Add UniqueEntity constraint field validation
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by reading the referenced RepositoryMethodCallRule.php and the Symfony UniqueEntity constraint documentation. Trace how objectManagerLoader exposes class metadata, then determine where the constraint's field arguments can be checked against the entity fields used by findBy. Done means invalid field names are reported while constraints with an overridden repository method remain ignored.
Written by the indexing model from the issue text.
Description
Symfony provides a UniqueEntity annotation
https://symfony.com/doc/current/reference/constraints/UniqueEntity.html
The first arguments need to be entity fields, which will be use by a findBy call (by default).
So a rule could be implemented, similar to https://github.com/phpstan/phpstan-doctrine/blob/0871900872abde0d93e4bbd8c681a9985bcd927e/src/Rules/Doctrine/ORM/RepositoryMethodCallRule.php#L19
in order to check that all field names passed exist.
The repository method can be overriden in the constraint to use something else than findBy,
as a first step we could ignore constraint with an overridden method.
@ondrejmirtes I know it's a Symfony constraint, but since it requires objectManagerLoader to have class metadata I think it's more an issue for phpstan-doctrine or phpstan-symfony.
- Dominant language
- PHP
- Stars
- 678
- Forks
- 122
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-doctrine
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
phpstan/phpstan-doctrine#785 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
phpstan/phpstan-doctrine#792 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
phpstan/phpstan-doctrine#788 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
phpstan/phpstan-doctrine#763 ·
All issues in phpstan/phpstan-doctrine
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100