File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
tests/PHPStan/Rules/Methods Expand file tree Collapse file tree 3 files changed +38
-1
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 ;
89use PHPStan \Reflection \ParametersAcceptor ;
910use PHPStan \Reflection \ResolvedFunctionVariant ;
1011use PHPStan \Type \ErrorType ;
@@ -409,8 +410,11 @@ private function processArguments(
409410 $ namedArgumentAlreadyOccurred = true ;
410411
411412 $ parametersCount = count ($ parameters );
413+ $ requiredParametersByName = array_filter ($ unusedParametersByName , static function (ParameterReflection $ parameter ): bool {
414+ return !$ parameter ->isOptional ();
415+ });
412416 if (
413- count ($ unusedParametersByName ) !== 0
417+ count ($ requiredParametersByName ) !== 0
414418 || !$ parametersAcceptor ->isVariadic ()
415419 || $ parametersCount <= 0
416420 || $ isBuiltin
Original file line number Diff line number Diff line change @@ -1903,4 +1903,17 @@ public function testBug3546(): void
19031903 $ this ->analyse ([__DIR__ . '/data/bug-3546.php ' ], []);
19041904 }
19051905
1906+ public function testBug4800 (): void
1907+ {
1908+ if (!self ::$ useStaticReflectionProvider ) {
1909+ $ this ->markTestSkipped ('Test requires static reflection. ' );
1910+ }
1911+
1912+ $ this ->checkThisOnly = false ;
1913+ $ this ->checkNullables = true ;
1914+ $ this ->checkUnionTypes = true ;
1915+ $ this ->phpVersion = 80000 ;
1916+ $ this ->analyse ([__DIR__ . '/data/bug-4800.php ' ], []);
1917+ }
1918+
19061919}
Original file line number Diff line number Diff line change 1+ <?php // lint >= 8.0
2+
3+ namespace Bug4800 ;
4+
5+ class HelloWorld
6+ {
7+ /**
8+ * @param string|int ...$arguments
9+ */
10+ public function a (string $ bar = '' , ...$ arguments ): string
11+ {
12+ return '' ;
13+ }
14+
15+ public function b (): void
16+ {
17+ $ this ->a (bar: 'baz ' , foo: 'bar ' , c: 3 );
18+ $ this ->a (foo: 'bar ' , c: 3 );
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments