From b423ab4465bdf4f77ba0928806cd7cd702ef7c12 Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Thu, 22 Sep 2016 15:52:42 -0400 Subject: [PATCH 01/14] Add hidden field --- src/Symfony/Component/Console/Command/Command.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 0d5001bb187a..9c10355276b1 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -34,6 +34,7 @@ class Command private $processTitle; private $aliases = array(); private $definition; + private $hidden; private $help; private $description; private $ignoreValidationErrors = false; @@ -445,6 +446,16 @@ public function getName() { return $this->name; } + + public function setHidden($hiddenBool) + { + return $this->hidden = $hiddenBool; + } + + public function isHidden() + { + return $this->hidden; + } /** * Sets the description for the command. From 8d0262f832e4fbe009c658231c4ab2d33b1adc2f Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Thu, 22 Sep 2016 16:10:04 -0400 Subject: [PATCH 02/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 9c10355276b1..3a4ca9bab5fe 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -447,11 +447,24 @@ public function getName() return $this->name; } + /** + * Sets if the command should be hidden from application inspection. + * + * @param bool $hiddenBool To show this command or not + * + * @return Command The current instance + */ public function setHidden($hiddenBool) { - return $this->hidden = $hiddenBool; + $this->hidden = $hiddenBool; + return $this; } + /** + * Returns if the command should be hidden from application inspection. + * + * @return boolean If the command is hidden or not + */ public function isHidden() { return $this->hidden; From b73f494712eab6c03c1edec356a41df433112776 Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Thu, 22 Sep 2016 16:10:35 -0400 Subject: [PATCH 03/14] Update ApplicationDescription.php --- .../Component/Console/Descriptor/ApplicationDescription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index 89961b9cae7d..4c4a267fe09c 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -112,7 +112,7 @@ private function inspectApplication() /** @var Command $command */ foreach ($commands as $name => $command) { - if (!$command->getName()) { + if (!$command->getName() || $command->isHidden()) { continue; } From 1add2ad12088453c57cc47d5d59c86ef8509ef8e Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Thu, 22 Sep 2016 16:16:44 -0400 Subject: [PATCH 04/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 3a4ca9bab5fe..db3e9c5942dc 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -447,7 +447,7 @@ public function getName() return $this->name; } - /** + /** * Sets if the command should be hidden from application inspection. * * @param bool $hiddenBool To show this command or not @@ -457,13 +457,14 @@ public function getName() public function setHidden($hiddenBool) { $this->hidden = $hiddenBool; + return $this; } /** * Returns if the command should be hidden from application inspection. * - * @return boolean If the command is hidden or not + * @return bool If the command is hidden or not */ public function isHidden() { From 199319649f7a9521bbc27752c1c4bd7cd953178d Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Thu, 22 Sep 2016 16:18:11 -0400 Subject: [PATCH 05/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index db3e9c5942dc..cd79254a485a 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -446,7 +446,7 @@ public function getName() { return $this->name; } - + /** * Sets if the command should be hidden from application inspection. * @@ -457,7 +457,7 @@ public function getName() public function setHidden($hiddenBool) { $this->hidden = $hiddenBool; - + return $this; } From fb1f30c51dba52edad3c573b7a9ffd0c9576f2bc Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Sun, 25 Sep 2016 16:08:41 -0400 Subject: [PATCH 06/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index cd79254a485a..b811022f0451 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -34,7 +34,7 @@ class Command private $processTitle; private $aliases = array(); private $definition; - private $hidden; + private $hidden = false; private $help; private $description; private $ignoreValidationErrors = false; @@ -454,9 +454,9 @@ public function getName() * * @return Command The current instance */ - public function setHidden($hiddenBool) + public function setHidden($hidden) { - $this->hidden = $hiddenBool; + $this->hidden = $hidden; return $this; } From 56a8b93b74feb9193b7a84b5bd8133584d46bca2 Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Sun, 25 Sep 2016 16:10:11 -0400 Subject: [PATCH 07/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index b811022f0451..b60c5d2a5136 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -450,7 +450,7 @@ public function getName() /** * Sets if the command should be hidden from application inspection. * - * @param bool $hiddenBool To show this command or not + * @param bool $hidden To show this command or not * * @return Command The current instance */ From cd771396e7c33deb6847f85791a3f3d98f49ea6b Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Sun, 25 Sep 2016 16:12:04 -0400 Subject: [PATCH 08/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index b60c5d2a5136..f5611720670a 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -448,7 +448,7 @@ public function getName() } /** - * Sets if the command should be hidden from application inspection. + * To hide the command in application descriptions. * * @param bool $hidden To show this command or not * @@ -462,7 +462,7 @@ public function setHidden($hidden) } /** - * Returns if the command should be hidden from application inspection. + * Returns if the command should be hidden in application descriptions * * @return bool If the command is hidden or not */ From dfc1ac84385f621936121e2c4fc97fd659380e2a Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Sun, 25 Sep 2016 16:12:50 -0400 Subject: [PATCH 09/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index f5611720670a..f01bc82f7010 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -462,7 +462,7 @@ public function setHidden($hidden) } /** - * Returns if the command should be hidden in application descriptions + * Returns if the command is hidden in application descriptions * * @return bool If the command is hidden or not */ From 3efa8744bef89e639c9ba128e55dcc97141228bf Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Sun, 25 Sep 2016 16:14:59 -0400 Subject: [PATCH 10/14] Update Command.php --- src/Symfony/Component/Console/Command/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index f01bc82f7010..69c2dbaaeb5f 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -462,7 +462,7 @@ public function setHidden($hidden) } /** - * Returns if the command is hidden in application descriptions + * Returns if the command is hidden in application descriptions. * * @return bool If the command is hidden or not */ From e969581f7b758ea0c54ccfb892a4fc560ca77cd4 Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Thu, 29 Sep 2016 14:31:52 -0400 Subject: [PATCH 11/14] update hidden to public --- .../Component/Console/Command/Command.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 69c2dbaaeb5f..41db4d996888 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -34,7 +34,7 @@ class Command private $processTitle; private $aliases = array(); private $definition; - private $hidden = false; + private $public = true; private $help; private $description; private $ignoreValidationErrors = false; @@ -450,25 +450,25 @@ public function getName() /** * To hide the command in application descriptions. * - * @param bool $hidden To show this command or not + * @param bool $public To show this command or not * * @return Command The current instance */ - public function setHidden($hidden) + public function setPublic($public) { - $this->hidden = $hidden; + $this->public = $public; return $this; } /** - * Returns if the command is hidden in application descriptions. + * Returns if the command is public in application descriptions. * - * @return bool If the command is hidden or not + * @return bool If the command is public or not */ - public function isHidden() + public function isPublic() { - return $this->hidden; + return $this->public; } /** From 6d8783799191ef7334d253ec0022375921eee3a3 Mon Sep 17 00:00:00 2001 From: jwdeitch Date: Thu, 29 Sep 2016 14:32:13 -0400 Subject: [PATCH 12/14] Update ApplicationDescription.php --- .../Component/Console/Descriptor/ApplicationDescription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index 4c4a267fe09c..49040d2d2064 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -112,7 +112,7 @@ private function inspectApplication() /** @var Command $command */ foreach ($commands as $name => $command) { - if (!$command->getName() || $command->isHidden()) { + if (!$command->getName() || !$command->isPublic()) { continue; } From 0a3c290ce5440d251e02d142457144fe1b3fecf7 Mon Sep 17 00:00:00 2001 From: Jordan Deitch Date: Thu, 29 Sep 2016 15:12:19 -0400 Subject: [PATCH 13/14] update docblocks and added test --- .../Component/Console/Command/Command.php | 8 ++---- .../Tests/Fixtures/DescriptorApplication2.php | 1 + .../Tests/Fixtures/DescriptorCommand3.php | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand3.php diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 41db4d996888..3967129f0afc 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -448,9 +448,7 @@ public function getName() } /** - * To hide the command in application descriptions. - * - * @param bool $public To show this command or not + * @param bool $public Whether the command should be publicly shown or not. * * @return Command The current instance */ @@ -462,9 +460,7 @@ public function setPublic($public) } /** - * Returns if the command is public in application descriptions. - * - * @return bool If the command is public or not + * @return bool Whether the command should be publicly shown or not. */ public function isPublic() { diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php index ff5513580041..0fe87a18e436 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php +++ b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php @@ -20,5 +20,6 @@ public function __construct() parent::__construct('My Symfony application', 'v1.0'); $this->add(new DescriptorCommand1()); $this->add(new DescriptorCommand2()); + $this->add(new DescriptorCommand3()); } } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand3.php b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand3.php new file mode 100644 index 000000000000..f375778ce3c0 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand3.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Command\Command; + +class DescriptorCommand3 extends Command +{ + protected function configure() + { + $this + ->setName('descriptor:command3') + ->setDescription('command 3 description') + ->setHelp('command 3 help') + ->setPublic(false) + ; + } +} From 746dab31f12b02b43e202d0546d0557320a04e59 Mon Sep 17 00:00:00 2001 From: Jordan Deitch Date: Fri, 30 Sep 2016 15:53:07 -0400 Subject: [PATCH 14/14] casting setPublic() arg to bool --- src/Symfony/Component/Console/Command/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 3967129f0afc..8649756e87d8 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -454,7 +454,7 @@ public function getName() */ public function setPublic($public) { - $this->public = $public; + $this->public = (bool) $public; return $this; }