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

When using PHP attributes it incorrectly "builds" the Fully Qualified Class Name #6211

Closed
Ilyes512 opened this issue Jul 31, 2021 · 1 comment · Fixed by #6215
Closed

When using PHP attributes it incorrectly "builds" the Fully Qualified Class Name #6211

Ilyes512 opened this issue Jul 31, 2021 · 1 comment · Fixed by #6215
Labels

Comments

@Ilyes512
Copy link

See https://psalm.dev/r/4dc3c5409a

This might have to do with #6197 and the linked PR #6204

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/4dc3c5409a
<?php

namespace NamespaceOne {
    use Attribute;
    
    #[Attribute(Attribute::TARGET_CLASS)]
    class FooAttribute
    {
        /** @var class-string */
        private string $className;

        /**
         * @param class-string<FoobarInterface> $className
         */
        public function __construct(string $className)
        {
            $this->className = $className;
        }
    }

    interface FoobarInterface {}

    class Bar implements FoobarInterface {}
}

namespace NamespaceTwo {
    use NamespaceOne\FooAttribute;
    use NamespaceOne\Bar;
    
	#[FooAttribute(className: Bar::class)]
	class Baz {}
}
Psalm output (using commit 7e137f5):

ERROR: InvalidArgument - 30:28 - Argument 1 of NamespaceOne\FooAttribute::__construct expects class-string<NamespaceOne\FoobarInterface>, NamespaceTwo\NamespaceOne\Bar::class provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants