Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Type/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,14 @@ public function getObjectClassNames(): array

public function getObjectClassReflections(): array
{
return $this->pickFromTypes(
static fn (Type $type) => $type->getObjectClassReflections(),
static fn (Type $type) => $type->isObject()->yes(),
);
$reflections = [];
foreach ($this->types as $type) {
foreach ($type->getObjectClassReflections() as $reflection) {
$reflections[] = $reflection;
}
}

return $reflections;
}

public function getArrays(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public function testRule(): void
183,
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
],
[
'PHPDoc tag @phpstan-require-extends contains unknown class IncompatibleRequireExtends\SomeClass.',
183,
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
],
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public function testRule(): void
192,
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
],
[
'PHPDoc tag @phpstan-require-extends contains unknown class IncompatibleRequireExtends\SomeClass.',
192,
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
],
]);
}

Expand Down
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/SealedDefinitionClassRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function testRule(): void
26,
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
],
[
'PHPDoc tag @phpstan-sealed contains unknown class IncompatibleSealed\UnknownClass.',
46,
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
],
]);
}

Expand Down
5 changes: 5 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/incompatible-sealed.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ interface ValidInterface {}
* @phpstan-sealed SomeInterface
*/
interface ValidInterface2 {}

/**
* @phpstan-sealed UnknownClass|SomeClass
*/
class InvalidClassWithUnion {}
Loading