diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dded4231..e325a38a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Improvements: - Disable the processing of includes/requires, it doesn't work very well but it has massive performance impact on certain projects #2580 - Include project PHP and runtime version and LSP status + - Add `iterable` "generic" `@param` in docblock #2585 Bug fixes: diff --git a/lib/WorseReflection/Bridge/TolerantParser/Diagnostics/DocblockMissingParamProvider.php b/lib/WorseReflection/Bridge/TolerantParser/Diagnostics/DocblockMissingParamProvider.php index 93a45b632..268551dc1 100644 --- a/lib/WorseReflection/Bridge/TolerantParser/Diagnostics/DocblockMissingParamProvider.php +++ b/lib/WorseReflection/Bridge/TolerantParser/Diagnostics/DocblockMissingParamProvider.php @@ -20,6 +20,7 @@ use Phpactor\WorseReflection\Core\Type\ClosureType; use Phpactor\WorseReflection\Core\Type\MissingType; use Phpactor\WorseReflection\Core\Type\MixedType; +use Phpactor\WorseReflection\Core\Type\PseudoIterableType; use Phpactor\WorseReflection\Core\Type\ReflectedClassType; use Phpactor\WorseReflection\Core\Util\NodeUtil; @@ -94,6 +95,9 @@ public function exit(NodeContextResolver $resolver, Frame $frame, Node $node): i if ($type instanceof ArrayType) { $type = new ArrayType(TypeFactory::int(), TypeFactory::mixed()); } + if ($type::class === PseudoIterableType::class) { + $type = new PseudoIterableType(TypeFactory::int(), TypeFactory::mixed()); + } // replace with "mixed" $type = $type->map(fn (Type $type) => $type instanceof MissingType ? new MixedType() : $type); @@ -171,6 +175,24 @@ public function foo(Generator $foobar) { Assert::assertEquals('Method "foo" is missing @param $foobar', $diagnostics->at(0)->message()); } ); + yield new DiagnosticExample( + title: 'iterable', + source: <<<'PHP' + byClass(DocblockMissingParamDiagnostic::class); + Assert::assertCount(1, $diagnostics); + Assert::assertEquals('Method "foo" is missing @param $foobar', $diagnostics->at(0)->message()); + } + ); yield new DiagnosticExample( title: 'array', source: <<<'PHP'