From dc88477edea7b4e2320332dc39ea1383c75bff28 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 10 Dec 2025 13:54:46 -0800 Subject: [PATCH] Fixes for compat with phpBB4 --- composer.json | 10 +++++----- src/Command/ValidateCommand.php | 5 ++--- src/Events/recursive_event_filter_iterator.php | 4 ++-- src/Files/Type/RoutingFile.php | 2 +- src/Files/Type/ServiceFile.php | 2 +- src/Files/Type/YmlFile.php | 4 ++-- src/Tests/Tests/epv_test_validate_languages.php | 5 ++++- src/Tests/Tests/epv_test_validate_php_functions.php | 11 +++++++---- src/Tests/Tests/epv_test_validate_revert_schema.php | 5 ++++- 9 files changed, 28 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 6561ed9..48e3411 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ "require": { "php": ">=7.2", "ext-json": "*", - "symfony/yaml": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/finder": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/process": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "nikic/php-parser": "^4.0", + "symfony/yaml": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/finder": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/process": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "nikic/php-parser": "^4.0 || ^5.0", "gitonomy/gitlib": "^1.3.0", "sensiolabs/ansi-to-html": "~1.1", "composer/composer": "^1.5 || ^2.0" diff --git a/src/Command/ValidateCommand.php b/src/Command/ValidateCommand.php index e3417af..04af2a0 100644 --- a/src/Command/ValidateCommand.php +++ b/src/Command/ValidateCommand.php @@ -14,7 +14,6 @@ use Phpbb\Epv\Tests\Exception\TestException; use Phpbb\Epv\Tests\TestStartup; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -23,7 +22,7 @@ class ValidateCommand extends Command { - protected function configure() + protected function configure(): void { $this ->setName('run') @@ -37,7 +36,7 @@ protected function configure() ->addOption('debug', null, InputOption::VALUE_NONE, "Run in debug"); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $dir = $input->getOption("dir"); $git = $input->getOption('git'); diff --git a/src/Events/recursive_event_filter_iterator.php b/src/Events/recursive_event_filter_iterator.php index 825ee8c..a45a49a 100644 --- a/src/Events/recursive_event_filter_iterator.php +++ b/src/Events/recursive_event_filter_iterator.php @@ -36,7 +36,7 @@ public function __construct(\RecursiveIterator $iterator, $root_path) * * @return recursive_event_filter_iterator */ - public function getChildren() + public function getChildren(): recursive_event_filter_iterator { return new self($this->getInnerIterator()->getChildren(), $this->root_path); } @@ -44,7 +44,7 @@ public function getChildren() /** * {@inheritDoc} */ - public function accept() + public function accept(): bool { $relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $this->current()); $filename = $this->current()->getFilename(); diff --git a/src/Files/Type/RoutingFile.php b/src/Files/Type/RoutingFile.php index be4754b..ac66fa6 100644 --- a/src/Files/Type/RoutingFile.php +++ b/src/Files/Type/RoutingFile.php @@ -17,7 +17,7 @@ class RoutingFile extends YmlFile implements RoutingFileInterface * Get the file type for the specific file. * @return int */ - function getFileType() + function getFileType(): int { return Type::TYPE_YML | Type::TYPE_ROUTING; } diff --git a/src/Files/Type/ServiceFile.php b/src/Files/Type/ServiceFile.php index e315e57..a794e4c 100644 --- a/src/Files/Type/ServiceFile.php +++ b/src/Files/Type/ServiceFile.php @@ -17,7 +17,7 @@ class ServiceFile extends YmlFile implements ServiceFileInterface * Get the file type for the specific file. * @return int */ - function getFileType() + function getFileType(): int { return Type::TYPE_YML | Type::TYPE_SERVICE; } diff --git a/src/Files/Type/YmlFile.php b/src/Files/Type/YmlFile.php index 43aca37..c2b342e 100644 --- a/src/Files/Type/YmlFile.php +++ b/src/Files/Type/YmlFile.php @@ -77,7 +77,7 @@ public function __construct($debug, $filename, $rundir) * * @return array */ - public function getYaml() + public function getYaml(): array { return $this->yamlFile; } @@ -86,7 +86,7 @@ public function getYaml() * Get the file type for the specific file. * @return int */ - function getFileType() + function getFileType(): int { return Type::TYPE_YML; } diff --git a/src/Tests/Tests/epv_test_validate_languages.php b/src/Tests/Tests/epv_test_validate_languages.php index 07a3d9d..6c83f5a 100644 --- a/src/Tests/Tests/epv_test_validate_languages.php +++ b/src/Tests/Tests/epv_test_validate_languages.php @@ -49,7 +49,10 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac parent::__construct($debug, $output, $basedir, $namespace, $titania, $opendir); $this->directory = true; - $this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7); + $factory = new ParserFactory(); + $this->parser = method_exists($factory, 'createForNewestSupportedVersion') + ? $factory->createForNewestSupportedVersion() + : $factory->create(ParserFactory::PREFER_PHP7); $this->visitor = new ArrayKeyVisitor; $this->traverser = new NodeTraverser; $this->traverser->addVisitor($this->visitor); diff --git a/src/Tests/Tests/epv_test_validate_php_functions.php b/src/Tests/Tests/epv_test_validate_php_functions.php index 1bc0913..27fec1b 100644 --- a/src/Tests/Tests/epv_test_validate_php_functions.php +++ b/src/Tests/Tests/epv_test_validate_php_functions.php @@ -113,7 +113,10 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac parent::__construct($debug, $output, $basedir, $namespace, $titania, $opendir); $this->fileTypeFull = Type::TYPE_PHP; - $this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7); + $factory = new ParserFactory(); + $this->parser = method_exists($factory, 'createForNewestSupportedVersion') + ? $factory->createForNewestSupportedVersion() + : $factory->create(ParserFactory::PREFER_PHP7); } /** @@ -335,7 +338,7 @@ private function checkInDefined(If_ $node) if ($cond instanceof BooleanNot && $cond->expr instanceof FuncCall - && $cond->expr->name->getFirst() === 'defined' + && (method_exists($cond->expr->name, 'getFirst') ? $cond->expr->name->getFirst() : $cond->expr->name->toString()) === 'defined' && $cond->expr->args[0]->value->value === 'IN_PHPBB' ) { @@ -375,7 +378,7 @@ private function validateFunctionNames(Node $node) } else if (isset($node->expr) && $node->expr instanceof FuncCall && $node->expr->name instanceof Name) { - $name = $node->expr->name->getFirst(); + $name = method_exists($node->expr->name, 'getFirst') ? $node->expr->name->getFirst() : $node->expr->name->toString(); } if ($name !== null) @@ -475,7 +478,7 @@ private function getMethodName(Node $node) } else if ($node->name instanceof Node\Name) { - return $node->name->getFirst(); + return method_exists($node->name, 'getFirst') ? $node->name->getFirst() : $node->name->toString(); } else { diff --git a/src/Tests/Tests/epv_test_validate_revert_schema.php b/src/Tests/Tests/epv_test_validate_revert_schema.php index bf9a5bf..461267b 100644 --- a/src/Tests/Tests/epv_test_validate_revert_schema.php +++ b/src/Tests/Tests/epv_test_validate_revert_schema.php @@ -43,7 +43,10 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac parent::__construct($debug, $output, $basedir, $namespace, $titania, $opendir); $this->fileTypeFull = Type::TYPE_MIGRATION; - $this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7); + $factory = new ParserFactory(); + $this->parser = method_exists($factory, 'createForNewestSupportedVersion') + ? $factory->createForNewestSupportedVersion() + : $factory->create(ParserFactory::PREFER_PHP7); } /**