Skip to content

Commit

Permalink
Merge pull request #7189 from orklah/7178-2
Browse files Browse the repository at this point in the history
fix #7178 again
  • Loading branch information
orklah committed Dec 20, 2021
2 parents 2e32a18 + 639b1b9 commit 3a2cce7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion stubs/Reflection.phpstub
Expand Up @@ -51,7 +51,7 @@ class ReflectionClass implements Reflector {
* @since 8.0
* @template TClass as object
* @param class-string<TClass>|null $name
* @return (TClass is object ? array<ReflectionAttribute<TClass>> : array<ReflectionAttribute<object>>)
* @return ($name is null ? array<ReflectionAttribute<object>> : array<ReflectionAttribute<TClass>>)
*/
public function getAttributes(?string $name = null, int $flags = 0): array {}
}
Expand Down
25 changes: 7 additions & 18 deletions tests/AttributeTest.php
Expand Up @@ -104,26 +104,15 @@ function foo(string $s) : void {
],
'testReflectingAllAttributes' => [
'<?php
/** @var class-string $a */
$cs = stdClass::class;
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{
}
$a = new ReflectionClass($cs);
$b = $a->getAttributes();
',
[],
'assertions' => [
'$b' => 'array<array-key, ReflectionAttribute<object>>',
],
[],
'8.0'
],
Expand Down

0 comments on commit 3a2cce7

Please sign in to comment.