Skip to content

[Console] pass command name automatically if required by the application #8626

Closed
wants to merge 1 commit into from

3 participants

@xabbuh
Symfony member
xabbuh commented Aug 1, 2013
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #8625
License MIT
Doc PR
@stloyd stloyd commented on an outdated diff Aug 1, 2013
src/Symfony/Component/Console/Tester/CommandTester.php
@@ -52,6 +52,16 @@ public function __construct(Command $command)
*/
public function execute(array $input, array $options = array())
{
+ // set the command name automatically if the application requires
+ // this argument and no command name was passed
+ $application = $this->command->getApplication();
+ if ($application != null) {
@stloyd
stloyd added a note Aug 1, 2013

Should be null !== $application to match CS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stloyd stloyd commented on an outdated diff Aug 1, 2013
src/Symfony/Component/Console/Tester/CommandTester.php
@@ -52,6 +52,16 @@ public function __construct(Command $command)
*/
public function execute(array $input, array $options = array())
{
+ // set the command name automatically if the application requires
+ // this argument and no command name was passed
+ $application = $this->command->getApplication();
+ if ($application != null) {
+ $definition = $application->getDefinition();
+ if ($definition->hasArgument("command") && !isset($input['command'])) {
@stloyd
stloyd added a note Aug 1, 2013

Please use ' not ".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@stloyd stloyd commented on an outdated diff Aug 1, 2013
src/Symfony/Component/Console/Tester/CommandTester.php
@@ -52,6 +52,16 @@ public function __construct(Command $command)
*/
public function execute(array $input, array $options = array())
{
+ // set the command name automatically if the application requires
+ // this argument and no command name was passed
+ $application = $this->command->getApplication();
@stloyd
stloyd added a note Aug 1, 2013

Shouldn't you do first the check:

if (!isset($input['command']))) {
   // Your patch here
}

To avoid unnecessary calls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@xabbuh
Symfony member
xabbuh commented Aug 2, 2013

Thanks for your feedback, @stloyd. I modified the PR accordingly.

@stof stof commented on an outdated diff Aug 9, 2013
src/Symfony/Component/Console/Tester/CommandTester.php
@@ -52,6 +52,18 @@ public function __construct(Command $command)
*/
public function execute(array $input, array $options = array())
{
+ // set the command name automatically if the application requires
+ // this argument and no command name was passed
+ if (!isset($input['command'])) {
+ $application = $this->command->getApplication();
+ if ($application !== null) {
@stof
Symfony member
stof added a note Aug 9, 2013

it should be null !== $application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabpot fabpot added a commit that closed this pull request Sep 30, 2013
@fabpot fabpot feature#8626 [Console] pass command name automatically if required by…
… the application (xabbuh)

This PR was submitted for the 2.2 branch but it was merged into the master branch instead (closes #8626).

Discussion
----------

[Console] pass command name automatically if required by the application

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8625
| License       | MIT
| Doc PR        |

Commits
-------

50c8050 [Console] pass command name automatically if required by the application
ad7be73
@fabpot fabpot closed this in ad7be73 Sep 30, 2013
@xabbuh xabbuh deleted the xabbuh:issue-8625 branch Oct 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.