Skip to content

Commit c5a6c3f

Browse files
committed
minor #21603 [Console] Deprecate the add() method (javiereguiluz)
This PR was merged into the 7.4 branch. Discussion ---------- [Console] Deprecate the add() method Related to #21602. It fixes the second part of #21074 (comment) Commits ------- a7de753 [Console] Deprecate the add() method
2 parents 7000d14 + a7de753 commit c5a6c3f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

components/console.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ First, you need to create a PHP script to define the console application::
4343
$application->run();
4444

4545
Then, you can register the commands using
46-
:method:`Symfony\\Component\\Console\\Application::add`::
46+
:method:`Symfony\\Component\\Console\\Application::addCommand`::
4747

4848
// ...
49-
$application->add(new GenerateAdminCommand());
49+
$application->addCommand(new GenerateAdminCommand());
50+
51+
.. versionadded:: 7.4
52+
53+
The ``addCommand()`` method was introduced in Symfony 7.4. In earlier
54+
versions, you had to use the ``add()`` method of the same class.
5055

5156
You can also register inline commands and define their behavior thanks to the
5257
``Command::setCode()`` method::

components/console/single_command_tool.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You can still register a command as usual::
3636
$application = new Application('echo', '1.0.0');
3737
$command = new DefaultCommand();
3838

39-
$application->add($command);
39+
$application->addCommand($command);
4040

4141
$application->setDefaultCommand($command->getName(), true);
4242
$application->run();

0 commit comments

Comments
 (0)