Code Monkey home page Code Monkey logo

Comments (7)

alcaeus avatar alcaeus commented on June 2, 2024 4

Pretty much every Symfony constraint does exactly that: https://github.com/symfony/symfony/blob/2bfcaeb31ff3b878734b0951851d25abf2b3321e/src/Symfony/Component/Validator/Constraints/NotNullValidator.php#L28. There should not be any magic involved with this: I could easily create a FooConstraint that returns YourValidator::class in its validatedBy method, and all of a sudden YourValidator::validate would run into a fatal error because it receives a constraint class it doesn't expect or understand. In this case, you want to make sure you're given the correct type instead of assuming some magic to do so.

I suggest closing this issue as there's nothing to fix: asserting against the constraint class is exactly what should be done.

from phpstan-symfony.

lookyman avatar lookyman commented on June 2, 2024 1

For now, just ignore the error in PHPStan's config. But I will look into what can be done about it. Haven't really worked with the validation component before, so it may take a while..

from phpstan-symfony.

Kocal avatar Kocal commented on June 2, 2024

Okay thanks 👍

from phpstan-symfony.

lookyman avatar lookyman commented on June 2, 2024

Also, maybe you could probably just add something like assert($constraint instanceof IsString); into the IsStringValidator::validate() method..

from phpstan-symfony.

Kocal avatar Kocal commented on June 2, 2024

Oh, I didn't know Symfony check for Constraint instance.
Well, I will do the same, thanks you guys!

from phpstan-symfony.

ismail1432 avatar ismail1432 commented on June 2, 2024

Thanks @alcaeus 👍

from phpstan-symfony.

github-actions avatar github-actions commented on June 2, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from phpstan-symfony.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.