mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Param: do not resolve types if it's not possible
-> https://travis-ci.org/github/JetBrains/phpstorm-stubs/builds/723069982 -> https://github.com/JetBrains/phpstorm-stubs/pull/892
This commit is contained in:
+18
-13
@@ -75,7 +75,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
$isReference = false;
|
$isReference = false;
|
||||||
|
|
||||||
// if the first item that is encountered is not a variable; it is a type
|
// if the first item that is encountered is not a variable; it is a type
|
||||||
if ($firstPart && $firstPart[0] !== '$') {
|
if ($firstPart && !self::strStartsWithVariable($firstPart)) {
|
||||||
$type = $typeResolver->resolve($firstPart, $context);
|
$type = $typeResolver->resolve($firstPart, $context);
|
||||||
} else {
|
} else {
|
||||||
// first part is not a type; we should prepend it to the parts array for further processing
|
// first part is not a type; we should prepend it to the parts array for further processing
|
||||||
@@ -83,18 +83,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if the next item starts with a $ or ...$ or &$ or &...$ it must be the variable name
|
// if the next item starts with a $ or ...$ or &$ or &...$ it must be the variable name
|
||||||
if (isset($parts[0])
|
if (isset($parts[0]) && self::strStartsWithVariable($parts[0])) {
|
||||||
&&
|
|
||||||
(
|
|
||||||
strpos($parts[0], '$') === 0
|
|
||||||
||
|
|
||||||
strpos($parts[0], '...$') === 0
|
|
||||||
||
|
|
||||||
strpos($parts[0], '&$') === 0
|
|
||||||
||
|
|
||||||
strpos($parts[0], '&...$') === 0
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$variableName = array_shift($parts);
|
$variableName = array_shift($parts);
|
||||||
array_shift($parts);
|
array_shift($parts);
|
||||||
|
|
||||||
@@ -155,4 +144,20 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
. ($this->variableName !== null ? '$' . $this->variableName : '')
|
. ($this->variableName !== null ? '$' . $this->variableName : '')
|
||||||
. ($this->description ? ' ' . $this->description : '');
|
. ($this->description ? ' ' . $this->description : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $str
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function strStartsWithVariable(string $str): bool
|
||||||
|
{
|
||||||
|
return strpos($str, '$') === 0
|
||||||
|
||
|
||||||
|
strpos($str, '...$') === 0
|
||||||
|
||
|
||||||
|
strpos($str, '&$') === 0
|
||||||
|
||
|
||||||
|
strpos($str, '&...$') === 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user