mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Suggestion: Add new Types for non-empty-string and positive-int
#7449
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ThomasLandauer on GitHub (Dec 4, 2024).
Feature Request
What
Implement something like
Types:NON_EMPTY_STRINGandTypes::POSITIVE_INT.Why
Since Symfony 7.2,
UserInterface::getUserIdentifier()is annotated with@return non-empty-string.So if you're fetching that user identifier from the database, PHPStan will report something like:
So instead of telling everybody to just
@phpstan-ignoreit (e.g. at https://github.com/phpstan/phpstan-doctrine/issues/204), I'm wondering if it would be possible to fix the root cause :-)@curry684 commented on GitHub (Dec 26, 2024):
The root cause is not with Doctrine, as it does not take any responsibility for content validation whatsoever. As correctly pointed out in the linked issue you can always break it by directly editing the database anyway.
The true root cause is setting an entity field to non-empty-string. Your validation layers should ensure it does not get invalid content, not Doctrine or PHPStan.
@dcorroyer commented on GitHub (Jul 21, 2025):
I've just used an assert to fix my PHPStan error - maybe this could help you too.