improve api docs generator class discrimination

This commit is contained in:
sunxyw
2022-04-15 23:37:54 +08:00
parent 97face2406
commit 371926b5a6

View File

@@ -91,6 +91,8 @@ use Jasny\PhpdocParser\Set\PhpDocumentor;
use Jasny\PhpdocParser\Tag\Summery; use Jasny\PhpdocParser\Tag\Summery;
use ZM\Console\Console; use ZM\Console\Console;
var_dump('hi');
$opts = getopt('', ['show-warnings']); $opts = getopt('', ['show-warnings']);
if (array_key_exists('show-warnings', $opts)) { if (array_key_exists('show-warnings', $opts)) {
$show_warnings = true; $show_warnings = true;
@@ -98,7 +100,7 @@ if (array_key_exists('show-warnings', $opts)) {
$show_warnings = false; $show_warnings = false;
} }
Console::init(2); Console::init(4);
$errors = []; $errors = [];
$warnings = []; $warnings = [];
@@ -296,12 +298,16 @@ foreach (new \RecursiveIteratorIterator($fs) as $file) {
// 过滤不包含类的文件 // 过滤不包含类的文件
$tokens = token_get_all(file_get_contents($path)); $tokens = token_get_all(file_get_contents($path));
$found = false; $found = false;
foreach ($tokens as $token) { foreach ($tokens as $k => $token) {
if (!is_array($token)) { if (!is_array($token)) {
continue; continue;
} }
if ($token[0] === T_CLASS) { if ($token[0] === T_CLASS && $tokens[$k - 2][0] !== T_NEW) {
$found = true; $found = true;
break;
}
if ($k >= 100) {
break;
} }
} }
if (!$found) { if (!$found) {