{ if (!
class_exists(ParserFactory::
class)) { throw new \
LogicException(sprintf('You cannot use "%s" as the "nikic/php-parser" package is not installed. Try running "composer require nikic/php-parser".',
static::
class));
} $this->parser =
(new ParserFactory())->
create(ParserFactory::PREFER_PHP7
);
} public function extract(iterable|string
$resource, MessageCatalogue
$catalogue): void
{ foreach ($this->
extractFiles($resource) as $file) { $traverser =
new NodeTraverser();
/** @var AbstractVisitor&NodeVisitor $visitor */
foreach ($this->visitors
as $visitor) { $visitor->
initialize($catalogue,
$file,
$this->prefix
);
$traverser->
addVisitor($visitor);
} $nodes =
$this->parser->
parse(file_get_contents($file));
$traverser->
traverse($nodes);
} }