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

wrong template inference #7178

Closed
orklah opened this issue Dec 16, 2021 · 1 comment · Fixed by #7180
Closed

wrong template inference #7178

orklah opened this issue Dec 16, 2021 · 1 comment · Fixed by #7180

Comments

@orklah
Copy link
Collaborator

orklah commented Dec 16, 2021

https://psalm.dev/r/cc7ea40afd

$b should be array<array-key, ReflectionAttribute<object>>, not empty. In the remove-empty PR, it makes ReflectionAttribute generates Never everywhere that are then flagged as NoValue

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/cc7ea40afd
<?php

final class a
{
    /**
     * @psalm-param class-string $className
     */
    public function a(string $className): void
    {
        $a = new ReflectionClass($className);
        /** @psalm-trace $a */
        $b = $a->getAttributes();
        /** @psalm-trace $b */
    }
}
Psalm output (using commit f4b48ab):

INFO: Trace - 12:9 - $a: ReflectionClass<object>

INFO: Trace - 13:0 - $b: array<array-key, ReflectionAttribute<empty>>

INFO: UnusedVariable - 12:9 - $b is never referenced or the value is not used

orklah added a commit that referenced this issue Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant