diff --git a/src/PhpDoc/PhpDocUtil.php b/src/PhpDoc/PhpDocUtil.php index 0c4649c2c..909bb1a57 100644 --- a/src/PhpDoc/PhpDocUtil.php +++ b/src/PhpDoc/PhpDocUtil.php @@ -39,9 +39,19 @@ public static function matchTaintEscape($callLike, Scope $scope): ?string } /** + * @api + * * @param CallLike|MethodReflection $callLike + */ + public static function matchInferencePlaceholder($callLike, Scope $scope): ?string + { + return self::matchStringAnnotation('@phpstandba-inference-placeholder', $callLike, $scope); + } + + /** + * @api * - *@api + * @param CallLike|MethodReflection $callLike */ public static function commentContains(string $text, $callLike, Scope $scope): bool { @@ -66,11 +76,16 @@ public static function commentContains(string $text, $callLike, Scope $scope): b /** * Returns a unquoted plain string following a annotation. * - * @param string $annotation e.g. '@phpstandba-inference-placeholder' + * @param string $annotation e.g. '@phpstandba-inference-placeholder' + * @param CallLike|MethodReflection $callLike */ - public static function matchStringAnnotation(string $annotation, CallLike $callLike, Scope $scope): ?string + private static function matchStringAnnotation(string $annotation, $callLike, Scope $scope): ?string { - $methodReflection = self::getMethodReflection($callLike, $scope); + if ($callLike instanceof CallLike) { + $methodReflection = self::getMethodReflection($callLike, $scope); + } else { + $methodReflection = $callLike; + } if (null !== $methodReflection) { // atm no resolved phpdoc for methods diff --git a/src/QueryReflection/QueryReflection.php b/src/QueryReflection/QueryReflection.php index 4a532c86e..f62f24887 100644 --- a/src/QueryReflection/QueryReflection.php +++ b/src/QueryReflection/QueryReflection.php @@ -205,8 +205,7 @@ private function resolveQueryStringExpr(Expr $queryExpr, Scope $scope, bool $res return '1'; } - $placeholder = PhpDocUtil::matchStringAnnotation('@phpstandba-inference-placeholder', $queryExpr, $scope); - + $placeholder = PhpDocUtil::matchInferencePlaceholder($queryExpr, $scope); if (null !== $placeholder) { return $placeholder; }