diff --git a/src/Handler/ContainerHandler.php b/src/Handler/ContainerHandler.php index 117b941..a4ce5a8 100644 --- a/src/Handler/ContainerHandler.php +++ b/src/Handler/ContainerHandler.php @@ -165,7 +165,7 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) } } - private static function isContainerMethod(string $declaringMethodId, string $methodName): bool + public static function isContainerMethod(string $declaringMethodId, string $methodName): bool { return in_array( $declaringMethodId, diff --git a/src/Handler/ParameterBagHandler.php b/src/Handler/ParameterBagHandler.php index 9dd1318..f8a84ad 100644 --- a/src/Handler/ParameterBagHandler.php +++ b/src/Handler/ParameterBagHandler.php @@ -24,14 +24,16 @@ public static function init(ContainerMeta $containerMeta): void public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $event): void { + if (!self::$containerMeta) { + return; + } + $declaring_method_id = $event->getDeclaringMethodId(); $expr = $event->getExpr(); - if (!self::$containerMeta || !in_array($declaring_method_id, [ - 'Symfony\Bundle\FrameworkBundle\Controller\AbstractController::getparameter', - 'Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface::get', - 'Symfony\Component\DependencyInjection\ContainerInterface::getparameter', - ], true)) { + if (!ContainerHandler::isContainerMethod($declaring_method_id, 'getparameter') + && 'Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface::get' !== $declaring_method_id + ) { return; }