4141use Symfony \Component \Console \Output \ConsoleOutputInterface ;
4242use Symfony \Component \Console \Output \OutputInterface ;
4343use Symfony \Component \Console \Style \SymfonyStyle ;
44- use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
4544use Symfony \Component \ErrorCatcher \ErrorHandler ;
4645use Symfony \Component \ErrorCatcher \Exception \FatalThrowableError ;
46+ use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
4747
4848/**
4949 * An Application is the container for a collection of commands.
@@ -78,10 +78,6 @@ class Application
7878private $ singleCommand =false ;
7979private $ initialized ;
8080
81- /**
82- * @param string $name The name of the application
83- * @param string $version The version of the application
84- */
8581public function __construct (string $ name ='UNKNOWN ' ,string $ version ='UNKNOWN ' )
8682 {
8783$ this ->name =$ name ;
@@ -342,12 +338,10 @@ public function areExceptionsCaught()
342338
343339/**
344340 * Sets whether to catch exceptions or not during commands execution.
345- *
346- * @param bool $boolean Whether to catch exceptions or not during commands execution
347341 */
348- public function setCatchExceptions ($ boolean )
342+ public function setCatchExceptions (bool $ boolean )
349343 {
350- $ this ->catchExceptions =( bool ) $ boolean ;
344+ $ this ->catchExceptions =$ boolean ;
351345 }
352346
353347/**
@@ -362,12 +356,10 @@ public function isAutoExitEnabled()
362356
363357/**
364358 * Sets whether to automatically exit after a command execution or not.
365- *
366- * @param bool $boolean Whether to automatically exit after a command execution or not
367359 */
368- public function setAutoExit ($ boolean )
360+ public function setAutoExit (bool $ boolean )
369361 {
370- $ this ->autoExit =( bool ) $ boolean ;
362+ $ this ->autoExit =$ boolean ;
371363 }
372364
373365/**
@@ -382,10 +374,8 @@ public function getName()
382374
383375/**
384376 * Sets the application name.
385- *
386- * @param string $name The application name
387- */
388- public function setName ($ name )
377+ **/
378+ public function setName (string $ name )
389379 {
390380$ this ->name =$ name ;
391381 }
@@ -402,10 +392,8 @@ public function getVersion()
402392
403393/**
404394 * Sets the application version.
405- *
406- * @param string $version The application version
407395 */
408- public function setVersion ($ version )
396+ public function setVersion (string $ version )
409397 {
410398$ this ->version =$ version ;
411399 }
@@ -431,11 +419,9 @@ public function getLongVersion()
431419/**
432420 * Registers a new command.
433421 *
434- * @param string $name The command name
435- *
436422 * @return Command The newly created command
437423 */
438- public function register ($ name )
424+ public function register (string $ name )
439425 {
440426return $ this ->add (new Command ($ name ));
441427 }
@@ -494,13 +480,11 @@ public function add(Command $command)
494480/**
495481 * Returns a registered command by name or alias.
496482 *
497- * @param string $name The command name or alias
498- *
499483 * @return Command A Command object
500484 *
501485 * @throws CommandNotFoundException When given command name does not exist
502486 */
503- public function get ($ name )
487+ public function get (string $ name )
504488 {
505489$ this ->init ();
506490
@@ -525,11 +509,9 @@ public function get($name)
525509/**
526510 * Returns true if the command exists, false otherwise.
527511 *
528- * @param string $name The command name or alias
529- *
530512 * @return bool true if the command exists, false otherwise
531513 */
532- public function has ($ name )
514+ public function has (string $ name )
533515 {
534516$ this ->init ();
535517
@@ -560,13 +542,11 @@ public function getNamespaces()
560542/**
561543 * Finds a registered namespace by a name or an abbreviation.
562544 *
563- * @param string $namespace A namespace or abbreviation to search for
564- *
565545 * @return string A registered namespace
566546 *
567547 * @throws NamespaceNotFoundException When namespace is incorrect or ambiguous
568548 */
569- public function findNamespace ($ namespace )
549+ public function findNamespace (string $ namespace )
570550 {
571551$ allNamespaces =$ this ->getNamespaces ();
572552$ expr =preg_replace_callback ('{([^:]+|)} ' ,function ($ matches ) {return preg_quote ($ matches [1 ]).'[^:]* ' ; },$ namespace );
@@ -602,13 +582,11 @@ public function findNamespace($namespace)
602582 * Contrary to get, this command tries to find the best
603583 * match if you give it an abbreviation of a name or alias.
604584 *
605- * @param string $name A command name or a command alias
606- *
607585 * @return Command A Command instance
608586 *
609587 * @throws CommandNotFoundException When command name is incorrect or ambiguous
610588 */
611- public function find ($ name )
589+ public function find (string $ name )
612590 {
613591$ this ->init ();
614592
@@ -694,11 +672,9 @@ public function find($name)
694672 *
695673 * The array keys are the full names and the values the command instances.
696674 *
697- * @param string $namespace A namespace name
698- *
699675 * @return Command[] An array of Command instances
700676 */
701- public function all ($ namespace =null )
677+ public function all (string $ namespace =null )
702678 {
703679$ this ->init ();
704680
@@ -738,11 +714,9 @@ public function all($namespace = null)
738714/**
739715 * Returns an array of possible abbreviations given a set of names.
740716 *
741- * @param array $names An array of names
742- *
743- * @return array An array of abbreviations
717+ * @return string[][] An array of abbreviations
744718 */
745- public static function getAbbreviations ($ names )
719+ public static function getAbbreviations (array $ names )
746720 {
747721$ abbrevs = [];
748722foreach ($ namesas $ name ) {
@@ -1020,11 +994,9 @@ protected function getDefaultHelperSet()
1020994/**
1021995 * Returns abbreviated suggestions in string format.
1022996 *
1023- * @param array $abbrevs Abbreviated suggestions to convert
1024- *
1025997 * @return string A formatted string of abbreviated suggestions
1026998 */
1027- private function getAbbreviationSuggestions ($ abbrevs )
999+ private function getAbbreviationSuggestions (array $ abbrevs )
10281000 {
10291001return ' ' .implode ("\n " ,$ abbrevs );
10301002 }
@@ -1034,12 +1006,9 @@ private function getAbbreviationSuggestions($abbrevs)
10341006 *
10351007 * This method is not part of public API and should not be used directly.
10361008 *
1037- * @param string $name The full name of the command
1038- * @param string $limit The maximum number of parts of the namespace
1039- *
10401009 * @return string The namespace of the command
10411010 */
1042- public function extractNamespace ($ name ,$ limit =null )
1011+ public function extractNamespace (string $ name ,int $ limit =null )
10431012 {
10441013$ parts =explode (': ' ,$ name );
10451014array_pop ($ parts );
@@ -1051,12 +1020,9 @@ public function extractNamespace($name, $limit = null)
10511020 * Finds alternative of $name among $collection,
10521021 * if nothing is found in $collection, try in $abbrevs.
10531022 *
1054- * @param string $name The string
1055- * @param iterable $collection The collection
1056- *
10571023 * @return string[] A sorted array of similar string
10581024 */
1059- private function findAlternatives ($ name ,$ collection )
1025+ private function findAlternatives (string $ name ,iterable $ collection )
10601026 {
10611027$ threshold =1e3 ;
10621028$ alternatives = [];
@@ -1101,12 +1067,9 @@ private function findAlternatives($name, $collection)
11011067/**
11021068 * Sets the default Command name.
11031069 *
1104- * @param string $commandName The Command name
1105- * @param bool $isSingleCommand Set to true if there is only one command in this application
1106- *
11071070 * @return self
11081071 */
1109- public function setDefaultCommand ($ commandName ,$ isSingleCommand =false )
1072+ public function setDefaultCommand (string $ commandName ,bool $ isSingleCommand =false )
11101073 {
11111074$ this ->defaultCommand =$ commandName ;
11121075
@@ -1161,11 +1124,9 @@ private function splitStringByWidth($string, $width)
11611124/**
11621125 * Returns all namespaces of the command name.
11631126 *
1164- * @param string $name The full name of the command
1165- *
11661127 * @return string[] The namespaces of the command
11671128 */
1168- private function extractAllNamespaces ($ name )
1129+ private function extractAllNamespaces (string $ name )
11691130 {
11701131// -1 as third argument is needed to skip the command short name when exploding
11711132$ parts =explode (': ' ,$ name , -1 );