From e0acf87ea305e18a808773e9168851b2ab49ae77 Mon Sep 17 00:00:00 2001 From: phpstan-bot <79867460+phpstan-bot@users.noreply.github.com> Date: Wed, 17 Jun 2026 05:45:25 +0000 Subject: [PATCH] RequiredPhpVersionVisitor: report named arguments as requiring PHP 8.0 - Detect named arguments via a single `Node\Arg` check with a non-null `name`, which covers every call context at once: function calls, method calls, nullsafe method calls, static calls, `new` expressions and attributes. - Add `testDetectedVersion` cases for named arguments across all those contexts plus a negative case for positional-only arguments. - Add `// lint >= 8.0` comments to the fixtures the new detection flagged so they are skipped on older PHP versions in CI. For the two `nsrt` fixtures (consumed by TypeInferenceTestCase, which requires the comment to immediately follow `name !== null) { + $this->require(self::PHP_8_0, 'named arguments', $node); + } + $this->checkStandaloneType($node); $this->checkMixedType($node); diff --git a/tests/PHPStan/Analyser/data/bug-14596.php b/tests/PHPStan/Analyser/data/bug-14596.php index 8904c0c805..c8028a43e2 100644 --- a/tests/PHPStan/Analyser/data/bug-14596.php +++ b/tests/PHPStan/Analyser/data/bug-14596.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug14596; diff --git a/tests/PHPStan/Analyser/data/bug-9428.php b/tests/PHPStan/Analyser/data/bug-9428.php index 90d47479f1..596c99c0d1 100644 --- a/tests/PHPStan/Analyser/data/bug-9428.php +++ b/tests/PHPStan/Analyser/data/bug-9428.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug9428; diff --git a/tests/PHPStan/Analyser/data/discussion-7124.php b/tests/PHPStan/Analyser/data/discussion-7124.php index 4560c0954e..29a8d1f5f5 100644 --- a/tests/PHPStan/Analyser/data/discussion-7124.php +++ b/tests/PHPStan/Analyser/data/discussion-7124.php @@ -1,4 +1,4 @@ -= 8.0 namespace Discussion7124; diff --git a/tests/PHPStan/Analyser/nsrt/bug-4510.php b/tests/PHPStan/Analyser/nsrt/bug-4510.php index 3c5b2c52f7..c5cedb7714 100644 --- a/tests/PHPStan/Analyser/nsrt/bug-4510.php +++ b/tests/PHPStan/Analyser/nsrt/bug-4510.php @@ -1,4 +1,5 @@ -= 8.0 +declare(strict_types = 1); namespace Bug4510; diff --git a/tests/PHPStan/Analyser/nsrt/bug-5262.php b/tests/PHPStan/Analyser/nsrt/bug-5262.php index 229d9fbeb2..e60eb70499 100644 --- a/tests/PHPStan/Analyser/nsrt/bug-5262.php +++ b/tests/PHPStan/Analyser/nsrt/bug-5262.php @@ -1,4 +1,5 @@ -= 8.0 +declare(strict_types = 1); namespace Bug5262; diff --git a/tests/PHPStan/Build/RequiredPhpVersionCommentTest.php b/tests/PHPStan/Build/RequiredPhpVersionCommentTest.php index 16a8eb2684..33e82077e4 100644 --- a/tests/PHPStan/Build/RequiredPhpVersionCommentTest.php +++ b/tests/PHPStan/Build/RequiredPhpVersionCommentTest.php @@ -132,6 +132,13 @@ public static function dataDetectedVersion(): iterable yield 'nullable union type' => [' [' [' [' ['bar(baz: 1);', 80000]; + yield 'named argument in nullsafe method call' => ['bar(baz: 1);', 80000]; + yield 'named argument in static call' => [' [' [' [' [' [' ['= 8.0 namespace ClassAttributes; diff --git a/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php b/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php index f226cb3658..ed1047d020 100644 --- a/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallCallablesRuleTest.php @@ -391,27 +391,27 @@ public function testBug4510(): void $this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-4510.php'], [ [ 'Trying to invoke array{$this(Bug4510\HelloWorld), string} but it might not be a callable.', - 16, + 17, ], [ 'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.', - 27, + 28, ], [ "Trying to invoke array{'Bug4510\\\HelloWorld', string} but it might not be a callable.", - 46, + 47, ], [ 'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.', - 90, + 91, ], [ 'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.', - 118, + 119, ], [ 'Trying to invoke array{Bug4510\HelloWorld, string} but it might not be a callable.', - 133, + 134, ], ]); } diff --git a/tests/PHPStan/Rules/Functions/data/array_values_list.php b/tests/PHPStan/Rules/Functions/data/array_values_list.php index 7eef89c9cd..9b8cbbd4a9 100644 --- a/tests/PHPStan/Rules/Functions/data/array_values_list.php +++ b/tests/PHPStan/Rules/Functions/data/array_values_list.php @@ -1,4 +1,4 @@ -= 8.0 /** @var list $list */ $list = [1, 2, 3]; diff --git a/tests/PHPStan/Rules/Functions/data/bug-11418.php b/tests/PHPStan/Rules/Functions/data/bug-11418.php index 8172892d95..6df92d50c3 100755 --- a/tests/PHPStan/Rules/Functions/data/bug-11418.php +++ b/tests/PHPStan/Rules/Functions/data/bug-11418.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug11418; diff --git a/tests/PHPStan/Rules/Functions/data/bug-13719.php b/tests/PHPStan/Rules/Functions/data/bug-13719.php index 8a33eb50f3..942e58002e 100644 --- a/tests/PHPStan/Rules/Functions/data/bug-13719.php +++ b/tests/PHPStan/Rules/Functions/data/bug-13719.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug13719; diff --git a/tests/PHPStan/Rules/Functions/data/bug-8046.php b/tests/PHPStan/Rules/Functions/data/bug-8046.php index 368f656341..ae243ca257 100644 --- a/tests/PHPStan/Rules/Functions/data/bug-8046.php +++ b/tests/PHPStan/Rules/Functions/data/bug-8046.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug8046; diff --git a/tests/PHPStan/Rules/Functions/data/bug-9823.php b/tests/PHPStan/Rules/Functions/data/bug-9823.php index 3c8b3cfb77..38cfa8e65b 100644 --- a/tests/PHPStan/Rules/Functions/data/bug-9823.php +++ b/tests/PHPStan/Rules/Functions/data/bug-9823.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug9823; diff --git a/tests/PHPStan/Rules/Functions/data/callables-named-arguments.php b/tests/PHPStan/Rules/Functions/data/callables-named-arguments.php index 38e04e86c9..f55d8f583b 100644 --- a/tests/PHPStan/Rules/Functions/data/callables-named-arguments.php +++ b/tests/PHPStan/Rules/Functions/data/callables-named-arguments.php @@ -1,4 +1,4 @@ -= 8.0 namespace CallablesNamedArguments; diff --git a/tests/PHPStan/Rules/Functions/data/constant-parameter-check.php b/tests/PHPStan/Rules/Functions/data/constant-parameter-check.php index 70878d4eee..48b082b0e1 100644 --- a/tests/PHPStan/Rules/Functions/data/constant-parameter-check.php +++ b/tests/PHPStan/Rules/Functions/data/constant-parameter-check.php @@ -1,4 +1,4 @@ -= 8.0 namespace ConstantParameterCheck; diff --git a/tests/PHPStan/Rules/Functions/data/function-call-statement-no-side-effects-8.0.php b/tests/PHPStan/Rules/Functions/data/function-call-statement-no-side-effects-8.0.php index 497de17310..197b68e331 100644 --- a/tests/PHPStan/Rules/Functions/data/function-call-statement-no-side-effects-8.0.php +++ b/tests/PHPStan/Rules/Functions/data/function-call-statement-no-side-effects-8.0.php @@ -1,4 +1,4 @@ -= 8.0 namespace FunctionCallStatementNoSideEffectsPhp8; diff --git a/tests/PHPStan/Rules/Functions/data/implode-named-parameters.php b/tests/PHPStan/Rules/Functions/data/implode-named-parameters.php index 8e016b5157..a738586071 100644 --- a/tests/PHPStan/Rules/Functions/data/implode-named-parameters.php +++ b/tests/PHPStan/Rules/Functions/data/implode-named-parameters.php @@ -1,4 +1,4 @@ -= 8.0 namespace ImplodeNamedParameters; diff --git a/tests/PHPStan/Rules/Functions/data/named-arguments-after-unpacking.php b/tests/PHPStan/Rules/Functions/data/named-arguments-after-unpacking.php index 29d9ac8b4e..b9a9c0b2a3 100755 --- a/tests/PHPStan/Rules/Functions/data/named-arguments-after-unpacking.php +++ b/tests/PHPStan/Rules/Functions/data/named-arguments-after-unpacking.php @@ -1,4 +1,4 @@ -= 8.0 namespace FunctionNamedArgumentsAfterUnpacking; diff --git a/tests/PHPStan/Rules/Functions/data/named-arguments.php b/tests/PHPStan/Rules/Functions/data/named-arguments.php index 4cda8071d1..3542672ff2 100644 --- a/tests/PHPStan/Rules/Functions/data/named-arguments.php +++ b/tests/PHPStan/Rules/Functions/data/named-arguments.php @@ -1,4 +1,4 @@ -= 8.0 namespace FunctionNamedArguments; diff --git a/tests/PHPStan/Rules/Methods/data/bug-14596.php b/tests/PHPStan/Rules/Methods/data/bug-14596.php index f35305cdc3..973c6716a6 100644 --- a/tests/PHPStan/Rules/Methods/data/bug-14596.php +++ b/tests/PHPStan/Rules/Methods/data/bug-14596.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug14596Methods; diff --git a/tests/PHPStan/Rules/Methods/data/bug-5898.php b/tests/PHPStan/Rules/Methods/data/bug-5898.php index cbf5e3cb47..315a1bbfff 100644 --- a/tests/PHPStan/Rules/Methods/data/bug-5898.php +++ b/tests/PHPStan/Rules/Methods/data/bug-5898.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug5898; diff --git a/tests/PHPStan/Rules/Methods/data/bug-7434.php b/tests/PHPStan/Rules/Methods/data/bug-7434.php index be1750fdfb..692799146a 100644 --- a/tests/PHPStan/Rules/Methods/data/bug-7434.php +++ b/tests/PHPStan/Rules/Methods/data/bug-7434.php @@ -1,4 +1,4 @@ -= 8.0 namespace Bug7434; diff --git a/tests/PHPStan/Rules/Methods/data/constant-parameter-check-methods.php b/tests/PHPStan/Rules/Methods/data/constant-parameter-check-methods.php index 8025fc62d6..4b69554a4b 100644 --- a/tests/PHPStan/Rules/Methods/data/constant-parameter-check-methods.php +++ b/tests/PHPStan/Rules/Methods/data/constant-parameter-check-methods.php @@ -1,4 +1,4 @@ -= 8.0 namespace ConstantParameterCheckMethods; diff --git a/tests/PHPStan/Rules/Methods/data/disallow-named-arguments-php-version-scope.php b/tests/PHPStan/Rules/Methods/data/disallow-named-arguments-php-version-scope.php index 174fef244d..7302d5cf1a 100644 --- a/tests/PHPStan/Rules/Methods/data/disallow-named-arguments-php-version-scope.php +++ b/tests/PHPStan/Rules/Methods/data/disallow-named-arguments-php-version-scope.php @@ -1,4 +1,4 @@ -= 8.0 namespace DisallowNamedArgumentsInPhpVersionScope; diff --git a/tests/PHPStan/Rules/Methods/data/disallow-named-arguments.php b/tests/PHPStan/Rules/Methods/data/disallow-named-arguments.php index daff44a02b..4ec3be6e6e 100644 --- a/tests/PHPStan/Rules/Methods/data/disallow-named-arguments.php +++ b/tests/PHPStan/Rules/Methods/data/disallow-named-arguments.php @@ -1,4 +1,4 @@ -= 8.0 namespace DisallowNamedArguments; diff --git a/tests/PHPStan/Rules/Methods/data/named-arguments.php b/tests/PHPStan/Rules/Methods/data/named-arguments.php index 2896572193..9b79bb05bd 100644 --- a/tests/PHPStan/Rules/Methods/data/named-arguments.php +++ b/tests/PHPStan/Rules/Methods/data/named-arguments.php @@ -1,4 +1,4 @@ -= 8.0 namespace NamedArgumentsMethod; diff --git a/tests/PHPStan/Rules/Methods/data/static-method-named-arguments.php b/tests/PHPStan/Rules/Methods/data/static-method-named-arguments.php index 4046b4b1c0..b05a185dff 100644 --- a/tests/PHPStan/Rules/Methods/data/static-method-named-arguments.php +++ b/tests/PHPStan/Rules/Methods/data/static-method-named-arguments.php @@ -1,4 +1,4 @@ -= 8.0 namespace StaticMethodNamedArguments;