Skip to content

Commit 05e4aa2

Browse files
committed
extract PhpDocUtil::matchInferencePlaceholder()
1 parent 271f837 commit 05e4aa2

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/PhpDoc/PhpDocUtil.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,19 @@ public static function matchTaintEscape($callLike, Scope $scope): ?string
3939
}
4040

4141
/**
42+
* @api
43+
*
4244
* @param CallLike|MethodReflection $callLike
45+
*/
46+
public static function matchInferencePlaceholder($callLike, Scope $scope): ?string
47+
{
48+
return self::matchStringAnnotation('@phpstandba-inference-placeholder', $callLike, $scope);
49+
}
50+
51+
/**
52+
* @api
4353
*
44-
*@api
54+
* @param CallLike|MethodReflection $callLike
4555
*/
4656
public static function commentContains(string $text, $callLike, Scope $scope): bool
4757
{
@@ -66,11 +76,16 @@ public static function commentContains(string $text, $callLike, Scope $scope): b
6676
/**
6777
* Returns a unquoted plain string following a annotation.
6878
*
69-
* @param string $annotation e.g. '@phpstandba-inference-placeholder'
79+
* @param string $annotation e.g. '@phpstandba-inference-placeholder'
80+
* @param CallLike|MethodReflection $callLike
7081
*/
71-
public static function matchStringAnnotation(string $annotation, CallLike $callLike, Scope $scope): ?string
82+
private static function matchStringAnnotation(string $annotation, $callLike, Scope $scope): ?string
7283
{
73-
$methodReflection = self::getMethodReflection($callLike, $scope);
84+
if ($callLike instanceof CallLike) {
85+
$methodReflection = self::getMethodReflection($callLike, $scope);
86+
} else {
87+
$methodReflection = $callLike;
88+
}
7489

7590
if (null !== $methodReflection) {
7691
// atm no resolved phpdoc for methods

src/QueryReflection/QueryReflection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ private function resolveQueryStringExpr(Expr $queryExpr, Scope $scope, bool $res
205205
return '1';
206206
}
207207

208-
$placeholder = PhpDocUtil::matchStringAnnotation('@phpstandba-inference-placeholder', $queryExpr, $scope);
209-
208+
$placeholder = PhpDocUtil::matchInferencePlaceholder($queryExpr, $scope);
210209
if (null !== $placeholder) {
211210
return $placeholder;
212211
}

0 commit comments

Comments
 (0)