Skip to content

Commit

Permalink
Merge pull request #7180 from orklah/7178
Browse files Browse the repository at this point in the history
doesn't infer empty for ReflectionClass::getAttributes without params
  • Loading branch information
orklah committed Dec 16, 2021
2 parents f4b48ab + ba6a4d8 commit e9ad61e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stubs/Reflection.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ReflectionClass implements Reflector {
* @since 8.0
* @template TClass as object
* @param class-string<TClass>|null $name
* @return array<ReflectionAttribute<TClass>>
* @return (TClass is object ? array<ReflectionAttribute<TClass>> : array<ReflectionAttribute<object>>)
*/
public function getAttributes(?string $name = null, int $flags = 0): array {}
}
Expand Down
25 changes: 25 additions & 0 deletions tests/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ function foo(string $s) : void {
[],
'8.0'
],
'testReflectingAllAttributes' => [
'<?php
final class a
{
/**
* @psalm-param class-string $className
*/
public function a(string $className): void
{
$a = new ReflectionClass($className);
$b = $a->getAttributes();
scope($b);
}
}
/** @param array<ReflectionAttribute<object>> $_a */
function scope($_a):void{
}
',
[],
[],
'8.0'
],
'convertKeyedArray' => [
'<?php
#[Attribute(Attribute::TARGET_CLASS)]
Expand Down

0 comments on commit e9ad61e

Please sign in to comment.