Skip to content

Commit 8d689ed

Browse files
authored
Support Symfony Console 7.x
2 parents 17e105a + 8cbf13f commit 8d689ed

File tree

8 files changed

+24
-14
lines changed

8 files changed

+24
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"require": {
1212
"php": ">=8.0.2",
13-
"symfony/console": "~6.3"
13+
"symfony/console": "~6.3 || ^7.0"
1414
},
1515
"require-dev": {
1616
"phpunit/phpunit": "^9.5",

src/CompletionCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class CompletionCommand extends SymfonyCommand
1515
*/
1616
protected $handler;
1717

18+
1819
protected function configure()
1920
{
2021
$this
@@ -51,7 +52,7 @@ public function getNativeDefinition(): InputDefinition
5152
* Any global options defined by user-code are meaningless to this command.
5253
* Options outside of the core defaults are ignored to avoid name and shortcut conflicts.
5354
*/
54-
public function mergeApplicationDefinition($mergeArgs = true): void
55+
public function mergeApplicationDefinition(bool $mergeArgs = true): void
5556
{
5657
// Get current application options
5758
$appDefinition = $this->getApplication()->getDefinition();
@@ -91,7 +92,7 @@ protected function filterApplicationOptions(array $appOptions)
9192
});
9293
}
9394

94-
protected function execute(InputInterface $input, OutputInterface $output)
95+
protected function execute(InputInterface $input, OutputInterface $output): int
9596
{
9697
$this->handler = new CompletionHandler($this->getApplication());
9798
$handler = $this->handler;
@@ -132,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
132133
$output->write($results, true);
133134
}
134135

135-
return 0;
136+
return (int) SymfonyCommand::SUCCESS;
136137
}
137138

138139
/**

tests/Stecman/Component/Symfony/Console/BashCompletion/Common/CompletionHandlerTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static function setUpBeforeClass(): void
3030

3131
protected function setUp(): void
3232
{
33+
parent::setUp();
3334
$this->application = new Application('Base application');
3435
$this->application->addCommands(array(
3536
new \CompletionAwareCommand(),

tests/Stecman/Component/Symfony/Console/BashCompletion/CompletionHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function testCompletionAwareCommand($commandLine, array $suggestions)
143143
$this->assertSame($suggestions, $this->getTerms($handler->runCompletion()));
144144
}
145145

146-
public function completionAwareCommandDataProvider()
146+
public static function completionAwareCommandDataProvider(): array
147147
{
148148
return array(
149149
'not complete aware command' => array('app wave --vigorous ', array()),
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22

3+
use Symfony\Component\Console\Command\Command;
34

4-
class HiddenCommand extends \Symfony\Component\Console\Command\Command
5+
class HiddenCommand extends Command
56
{
67
protected function configure()
78
{
89
$this->setName('internals')
910
->setHidden(true);
1011
}
11-
}
12+
}

tests/Stecman/Component/Symfony/Console/BashCompletion/Fixtures/TestBasicCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22

3+
use Symfony\Component\Console\Command\Command;
4+
use Symfony\Component\Console\Input\InputOption;
5+
use Symfony\Component\Console\Input\InputArgument;
36

4-
class TestBasicCommand extends \Symfony\Component\Console\Command\Command
7+
class TestBasicCommand extends Command
58
{
69
protected function configure()
710
{
@@ -16,11 +19,11 @@ protected function configure()
1619
->addOption(
1720
'style',
1821
's',
19-
\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED
22+
InputOption::VALUE_REQUIRED
2023
)
2124
->addArgument(
2225
'target',
23-
\Symfony\Component\Console\Input\InputArgument::REQUIRED
26+
InputArgument::REQUIRED
2427
);
2528
}
2629
}

tests/Stecman/Component/Symfony/Console/BashCompletion/Fixtures/TestSymfonyStyleCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

3-
class TestSymfonyStyleCommand extends \Symfony\Component\Console\Command\Command
3+
use Symfony\Component\Console\Command\Command;
4+
use Symfony\Component\Console\Input\InputOption;
5+
6+
class TestSymfonyStyleCommand extends Command
47
{
58
protected function configure()
69
{
@@ -16,12 +19,12 @@ protected function configure()
1619
->addOption(
1720
'style',
1821
's',
19-
\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED
22+
InputOption::VALUE_REQUIRED
2023
)
2124
->addOption(
2225
'target',
2326
't',
24-
\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED
27+
InputOption::VALUE_REQUIRED
2528
);
2629
}
2730
}

tests/Stecman/Component/Symfony/Console/BashCompletion/HookFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class HookFactoryTest extends TestCase
1414

1515
protected function setUp(): void
1616
{
17+
parent::setUp();
1718
$this->factory = new HookFactory();
1819
}
1920

@@ -43,7 +44,7 @@ public function testZshSyntax($programPath, $programName, $multiple)
4344
}
4445
}
4546

46-
public function generateHookDataProvider()
47+
public static function generateHookDataProvider()
4748
{
4849
return array(
4950
array('/path/to/myprogram', null, false),

0 commit comments

Comments
 (0)