Skip to content

Commit a0b405f

Browse files
committed
Merge branch 'asika32764-symfony6'
2 parents 5da449d + 582d102 commit a0b405f

File tree

10 files changed

+28
-34
lines changed

10 files changed

+28
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ vendor
33
/build/
44
phpunit.xml
55
/composer.lock
6+
/.phpunit.result.cache

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ If you don't need any custom completion behaviour, you can simply add the comple
6565

6666
Note: The type of shell (ZSH/BASH) is automatically detected using the `SHELL` environment variable at run time. In some circumstances, you may need to explicitly specify the shell type with the `--shell-type` option.
6767

68+
The current version supports Symfony 6 and PHP 8.x only, due to backwards compatibility breaks in Symfony 6. For older versions of Symfony and PHP, use [version 0.11.0](https://github.com/stecman/symfony-console-completion/releases/tag/0.11.0).
69+
6870

6971
## How it works
7072

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=5.3.2",
13-
"symfony/console": "~2.3 || ~3.0 || ~4.0 || ~5.0"
12+
"php": ">=8.0.2",
13+
"symfony/console": "~6.0"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "~4.8.36 || ~5.7 || ~6.4"
16+
"phpunit/phpunit": "^9.5",
17+
"dms/phpunit-arraysubset-asserts": "^0.4.0"
1718
},
1819
"autoload": {
1920
"psr-4": {

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="tests/bootstrap.php"
1312
>
1413
<testsuites>

src/CompletionCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@ protected function configure()
3434
);
3535

3636
// Hide this command from listing if supported
37-
// Command::setHidden() was not available before Symfony 3.2.0
38-
if (method_exists($this, 'setHidden')) {
39-
$this->setHidden(true);
40-
}
37+
$this->setHidden(true);
4138
}
4239

4340
/**
4441
* {@inheritdoc}
4542
*/
46-
public function getNativeDefinition()
43+
public function getNativeDefinition(): InputDefinition
4744
{
4845
return $this->createDefinition();
4946
}

src/CompletionHandler.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -451,28 +451,15 @@ protected function getAllOptions()
451451
*/
452452
protected function getCommandNames()
453453
{
454-
// Command::Hidden isn't supported before Symfony Console 3.2.0
455-
// We don't complete hidden command names as these are intended to be private
456-
if (method_exists('\Symfony\Component\Console\Command\Command', 'isHidden')) {
457-
$commands = array();
458-
459-
foreach ($this->application->all() as $name => $command) {
460-
if (!$command->isHidden()) {
461-
$commands[] = $name;
462-
}
463-
}
464-
465-
return $commands;
466-
467-
} else {
468-
469-
// Fallback for compatibility with Symfony Console < 3.2.0
470-
// This was the behaviour prior to pull #75
471-
$commands = $this->application->all();
472-
unset($commands['_completion']);
454+
$commands = array();
473455

474-
return array_keys($commands);
456+
foreach ($this->application->all() as $name => $command) {
457+
if (!$command->isHidden()) {
458+
$commands[] = $name;
459+
}
475460
}
461+
462+
return $commands;
476463
}
477464

478465
/**

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Stecman\Component\Symfony\Console\BashCompletion\Tests\Common;
44

5+
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
56
use PHPUnit\Framework\TestCase;
67
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
78
use Stecman\Component\Symfony\Console\BashCompletion\CompletionHandler;
@@ -12,20 +13,22 @@
1213
*/
1314
abstract class CompletionHandlerTestCase extends TestCase
1415
{
16+
use ArraySubsetAsserts;
17+
1518
/**
1619
* @var Application
1720
*/
1821
protected $application;
1922

20-
public static function setUpBeforeClass()
23+
public static function setUpBeforeClass(): void
2124
{
2225
require_once __DIR__ . '/../Fixtures/CompletionAwareCommand.php';
2326
require_once __DIR__ . '/../Fixtures/HiddenCommand.php';
2427
require_once __DIR__ . '/../Fixtures/TestBasicCommand.php';
2528
require_once __DIR__ . '/../Fixtures/TestSymfonyStyleCommand.php';
2629
}
2730

28-
protected function setUp()
31+
protected function setUp(): void
2932
{
3033
$this->application = new Application('Base application');
3134
$this->application->addCommands(array(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class CompletionCommandTest extends TestCase
1616
*/
1717
public function testConflictingGlobalOptions()
1818
{
19+
$this->expectNotToPerformAssertions();
20+
1921
$app = new Application('Base application');
2022

2123
// Conflicting option shortcut

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testCompleteCommandNames()
2121
{
2222
$handler = $this->createHandler('app ');
2323
$this->assertEquals(
24-
array('help', 'list', 'completion-aware', 'wave', 'walk:north'),
24+
array('help', 'list', 'completion', 'completion-aware', 'wave', 'walk:north'),
2525
$this->getTerms($handler->runCompletion())
2626
);
2727
}
@@ -176,7 +176,7 @@ public function testHelpCommandCompletion()
176176
{
177177
$handler = $this->createHandler('app help ');
178178
$this->assertEquals(
179-
array('help', 'list', 'completion-aware', 'wave', 'walk:north'),
179+
array('help', 'list', 'completion', 'completion-aware', 'wave', 'walk:north'),
180180
$this->getTerms($handler->runCompletion())
181181
);
182182
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class HookFactoryTest extends TestCase
1212
*/
1313
protected $factory;
1414

15-
protected function setUp()
15+
protected function setUp(): void
1616
{
1717
$this->factory = new HookFactory();
1818
}
@@ -56,6 +56,8 @@ public function generateHookDataProvider()
5656

5757
public function testForMissingSemiColons()
5858
{
59+
$this->expectNotToPerformAssertions();
60+
5961
$class = new \ReflectionClass('Stecman\Component\Symfony\Console\BashCompletion\HookFactory');
6062
$properties = $class->getStaticProperties();
6163
$hooks = $properties['hooks'];

0 commit comments

Comments
 (0)