parser = (new ParserFactory())->createForNewestSupportedVersion(); } /** * Parse PHP code into AST */ public function parse(string $code, string $filePath = ''): ?array { try { $ast = $this->parser->parse($code); if ($ast === null) { return null; } // Resolve names to fully qualified $traverser = new NodeTraverser(); $traverser->addVisitor(new NameResolver()); $ast = $traverser->traverse($ast); return $ast; } catch (Error $e) { $this->errors[] = [ 'file' => $filePath, 'message' => $e->getMessage(), 'line' => $e->getStartLine(), ]; return null; } } /** * Parse a Blade template */ public function parseBlade(string $code, string $filePath): array { $result = [ 'raw_outputs' => [], // {!! $var !!} 'escaped_outputs' => [], // {{ $var }} 'php_blocks' => [], // @php ... @endphp 'includes' => [], // @include, @extends, @component 'forms' => [], //