Skip to content

Commit

Permalink
[PropertyInfo] Add non-*-int missing types for PhpStanExtractor
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchen90 committed Dec 16, 2024
1 parent dd882db commit 82904ae
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Symfony/Component/PropertyInfo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.3
---

* Add `non-positive-int`, `non-negative-int` and `non-zero-int` PHPStan types for `PhpStanExtractor`

7.1
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ public static function provideLegacyPseudoTypes(): array
['literalString', [new LegacyType(LegacyType::BUILTIN_TYPE_STRING, false, null)]],
['positiveInt', [new LegacyType(LegacyType::BUILTIN_TYPE_INT, false, null)]],
['negativeInt', [new LegacyType(LegacyType::BUILTIN_TYPE_INT, false, null)]],
['nonPositiveInt', [new LegacyType(LegacyType::BUILTIN_TYPE_INT, false, null)]],
['nonNegativeInt', [new LegacyType(LegacyType::BUILTIN_TYPE_INT, false, null)]],
['nonZeroInt', [new LegacyType(LegacyType::BUILTIN_TYPE_INT, false, null)]],
['nonEmptyArray', [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true)]],
['nonEmptyList', [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT))]],
['scalar', [new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT), new LegacyType(LegacyType::BUILTIN_TYPE_STRING), new LegacyType(LegacyType::BUILTIN_TYPE_BOOL)]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class PhpStanPseudoTypesDummy extends PseudoTypesDummy
/** @var negative-int */
public $negativeInt;

/** @var non-positive-int */
public $nonPositiveInt;

/** @var non-negative-int */
public $nonNegativeInt;

/** @var non-zero-int */
public $nonZeroInt;

/** @var non-empty-array */
public $nonEmptyArray;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ private function extractTypes(TypeNode $node, NameScope $nameScope): array
return match ($node->name) {
'integer',
'positive-int',
'negative-int' => [new Type(Type::BUILTIN_TYPE_INT)],
'negative-int',
'non-positive-int',
'non-negative-int',
'non-zero-int' => [new Type(Type::BUILTIN_TYPE_INT)],
'double' => [new Type(Type::BUILTIN_TYPE_FLOAT)],
'list',
'non-empty-list' => [new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT))],
Expand Down

0 comments on commit 82904ae

Please sign in to comment.