Skip to content

Commit bb2903d

Browse files
authored
Merge pull request #41 from johnnynotsolucky/chore/support-symfony-8
Fix deprecated method usage
2 parents 687ffeb + 92b1583 commit bb2903d

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"aws/aws-sdk-php": "^3.319",
2222
"psy/psysh": "^0.12.0",
2323
"revolt/event-loop": "^1.0",
24-
"symfony/console": "^5.2 || ^6.2 || ^7",
25-
"symfony/filesystem": "^5.2 || ^6.2 || ^7",
26-
"symfony/http-client": "^5.2 || ^6.2 || ^7",
27-
"symfony/process": "^5.2 || ^6.2 || ^7",
28-
"symfony/yaml": "^5.2 || ^6.2 || ^7"
24+
"symfony/console": "^5.2 || ^6.2 || ^7 || ^8",
25+
"symfony/filesystem": "^5.2 || ^6.2 || ^7 || ^8",
26+
"symfony/http-client": "^5.2 || ^6.2 || ^7 || ^8",
27+
"symfony/process": "^5.2 || ^6.2 || ^7 || ^8",
28+
"symfony/yaml": "^5.2 || ^6.2 || ^7 || ^8"
2929
},
3030
"require-dev": {
3131
"phpstan/phpstan": "^2"

src/Application.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Bref\Cli\Cli\Styles;
88
use ErrorException;
99
use Exception;
10+
use Symfony\Component\Console\Command\Command;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213
use Symfony\Component\HttpClient\Exception\ClientException;
@@ -20,15 +21,25 @@ public function __construct()
2021

2122
$this->turnWarningsIntoExceptions();
2223

23-
$this->add(new Commands\Login);
24-
$this->add(new Commands\Deploy);
25-
$this->add(new Commands\Info);
26-
$this->add(new Commands\Remove);
27-
$this->add(new Commands\Command);
28-
$this->add(new Commands\Connect);
29-
$this->add(new Commands\PreviousLogs);
30-
$this->add(new Commands\Cloud);
31-
$this->add(new Commands\Tinker);
24+
$this->safeAddCommand(new Commands\Login);
25+
$this->safeAddCommand(new Commands\Deploy);
26+
$this->safeAddCommand(new Commands\Info);
27+
$this->safeAddCommand(new Commands\Remove);
28+
$this->safeAddCommand(new Commands\Command);
29+
$this->safeAddCommand(new Commands\Connect);
30+
$this->safeAddCommand(new Commands\PreviousLogs);
31+
$this->safeAddCommand(new Commands\Cloud);
32+
$this->safeAddCommand(new Commands\Tinker);
33+
}
34+
35+
public function safeAddCommand(Command $command): ?Command
36+
{
37+
if (method_exists($this, 'addCommand')) {
38+
// addCommand() exists since 7.4 and add() has been deprecated.
39+
return $this->addCommand($command);
40+
}
41+
42+
return $this->add($command);
3243
}
3344

3445
public function doRun(InputInterface $input, OutputInterface $output): int

0 commit comments

Comments
 (0)