From 3339144c786a26e01253260a967683fa01b70683 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 19 Dec 2025 22:25:24 +0100 Subject: [PATCH 1/2] dev --- composer.json | 2 +- phpstan.neon | 2 +- .../Fixture/class_is_nullable.php | 0 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.php diff --git a/composer.json b/composer.json index 198461ff..f5fbf6c1 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "phpstan/phpstan": "^2.1.32", "phpstan/phpstan-webmozart-assert": "^2.0", "phpunit/phpunit": "^11.5", - "rector/rector-src": "dev-main", + "rector/rector-src": "dev-tv-traverse-optimize", "rector/type-perfect": "^2.1", "symplify/easy-coding-standard": "^12.3", "symplify/phpstan-extensions": "^12.0", diff --git a/phpstan.neon b/phpstan.neon index 1def084a..0f541694 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,7 @@ parameters: level: 8 errorFormat: symplify - reportUnmatchedIgnoredErrors: false + # reportUnmatchedIgnoredErrors: false # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases typeAliases: diff --git a/rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.php b/rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.php new file mode 100644 index 00000000..e69de29b From ba6f2add2a1a9a829f675c42c276f0cf6da23b81 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 19 Dec 2025 22:49:23 +0100 Subject: [PATCH 2/2] misc --- phpstan.neon | 2 +- .../Fixture/class_is_nullable.php | 0 .../Rector/ConstFetch/DowngradePhp73JsonConstRector.php | 9 +++------ tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.php diff --git a/phpstan.neon b/phpstan.neon index 0f541694..1def084a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,7 @@ parameters: level: 8 errorFormat: symplify - # reportUnmatchedIgnoredErrors: false + reportUnmatchedIgnoredErrors: false # see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases typeAliases: diff --git a/rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.php b/rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.php deleted file mode 100644 index e69de29b..00000000 diff --git a/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php b/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php index 1ba690a2..4280417d 100644 --- a/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php +++ b/rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php @@ -118,9 +118,9 @@ private function markConstantKnownInInnerStmts(If_ $if): void SimpleNodeTraverser::decorateWithAttributeValue($if, self::PHP73_JSON_CONSTANT_IS_KNOWN, true); } - private function resolveFuncCall(Expression $Expression): ?FuncCall + private function resolveFuncCall(Expression $expression): ?FuncCall { - $expr = $Expression->expr; + $expr = $expression->expr; if ($expr instanceof Assign) { if ($expr->expr instanceof FuncCall) { return $expr->expr; @@ -154,8 +154,6 @@ private function refactorExpression(Expression $expression): ?array // retrieve a `FuncCall`, if any, from the statement $funcCall = $this->resolveFuncCall($expression); - - // Nothing to do if no `FuncCall` found if (! $funcCall instanceof FuncCall) { return null; } @@ -203,8 +201,7 @@ private function hasConstFetchInArgs(array $args, string $constName): bool { foreach ($args as $arg) { $value = $arg->value; - - if ($value instanceof ConstFetch && $this->getName($value) === $constName) { + if ($value instanceof ConstFetch && $this->isName($value, $constName)) { return true; } diff --git a/tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc b/tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc index 26757145..16cf462d 100644 --- a/tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc +++ b/tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc @@ -22,7 +22,7 @@ class Fixture { public function run(?int $flags = null) { - $flags = $flags ?? JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION; + $flags = $flags ?? JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION | 0; json_encode([], $flags); }