Security update for Core, with self-updated composer
[yaffs-website] / vendor / consolidation / annotated-command / src / AnnotatedCommand.php
index 597d6a2fa97858e05dca42b66fdf77463070e8f5..41be53a96aca8f5f2ed29edaeef29dc2b42b92d6 100644 (file)
@@ -3,8 +3,6 @@ namespace Consolidation\AnnotatedCommand;
 
 use Consolidation\AnnotatedCommand\Hooks\HookManager;
 use Consolidation\AnnotatedCommand\Parser\CommandInfo;
-use Consolidation\OutputFormatters\FormatterManager;
-use Consolidation\OutputFormatters\Options\FormatterOptions;
 use Consolidation\AnnotatedCommand\Help\HelpDocumentAlter;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputArgument;
@@ -132,6 +130,11 @@ class AnnotatedCommand extends Command implements HelpDocumentAlter
         }
         $this->setCommandArguments($commandInfo);
         $this->setReturnType($commandInfo->getReturnType());
+        // Hidden commands available since Symfony 3.2
+        // http://symfony.com/doc/current/console/hide_commands.html
+        if (method_exists($this, 'setHidden')) {
+            $this->setHidden($commandInfo->getHidden());
+        }
         return $this;
     }
 
@@ -225,8 +228,11 @@ class AnnotatedCommand extends Command implements HelpDocumentAlter
      */
     protected function checkUsesInputInterface($params)
     {
+        /** @var \ReflectionParameter $firstParam */
         $firstParam = reset($params);
-        return $firstParam instanceof InputInterface;
+        return $firstParam && $firstParam->getClass() && $firstParam->getClass()->implementsInterface(
+            '\\Symfony\\Component\\Console\\Input\\InputInterface'
+        );
     }
 
     /**
@@ -251,7 +257,11 @@ class AnnotatedCommand extends Command implements HelpDocumentAlter
         $index = $this->checkUsesInputInterface($params) ? 1 : 0;
         $this->usesOutputInterface =
             (count($params) > $index) &&
-            ($params[$index] instanceof OutputInterface);
+            $params[$index]->getClass() &&
+            $params[$index]->getClass()->implementsInterface(
+                '\\Symfony\\Component\\Console\\Output\\OutputInterface'
+            )
+        ;
         return $this;
     }
 
@@ -428,10 +438,15 @@ class AnnotatedCommand extends Command implements HelpDocumentAlter
         );
 
         $commandData->setUseIOInterfaces(
-            $this->usesOutputInterface,
-            $this->usesInputInterface
+            $this->usesInputInterface,
+            $this->usesOutputInterface
         );
 
+        // Allow the commandData to cache the list of options with
+        // special default values ('null' and 'true'), as these will
+        // need special handling. @see CommandData::options().
+        $commandData->cacheSpecialDefaults($this->getDefinition());
+
         return $commandData;
     }
 }