Skip to content

Commit

Permalink
Merge fd9c2d9 into 2eab92c
Browse files Browse the repository at this point in the history
  • Loading branch information
vvval committed Mar 12, 2019
2 parents 2eab92c + fd9c2d9 commit ee994a8
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions source/Spiral/Tokenizer/Reflections/ReflectionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ protected function importSchema(array $cache): bool
{
if (count($cache) === 4) {
list($this->hasIncludes, $this->declarations, $this->functions, $this->namespaces) = $cache;

return true;
}

Expand Down Expand Up @@ -297,13 +298,9 @@ protected function locateDeclarations()
case T_CLASS:
case T_TRAIT:
case T_INTERFACE:
if (
$this->tokens[$tokenID][self::TOKEN_TYPE] == T_CLASS
&& isset($this->tokens[$tokenID - 1])
&& $this->tokens[$tokenID - 1][self::TOKEN_TYPE] == T_PAAMAYIM_NEKUDOTAYIM
) {
if ($this->isClassNameConst($tokenID)) {
//PHP5.5 ClassName::class constant
continue;
continue 2;
}

$this->registerDeclaration($tokenID, $token[self::TOKEN_TYPE]);
Expand Down Expand Up @@ -458,6 +455,20 @@ private function registerDeclaration(int $tokenID, int $tokenType)
];
}

/**
* Check if token ID represents `ClassName::class` constant statement.
*
* @param int $tokenID
*
* @return bool
*/
private function isClassNameConst(int $tokenID): bool
{
return $this->tokens[$tokenID][self::TOKEN_TYPE] == T_CLASS
&& isset($this->tokens[$tokenID - 1])
&& $this->tokens[$tokenID - 1][self::TOKEN_TYPE] == T_PAAMAYIM_NEKUDOTAYIM;
}

/**
* Locate every function or static method call (including $this calls).
*
Expand Down

0 comments on commit ee994a8

Please sign in to comment.