Skip to content

Commit

Permalink
extract PhpDocUtil::matchInferencePlaceholder()
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Oct 8, 2022
1 parent 271f837 commit 05e4aa2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
23 changes: 19 additions & 4 deletions src/PhpDoc/PhpDocUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/QueryReflection/QueryReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 05e4aa2

Please sign in to comment.