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 5
5
use PhpParser \Node \Expr ;
6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Php \PhpVersion ;
8
+ use PHPStan \Reflection \ParameterReflection ;
8
9
use PHPStan \Reflection \ParametersAcceptor ;
9
10
use PHPStan \Reflection \ResolvedFunctionVariant ;
10
11
use PHPStan \Type \ErrorType ;
@@ -409,8 +410,11 @@ private function processArguments(
409
410
$ namedArgumentAlreadyOccurred = true ;
410
411
411
412
$ parametersCount = count ($ parameters );
413
+ $ requiredParametersByName = array_filter ($ unusedParametersByName , static function (ParameterReflection $ parameter ): bool {
414
+ return !$ parameter ->isOptional ();
415
+ });
412
416
if (
413
- count ($ unusedParametersByName ) !== 0
417
+ count ($ requiredParametersByName ) !== 0
414
418
|| !$ parametersAcceptor ->isVariadic ()
415
419
|| $ parametersCount <= 0
416
420
|| $ isBuiltin
Original file line number Diff line number Diff line change @@ -1903,4 +1903,17 @@ public function testBug3546(): void
1903
1903
$ this ->analyse ([__DIR__ . '/data/bug-3546.php ' ], []);
1904
1904
}
1905
1905
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
+
1906
1919
}
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