PHP 8.2.31
Preview: NamedSimplePhpParser.php Size: 898 B
//opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/rector/rector-symfony/src/PhpParser/NamedSimplePhpParser.php

<?php

declare (strict_types=1);
namespace Rector\Symfony\PhpParser;

use PhpParser\Node\Stmt;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\NameResolver;
use PhpParser\Parser;
use PhpParser\ParserFactory;
final class NamedSimplePhpParser
{
    /**
     * @readonly
     * @var \PhpParser\Parser
     */
    private $phpParser;
    public function __construct()
    {
        $parserFactory = new ParserFactory();
        $this->phpParser = $parserFactory->create(ParserFactory::ONLY_PHP7);
    }
    /**
     * @return Stmt[]
     */
    public function parseString(string $content) : array
    {
        $stmts = $this->phpParser->parse($content);
        if ($stmts === null) {
            return [];
        }
        $nodeTraverser = new NodeTraverser();
        $nodeTraverser->addVisitor(new NameResolver());
        $nodeTraverser->traverse($stmts);
        return $stmts;
    }
}

Directory Contents

Dirs: 0 × Files: 1

Name Size Perms Modified Actions
898 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).