File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
tests/Rule/data/providers Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,10 @@ protected function shouldMarkAsUsed(ReflectionMethod $method): ?string
326
326
return 'Route method via #[Route] attribute ' ;
327
327
}
328
328
329
+ if ($ this ->isMethodWithCallbackConstraintAttribute ($ method )) {
330
+ return 'Callback constraint method via #[Assert\Callback] attribute ' ;
331
+ }
332
+
329
333
if ($ this ->isProbablySymfonyListener ($ method )) {
330
334
return 'Probable listener method ' ;
331
335
}
@@ -461,6 +465,11 @@ protected function isMethodWithRouteAttribute(ReflectionMethod $method): bool
461
465
|| $ this ->hasAttribute ($ method , 'Symfony\Component\Routing\Annotation\Route ' , $ isInstanceOf );
462
466
}
463
467
468
+ protected function isMethodWithCallbackConstraintAttribute (ReflectionMethod $ method ): bool
469
+ {
470
+ return $ this ->hasAttribute ($ method , 'Symfony\Component\Validator\Constraints\Callback ' );
471
+ }
472
+
464
473
/**
465
474
* Ideally, we would need to parse DIC xml to know this for sure just like phpstan-symfony does.
466
475
*/
Original file line number Diff line number Diff line change 16
16
use Symfony \Component \HttpKernel \Event \GetResponseForExceptionEvent ;
17
17
use Symfony \Component \Routing \Attribute \Route ;
18
18
use Symfony \Contracts \Service \Attribute \Required ;
19
+ use Symfony \Component \Validator \Constraints as Assert ;
19
20
20
21
class SomeController {
21
22
@@ -115,3 +116,9 @@ public function create(): self {
115
116
class Sftp {
116
117
const RETRY_LIMIT = 3 ; // used in yaml via !php/const
117
118
}
119
+
120
+ class ValidatedModel
121
+ {
122
+ #[Assert \Callback]
123
+ public function validate (): void {}
124
+ }
You can’t perform that action at this time.
0 commit comments