Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a095056

Browse files
committed
WIP
1 parent f3499b5 commit a095056

28 files changed

Lines changed: 40 additions & 217 deletions

src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,7 @@ public function testComplete(array $input, array $expectedSuggestions)
304304
$environment = new Environment($loader);
305305

306306
$application = new Application();
307-
$command = new DebugCommand($environment, $projectDir, [], null, null);
308-
if (method_exists($application, 'addCommand')) {
309-
$application->addCommand($command);
310-
} else {
311-
$application->add($command);
312-
}
307+
$application->addCommand(new DebugCommand($environment, $projectDir, [], null, null));
313308

314309
$tester = new CommandCompletionTester($application->find('debug:twig'));
315310
$suggestions = $tester->complete($input, 2);
@@ -344,12 +339,7 @@ private function createCommandTester(array $paths = [], array $bundleMetadata =
344339
}
345340

346341
$application = new Application();
347-
$command = new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, null);
348-
if (method_exists($application, 'addCommand')) {
349-
$application->addCommand($command);
350-
} else {
351-
$application->add($command);
352-
}
342+
$application->addCommand(new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, null));
353343
$command = $application->find('debug:twig');
354344

355345
return new CommandTester($command);

src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,7 @@ private function createCommand(): Command
179179
$command = new LintCommand($environment);
180180

181181
$application = new Application();
182-
if (method_exists($application, 'addCommand')) {
183-
$application->addCommand($command);
184-
} else {
185-
$application->add($command);
186-
}
182+
$application->addCommand($command);
187183

188184
return $application->find('lint:twig');
189185
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
},
5959
"conflict": {
6060
"phpdocumentor/reflection-docblock": "<3.2.2",
61-
"phpdocumentor/type-resolver": "<1.4.0"
61+
"phpdocumentor/type-resolver": "<1.4.0",
62+
"symfony/console": "<7.4"
6263
},
6364
"autoload": {
6465
"psr-4": { "Symfony\\Bridge\\Twig\\": "" },

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,10 @@ public function getLongVersion(): string
159159
return parent::getLongVersion().\sprintf(' (env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
160160
}
161161

162-
/**
163-
* @deprecated since Symfony 7.4, use Application::addCommand() instead
164-
*/
165-
public function add(Command $command): ?Command
166-
{
167-
trigger_deprecation('symfony/framework-bundle', '7.4', 'The "%s()" method is deprecated and will be removed in Symfony 8.0, use "%s::addCommand()" instead.', __METHOD__, self::class);
168-
169-
return $this->addCommand($command);
170-
}
171-
172162
public function addCommand(callable|Command $command): ?Command
173163
{
174164
$this->registerCommands();
175165

176-
if (!method_exists(BaseApplication::class, 'addCommand')) {
177-
if (!$command instanceof Command) {
178-
throw new \LogicException('Using callables as commands requires symfony/console 7.4 or higher.');
179-
}
180-
181-
return parent::add($command);
182-
}
183-
184166
return parent::addCommand($command);
185167
}
186168

src/Symfony/Bundle/FrameworkBundle/Tests/Command/WorkflowDumpCommandTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ class WorkflowDumpCommandTest extends TestCase
2525
public function testComplete(array $input, array $expectedSuggestions)
2626
{
2727
$application = new Application();
28-
$command = new WorkflowDumpCommand(new ServiceLocator([]));
29-
if (method_exists($application, 'addCommand')) {
30-
$application->addCommand($command);
31-
} else {
32-
$application->add($command);
33-
}
28+
$application->addCommand(new WorkflowDumpCommand(new ServiceLocator([])));
3429

3530
$tester = new CommandCompletionTester($application->find('workflow:dump'));
3631
$suggestions = $tester->complete($input, 2);

src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,7 @@ private function createCommandTester($application = null): CommandTester
5959
{
6060
if (!$application) {
6161
$application = new BaseApplication();
62-
$command = new XliffLintCommand();
63-
if (method_exists($application, 'addCommand')) {
64-
$application->addCommand($command);
65-
} else {
66-
$application->add($command);
67-
}
62+
$application->addCommand(new XliffLintCommand());
6863
}
6964

7065
$command = $application->find('lint:xliff');

src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ private function createCommandTester($application = null): CommandTester
107107
{
108108
if (!$application) {
109109
$application = new BaseApplication();
110-
$command = new YamlLintCommand();
111-
if (method_exists($application, 'addCommand')) {
112-
$application->addCommand($command);
113-
} else {
114-
$application->add($command);
115-
}
110+
$application->addCommand(new YamlLintCommand());
116111
}
117112

118113
$command = $application->find('lint:yaml');

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"doctrine/persistence": "<1.3",
8282
"phpdocumentor/reflection-docblock": "<3.2.2",
8383
"phpdocumentor/type-resolver": "<1.4.0",
84+
"symfony/console": "<7.4",
8485
"symfony/security-csrf": "<7.4",
8586
"symfony/serializer": "<7.4",
8687
"symfony/translation": "<7.4",

src/Symfony/Component/Console/Application.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,6 @@ public function addCommands(array $commands): void
531531
}
532532
}
533533

534-
/**
535-
* @deprecated since Symfony 7.4, use Application::addCommand() instead
536-
*/
537-
public function add(Command $command): ?Command
538-
{
539-
trigger_deprecation('symfony/console', '7.4', 'The "%s()" method is deprecated and will be removed in Symfony 8.0, use "%s::addCommand()" instead.', __METHOD__, self::class);
540-
541-
return $this->addCommand($command);
542-
}
543-
544534
/**
545535
* Adds a command object.
546536
*

src/Symfony/Component/Console/Command/Command.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ public function __construct(?string $name = null)
6565

6666
$attribute = ((new \ReflectionClass(static::class))->getAttributes(AsCommand::class)[0] ?? null)?->newInstance();
6767

68-
if (null === $name) {
69-
$name = $attribute?->name;
70-
}
71-
72-
if (null !== $name) {
68+
if (null !== $name ??= $attribute?->name) {
7369
$aliases = explode('|', $name);
7470

7571
if ('' === $name = array_shift($aliases)) {

0 commit comments

Comments
 (0)