Skip to content

Commit

Permalink
fix: Fixed an issue that would cause the field type to be unusable if…
Browse files Browse the repository at this point in the history
… you were running PHP 8 or later, due to additions in the token parser in PHP 8 ([#40](#40))
  • Loading branch information
khalwat committed May 17, 2022
1 parent 468d7c1 commit 800d25d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/helpers/ClassMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ClassMapGenerator
* Generate a class map file.
*
* @param array|string $dirs Directories or a single path to search in
* @param string $file The name of the class map file
* @param string $file The name of the class map file
*/
public static function dump($dirs, $file)
{
Expand Down Expand Up @@ -92,8 +92,14 @@ private static function findClasses($path): array
$namespace = '';
// If there is a namespace, extract it
while (isset($tokens[++$i][1])) {
if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR], false)) {
$namespace .= $tokens[$i][1];
if (PHP_MAJOR_VERSION >= 8) {
if (\in_array($tokens[$i][0], [T_NAME_QUALIFIED], false)) {
$namespace .= $tokens[$i][1];
}
} else {
if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR], false)) {
$namespace .= $tokens[$i][1];
}
}
}
$namespace .= '\\';
Expand Down Expand Up @@ -126,7 +132,7 @@ private static function findClasses($path): array
break;
}
}
$classes[] = ltrim($namespace.$class, '\\');
$classes[] = ltrim($namespace . $class, '\\');
break;
default:
break;
Expand Down

0 comments on commit 800d25d

Please sign in to comment.