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

doesn't infer empty for ReflectionClass::getAttributes without params #7180

Merged
merged 3 commits into from Dec 16, 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 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
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