@@ -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,23 @@ 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
+ $ attributes = $ method ->getDeclaringClass ()->getAttributes ('Symfony\Component\Validator\Constraints\Callback ' );
471
+
472
+ foreach ($ attributes as $ attribute ) {
473
+ $ arguments = $ attribute ->getArguments ();
474
+
475
+ $ callback = $ arguments ['callback ' ] ?? $ arguments [0 ] ?? null ;
476
+
477
+ if ($ callback === $ method ->getName ()) {
478
+ return true ;
479
+ }
480
+ }
481
+
482
+ return $ this ->hasAttribute ($ method , 'Symfony\Component\Validator\Constraints\Callback ' );
483
+ }
484
+
464
485
/**
465
486
* Ideally, we would need to parse DIC xml to know this for sure just like phpstan-symfony does.
466
487
*/
@@ -502,6 +523,7 @@ private function isSymfonyInstalled(): bool
502
523
|| InstalledVersions::isInstalled ('symfony/contracts ' )
503
524
|| InstalledVersions::isInstalled ('symfony/console ' )
504
525
|| InstalledVersions::isInstalled ('symfony/http-kernel ' )
526
+ || InstalledVersions::isInstalled ('symfony/validator ' )
505
527
|| InstalledVersions::isInstalled ('symfony/dependency-injection ' );
506
528
}
507
529
0 commit comments