[Rule idea] Prevent injecting the ValidatorInterface in classes extending ConstraintValidator
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
No file or test is named. Start by locating the rule definitions and tests for classes implementing ConstraintValidatorInterface, then verify how constructor injection and #[Required] methods are represented; done means reporting ValidatorInterface injection in those classes without flagging other consumers.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Sometimes (for advanced cases), it is useful to execute validation of other constraints in the implementation of a ConstraintValidator.
The supported way of doing that in symfony/validator is to use $this->context->getValidator() (following the usage described in https://github.com/symfony/symfony/blob/v7.3.0/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php#L21-L58).
When providing support on the Symfony Slack, I encountered a case where a dev has injected the ValidatorInterface in the constraint instead and uses that. This broke everything because the main validator (entrypoint of the component) is injecting its current execution context in all the registered constraint validator, which will impact the in-progress validation when starting a new one (constraint validators will not attach all their violations to the new execution context even when not expected).
A static analysis rule could prevent such mistake by detecting places where we inject the Symfony\Component\Validator\Validator\ValidatorInterface (either through the constructor or through a method that has the #[Required] attribute of symfony/service-contracts) in a class implementing Symfony\Component\Validator\ConstraintValidatorInterface.
- Ngôn ngữ chính
- PHP
- Star
- 806
- Fork
- 107
- Merge trung bình
- 1 giờ 55 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của phpstan/phpstan-symfony
-
`ParameterBag::keys()` stub not applied for Symfony ≥ 7.4 → false-positive `is_string()` `alwaysNarrowedType`Có thể đã có người làm @ChrisAbner đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
phpstan/phpstan-symfony#510 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
phpstan/phpstan-symfony#494 · 5 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
phpstan/phpstan-symfony#268 ·
-
Account for `\ErrorException` from `unserialize()` when Symfony’s PHP error conversion is enabledĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
phpstan/phpstan-symfony#514 · 2 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
phpstan/phpstan-symfony#509 · 2 bình luận ·
Tất cả issue của phpstan/phpstan-symfony
Issue tương tự
-
fixed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
firefly-iii/firefly-iii#13150 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
TYPO3-Solr/ext-solr#4828 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Перевод устарел
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày