Proposed extension info change to allow getting info for unloaded extensions

This commit is contained in:
Matthew Barbour
2019-08-01 11:20:09 -05:00
committed by matthew
parent e6411c32aa
commit 3d1b964812
9 changed files with 192 additions and 69 deletions

View File

@@ -801,4 +801,31 @@ function iterator_map(callable $callback, iterator $iter): Generator
function iterator_map_to_array(callable $callback, iterator $iter): array
{
return iterator_to_array(iterator_map($callback, $iter));
}
function get_class_from_file(string $file): string
{
$fp = fopen($file, 'r');
$class = $buffer = '';
$i = 0;
while (!$class) {
if (feof($fp)) break;
$buffer .= fread($fp, 512);
$tokens = token_get_all($buffer);
if (strpos($buffer, '{') === false) continue;
for (;$i<count($tokens);$i++) {
if ($tokens[$i][0] === T_CLASS) {
for ($j=$i+1;$j<count($tokens);$j++) {
if ($tokens[$j] === '{') {
$class = $tokens[$i+2][1];
}
}
}
}
}
return $class;
}