Skip to content

Commit dc88477

Browse files
committed
Fixes for compat with phpBB4
1 parent a0f3290 commit dc88477

File tree

9 files changed

+28
-20
lines changed

9 files changed

+28
-20
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"require": {
1313
"php": ">=7.2",
1414
"ext-json": "*",
15-
"symfony/yaml": "^3.0 || ^4.0 || ^5.0 || ^6.0",
16-
"symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0",
17-
"symfony/finder": "^3.0 || ^4.0 || ^5.0 || ^6.0",
18-
"symfony/process": "^3.0 || ^4.0 || ^5.0 || ^6.0",
19-
"nikic/php-parser": "^4.0",
15+
"symfony/yaml": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
16+
"symfony/console": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
17+
"symfony/finder": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
18+
"symfony/process": "^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
19+
"nikic/php-parser": "^4.0 || ^5.0",
2020
"gitonomy/gitlib": "^1.3.0",
2121
"sensiolabs/ansi-to-html": "~1.1",
2222
"composer/composer": "^1.5 || ^2.0"

src/Command/ValidateCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Phpbb\Epv\Tests\Exception\TestException;
1515
use Phpbb\Epv\Tests\TestStartup;
1616
use Symfony\Component\Console\Command\Command;
17-
use Symfony\Component\Console\Input\InputArgument;
1817
use Symfony\Component\Console\Input\InputInterface;
1918
use Symfony\Component\Console\Input\InputOption;
2019
use Symfony\Component\Console\Output\OutputInterface;
@@ -23,7 +22,7 @@
2322
class ValidateCommand extends Command
2423
{
2524

26-
protected function configure()
25+
protected function configure(): void
2726
{
2827
$this
2928
->setName('run')
@@ -37,7 +36,7 @@ protected function configure()
3736
->addOption('debug', null, InputOption::VALUE_NONE, "Run in debug");
3837
}
3938

40-
protected function execute(InputInterface $input, OutputInterface $output)
39+
protected function execute(InputInterface $input, OutputInterface $output): int
4140
{
4241
$dir = $input->getOption("dir");
4342
$git = $input->getOption('git');

src/Events/recursive_event_filter_iterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ public function __construct(\RecursiveIterator $iterator, $root_path)
3636
*
3737
* @return recursive_event_filter_iterator
3838
*/
39-
public function getChildren()
39+
public function getChildren(): recursive_event_filter_iterator
4040
{
4141
return new self($this->getInnerIterator()->getChildren(), $this->root_path);
4242
}
4343

4444
/**
4545
* {@inheritDoc}
4646
*/
47-
public function accept()
47+
public function accept(): bool
4848
{
4949
$relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $this->current());
5050
$filename = $this->current()->getFilename();

src/Files/Type/RoutingFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RoutingFile extends YmlFile implements RoutingFileInterface
1717
* Get the file type for the specific file.
1818
* @return int
1919
*/
20-
function getFileType()
20+
function getFileType(): int
2121
{
2222
return Type::TYPE_YML | Type::TYPE_ROUTING;
2323
}

src/Files/Type/ServiceFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ServiceFile extends YmlFile implements ServiceFileInterface
1717
* Get the file type for the specific file.
1818
* @return int
1919
*/
20-
function getFileType()
20+
function getFileType(): int
2121
{
2222
return Type::TYPE_YML | Type::TYPE_SERVICE;
2323
}

src/Files/Type/YmlFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct($debug, $filename, $rundir)
7777
*
7878
* @return array
7979
*/
80-
public function getYaml()
80+
public function getYaml(): array
8181
{
8282
return $this->yamlFile;
8383
}
@@ -86,7 +86,7 @@ public function getYaml()
8686
* Get the file type for the specific file.
8787
* @return int
8888
*/
89-
function getFileType()
89+
function getFileType(): int
9090
{
9191
return Type::TYPE_YML;
9292
}

src/Tests/Tests/epv_test_validate_languages.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
4949
parent::__construct($debug, $output, $basedir, $namespace, $titania, $opendir);
5050

5151
$this->directory = true;
52-
$this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
52+
$factory = new ParserFactory();
53+
$this->parser = method_exists($factory, 'createForNewestSupportedVersion')
54+
? $factory->createForNewestSupportedVersion()
55+
: $factory->create(ParserFactory::PREFER_PHP7);
5356
$this->visitor = new ArrayKeyVisitor;
5457
$this->traverser = new NodeTraverser;
5558
$this->traverser->addVisitor($this->visitor);

src/Tests/Tests/epv_test_validate_php_functions.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
113113
parent::__construct($debug, $output, $basedir, $namespace, $titania, $opendir);
114114

115115
$this->fileTypeFull = Type::TYPE_PHP;
116-
$this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
116+
$factory = new ParserFactory();
117+
$this->parser = method_exists($factory, 'createForNewestSupportedVersion')
118+
? $factory->createForNewestSupportedVersion()
119+
: $factory->create(ParserFactory::PREFER_PHP7);
117120
}
118121

119122
/**
@@ -335,7 +338,7 @@ private function checkInDefined(If_ $node)
335338

336339
if ($cond instanceof BooleanNot
337340
&& $cond->expr instanceof FuncCall
338-
&& $cond->expr->name->getFirst() === 'defined'
341+
&& (method_exists($cond->expr->name, 'getFirst') ? $cond->expr->name->getFirst() : $cond->expr->name->toString()) === 'defined'
339342
&& $cond->expr->args[0]->value->value === 'IN_PHPBB'
340343
)
341344
{
@@ -375,7 +378,7 @@ private function validateFunctionNames(Node $node)
375378
}
376379
else if (isset($node->expr) && $node->expr instanceof FuncCall && $node->expr->name instanceof Name)
377380
{
378-
$name = $node->expr->name->getFirst();
381+
$name = method_exists($node->expr->name, 'getFirst') ? $node->expr->name->getFirst() : $node->expr->name->toString();
379382
}
380383

381384
if ($name !== null)
@@ -475,7 +478,7 @@ private function getMethodName(Node $node)
475478
}
476479
else if ($node->name instanceof Node\Name)
477480
{
478-
return $node->name->getFirst();
481+
return method_exists($node->name, 'getFirst') ? $node->name->getFirst() : $node->name->toString();
479482
}
480483
else
481484
{

src/Tests/Tests/epv_test_validate_revert_schema.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ public function __construct($debug, OutputInterface $output, $basedir, $namespac
4343
parent::__construct($debug, $output, $basedir, $namespace, $titania, $opendir);
4444

4545
$this->fileTypeFull = Type::TYPE_MIGRATION;
46-
$this->parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
46+
$factory = new ParserFactory();
47+
$this->parser = method_exists($factory, 'createForNewestSupportedVersion')
48+
? $factory->createForNewestSupportedVersion()
49+
: $factory->create(ParserFactory::PREFER_PHP7);
4750
}
4851

4952
/**

0 commit comments

Comments
 (0)