From 5a069b2b8ea8e521ce98f19aaa7efebbf94c27a1 Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Wed, 12 Jan 2022 00:11:24 +0100 Subject: [PATCH] Only check classes in php7 --- src/Validator/Php/PhpClassExistsValidator.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Validator/Php/PhpClassExistsValidator.php b/src/Validator/Php/PhpClassExistsValidator.php index af1f068..477cdd6 100644 --- a/src/Validator/Php/PhpClassExistsValidator.php +++ b/src/Validator/Php/PhpClassExistsValidator.php @@ -26,6 +26,9 @@ final class PhpClassExistsValidator implements ValidatorInterface /** @var PhpCodeEnsurerInterface */ private $codeEnsurer; + /** @var false|string */ + private $phpVersion; + public function __construct( callable $classExists, ?Parser $parser = null, @@ -34,11 +37,19 @@ public function __construct( $this->parser = $parser ?? (new ParserFactory)->create(ParserFactory::PREFER_PHP7); $this->classExists = $classExists; $this->codeEnsurer = $codeEnsurer ?? new PhpCodeEnsurer(); + + $phpversion = phpversion(); + Assert::string($phpversion, 'Could not get php version.'); + $this->phpVersion = $phpversion; } /** {@inheritDoc} */ public function validate(Block $block): array { + if ($this->phpVersion === "8") { + return []; + } + $phpCode = $this->codeEnsurer->getPHPCode($block->getContent()); try { $statements = $this->parser->parse($phpCode);