File tree Expand file tree Collapse file tree 3 files changed +25
-15
lines changed
tests/PHPStan/Rules/Methods Expand file tree Collapse file tree 3 files changed +25
-15
lines changed Original file line number Diff line number Diff line change 55use PhpParser \Node \Expr ;
66use PHPStan \Analyser \Scope ;
77use PHPStan \Php \PhpVersion ;
8- use PHPStan \Reflection \ParameterReflection ;
98use PHPStan \Reflection \ParametersAcceptor ;
109use PHPStan \Reflection \ResolvedFunctionVariant ;
1110use PHPStan \Type \ErrorType ;
@@ -410,12 +409,8 @@ private function processArguments(
410409 $ namedArgumentAlreadyOccurred = true ;
411410
412411 $ parametersCount = count ($ parameters );
413- $ requiredParametersByName = array_filter ($ unusedParametersByName , static function (ParameterReflection $ parameter ): bool {
414- return !$ parameter ->isOptional ();
415- });
416412 if (
417- count ($ requiredParametersByName ) !== 0
418- || !$ parametersAcceptor ->isVariadic ()
413+ !$ parametersAcceptor ->isVariadic ()
419414 || $ parametersCount <= 0
420415 || $ isBuiltin
421416 ) {
Original file line number Diff line number Diff line change @@ -1706,18 +1706,10 @@ public function testNamedArguments(): void
17061706 'Parameter ...$args of method NamedArgumentsMethod\Foo::doIpsum() expects string, int given. ' ,
17071707 91 ,
17081708 ],
1709- [
1710- 'Unknown parameter $foo in call to method NamedArgumentsMethod\Foo::doIpsum(). ' ,
1711- 92 ,
1712- ],
17131709 [
17141710 'Missing parameter $b (int) in call to method NamedArgumentsMethod\Foo::doIpsum(). ' ,
17151711 92 ,
17161712 ],
1717- [
1718- 'Unknown parameter $foo in call to method NamedArgumentsMethod\Foo::doIpsum(). ' ,
1719- 93 ,
1720- ],
17211713 [
17221714 'Missing parameter $a (int) in call to method NamedArgumentsMethod\Foo::doIpsum(). ' ,
17231715 93 ,
@@ -1913,7 +1905,12 @@ public function testBug4800(): void
19131905 $ this ->checkNullables = true ;
19141906 $ this ->checkUnionTypes = true ;
19151907 $ this ->phpVersion = 80000 ;
1916- $ this ->analyse ([__DIR__ . '/data/bug-4800.php ' ], []);
1908+ $ this ->analyse ([__DIR__ . '/data/bug-4800.php ' ], [
1909+ [
1910+ 'Missing parameter $bar (string) in call to method Bug4800\HelloWorld2::a(). ' ,
1911+ 36 ,
1912+ ],
1913+ ]);
19171914 }
19181915
19191916}
Original file line number Diff line number Diff line change @@ -18,3 +18,21 @@ public function b(): void
1818 $ this ->a (foo: 'bar ' , c: 3 );
1919 }
2020}
21+
22+ class HelloWorld2
23+ {
24+ /**
25+ * @param string|int ...$arguments
26+ */
27+ public function a (string $ bar , ...$ arguments ): string
28+ {
29+ return '' ;
30+ }
31+
32+ public function b (): void
33+ {
34+ $ this ->a (bar: 'baz ' , foo: 'bar ' , c: 3 );
35+ $ this ->a (foo: 'baz ' , bar: 'bar ' , c: 3 );
36+ $ this ->a (foo: 'bar ' , c: 3 );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments