forked from nette/utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6296f8d
commit e55a8da
Showing
1 changed file
with
10 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,11 +255,18 @@ private static function parseUseStatements(string $code, string $forClass = null | |
$namespace = $class = $classLevel = $level = null; | ||
$res = $uses = []; | ||
|
||
$nameTokens = [T_STRING, T_NS_SEPARATOR]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ondrejmirtes
Author
Owner
|
||
if (PHP_VERSION_ID >= 80000) { | ||
$nameTokens[] = T_NAME_QUALIFIED; | ||
$nameTokens[] = T_NAME_FULLY_QUALIFIED; | ||
$nameTokens[] = T_NAME_RELATIVE; | ||
} | ||
|
||
while ($token = current($tokens)) { | ||
next($tokens); | ||
switch (is_array($token) ? $token[0] : $token) { | ||
case T_NAMESPACE: | ||
$namespace = ltrim(self::fetch($tokens, [T_STRING, T_NS_SEPARATOR]) . '\\', '\\'); | ||
$namespace = ltrim(self::fetch($tokens, $nameTokens) . '\\', '\\'); | ||
$uses = []; | ||
break; | ||
|
||
|
@@ -277,10 +284,10 @@ private static function parseUseStatements(string $code, string $forClass = null | |
break; | ||
|
||
case T_USE: | ||
while (!$class && ($name = self::fetch($tokens, [T_STRING, T_NS_SEPARATOR]))) { | ||
while (!$class && ($name = self::fetch($tokens, $nameTokens))) { | ||
$name = ltrim($name, '\\'); | ||
if (self::fetch($tokens, '{')) { | ||
while ($suffix = self::fetch($tokens, [T_STRING, T_NS_SEPARATOR])) { | ||
while ($suffix = self::fetch($tokens, $nameTokens)) { | ||
if (self::fetch($tokens, T_AS)) { | ||
$uses[self::fetch($tokens, T_STRING)] = $name . $suffix; | ||
} else { | ||
|
Tady by šlo stručnější