public function __construct(Parser $parser = null)
{
$className = '\\PhpParser\\ParserFactory';
if (class_exists($className)) {
$this->parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7);
} else {
$this->parser = $parser ?: new \PhpParser\Parser(new \PhpParser\Lexer());
}
}