Skip to content

Commit

Permalink
added support for PHP 8.1 enum [Closes #23]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 25, 2021
1 parent e0463dd commit e2adc33
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ private function scanPhp(string $file): array
case T_CLASS:
case T_INTERFACE:
case T_TRAIT:
case PHP_VERSION_ID < 80100
? T_CLASS
: T_ENUM:
$expected = $token[0];
$name = '';
continue 2;
Expand All @@ -396,20 +399,13 @@ private function scanPhp(string $file): array
}

if ($expected) {
switch ($expected) {
case T_CLASS:
case T_INTERFACE:
case T_TRAIT:
if ($name && $level === $minLevel) {
$classes[] = $namespace . $name;
}
break;
if ($expected === T_NAMESPACE) {
$namespace = $name ? $name . '\\' : '';
$minLevel = $token === '{' ? 1 : 0;

case T_NAMESPACE:
$namespace = $name ? $name . '\\' : '';
$minLevel = $token === '{' ? 1 : 0;
} elseif ($name && $level === $minLevel) {
$classes[] = $namespace . $name;
}

$expected = null;
}

Expand Down

0 comments on commit e2adc33

Please sign in to comment.