Skip to content

Commit 5a069b2

Browse files
committed
Only check classes in php7
1 parent 2b49942 commit 5a069b2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Validator/Php/PhpClassExistsValidator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ final class PhpClassExistsValidator implements ValidatorInterface
2626
/** @var PhpCodeEnsurerInterface */
2727
private $codeEnsurer;
2828

29+
/** @var false|string */
30+
private $phpVersion;
31+
2932
public function __construct(
3033
callable $classExists,
3134
?Parser $parser = null,
@@ -34,11 +37,19 @@ public function __construct(
3437
$this->parser = $parser ?? (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
3538
$this->classExists = $classExists;
3639
$this->codeEnsurer = $codeEnsurer ?? new PhpCodeEnsurer();
40+
41+
$phpversion = phpversion();
42+
Assert::string($phpversion, 'Could not get php version.');
43+
$this->phpVersion = $phpversion;
3744
}
3845

3946
/** {@inheritDoc} */
4047
public function validate(Block $block): array
4148
{
49+
if ($this->phpVersion === "8") {
50+
return [];
51+
}
52+
4253
$phpCode = $this->codeEnsurer->getPHPCode($block->getContent());
4354
try {
4455
$statements = $this->parser->parse($phpCode);

0 commit comments

Comments
 (0)