Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #7178 again #7189

Merged
merged 1 commit into from Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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