diff --git a/src/Symfony/Component/PropertyInfo/CHANGELOG.md b/src/Symfony/Component/PropertyInfo/CHANGELOG.md index 490dab43b4754..fd2d4e7207069 100644 --- a/src/Symfony/Component/PropertyInfo/CHANGELOG.md +++ b/src/Symfony/Component/PropertyInfo/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + +* Add `non-positive-int`, `non-negative-int` and `non-zero-int` PHPStan types for `PhpStanExtractor` + 7.1 --- diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php index 0d77497c2e1da..d2d847b12fe89 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php @@ -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)]], diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/PhpStanPseudoTypesDummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/PhpStanPseudoTypesDummy.php index 06690f4b1fd6f..08349def1a8c1 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/PhpStanPseudoTypesDummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/PhpStanPseudoTypesDummy.php @@ -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; diff --git a/src/Symfony/Component/PropertyInfo/Util/PhpStanTypeHelper.php b/src/Symfony/Component/PropertyInfo/Util/PhpStanTypeHelper.php index 69325f42ef6b3..a92ab2ca584d1 100644 --- a/src/Symfony/Component/PropertyInfo/Util/PhpStanTypeHelper.php +++ b/src/Symfony/Component/PropertyInfo/Util/PhpStanTypeHelper.php @@ -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))],