File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed
tests/PHPStan/Rules/Methods Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ private function getParameters(): array
142142
143143 /** @var \PhpParser\Node\Param $parameter */
144144 foreach (array_reverse ($ this ->functionLike ->getParams ()) as $ parameter ) {
145- if (! $ isOptional || $ parameter ->default === null ) {
145+ if ($ parameter ->default === null && ! $ parameter -> variadic ) {
146146 $ isOptional = false ;
147147 }
148148
@@ -151,7 +151,7 @@ private function getParameters(): array
151151 }
152152 $ parameters [] = new PhpParameterFromParserNodeReflection (
153153 $ parameter ->var ->name ,
154- $ isOptional || $ parameter -> variadic ,
154+ $ isOptional ,
155155 $ this ->realParameterTypes [$ parameter ->var ->name ],
156156 $ this ->phpDocParameterTypes [$ parameter ->var ->name ] ?? null ,
157157 $ parameter ->byRef
Original file line number Diff line number Diff line change @@ -330,4 +330,10 @@ public function testBug3403(int $phpVersion): void
330330 $ this ->analyse ([__DIR__ . '/data/bug-3403.php ' ], []);
331331 }
332332
333+ public function testBug3443 (): void
334+ {
335+ $ this ->phpVersionId = PHP_VERSION_ID ;
336+ $ this ->analyse ([__DIR__ . '/data/bug-3443.php ' ], []);
337+ }
338+
333339}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug3443 ;
4+
5+ /**
6+ * Interface Collection.
7+ */
8+ interface CollectionInterface
9+ {
10+
11+ /**
12+ * @param mixed $data
13+ * @param mixed ...$parameters
14+ *
15+ * @return mixed
16+ */
17+ public static function with ($ data = [], ...$ parameters );
18+
19+ }
20+
21+
22+ /**
23+ * Class Collection.
24+ */
25+ final class Collection implements CollectionInterface
26+ {
27+
28+ public static function with ($ data = [], ...$ parameters )
29+ {
30+ return new self ();
31+ }
32+
33+ }
You can’t perform that action at this time.
0 commit comments