Skip to content

False positive with namespace aliasing #51

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

Open
alamirault opened this issue Jan 6, 2024 · 1 comment
Open

False positive with namespace aliasing #51

alamirault opened this issue Jan 6, 2024 · 1 comment

Comments

@alamirault
Copy link

Hello,

Maybe somebody has an idea in order to avoid this false positive (found by https://github.com/symfony-tools/code-block-checker/blob/main/src/Service/CodeRunner/ClassExist.php)


https://github.com/symfony/symfony-docs/actions/runs/7431226718/job/20221747353?pr=19383

        // src/Entity/Author.php
        namespace App\Entity;

        use Symfony\Component\Validator\Constraints as Assert; # False positive here

        use Symfony\Component\Validator\Mapping\ClassMetadata;

        class Author
        {
            // ...

            public static function loadValidatorMetadata(ClassMetadata $metadata): void
            {
                $metadata->addPropertyConstraint('mac', new Assert\MacAddress());
            }
        }

[Missing class] Class, interface or trait with name "Symfony\Component\Validator\Constraints" does not exist

@stof
Copy link
Member

stof commented Jun 3, 2025

We should probably make a special case for use Symfony\Component\Validator\Constraints as Assert and use Doctrine\ORM\Mapping as ORM which are the 2 common cases used in the documentation where we use a namespace rather than a class. It should be enough for our needs.

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

No branches or pull requests

2 participants