Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit493fd65

Browse files
committed
[Console] [5.0] Add all type-hint
1 parent8fb4741 commit493fd65

File tree

44 files changed

+230
-499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+230
-499
lines changed

‎src/Symfony/Component/Console/Application.php‎

Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
useSymfony\Component\Console\Output\ConsoleOutputInterface;
4242
useSymfony\Component\Console\Output\OutputInterface;
4343
useSymfony\Component\Console\Style\SymfonyStyle;
44-
useSymfony\Contracts\EventDispatcher\EventDispatcherInterface;
4544
useSymfony\Component\ErrorCatcher\ErrorHandler;
4645
useSymfony\Component\ErrorCatcher\Exception\FatalThrowableError;
46+
useSymfony\Contracts\EventDispatcher\EventDispatcherInterface;
4747

4848
/**
4949
* An Application is the container for a collection of commands.
@@ -78,10 +78,6 @@ class Application
7878
private$singleCommand =false;
7979
private$initialized;
8080

81-
/**
82-
* @param string $name The name of the application
83-
* @param string $version The version of the application
84-
*/
8581
publicfunction__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-
publicfunctionsetCatchExceptions($boolean)
342+
publicfunctionsetCatchExceptions(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-
publicfunctionsetAutoExit($boolean)
360+
publicfunctionsetAutoExit(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-
publicfunctionsetName($name)
377+
**/
378+
publicfunctionsetName(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-
publicfunctionsetVersion($version)
396+
publicfunctionsetVersion(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-
publicfunctionregister($name)
424+
publicfunctionregister(string$name)
439425
{
440426
return$this->add(newCommand($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-
publicfunctionget($name)
487+
publicfunctionget(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-
publicfunctionhas($name)
514+
publicfunctionhas(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-
publicfunctionfindNamespace($namespace)
549+
publicfunctionfindNamespace(string$namespace)
570550
{
571551
$allNamespaces =$this->getNamespaces();
572552
$expr =preg_replace_callback('{([^:]+|)}',function ($matches) {returnpreg_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-
publicfunctionfind($name)
589+
publicfunctionfind(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-
publicfunctionall($namespace =null)
677+
publicfunctionall(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-
publicstaticfunctiongetAbbreviations($names)
719+
publicstaticfunctiongetAbbreviations(array$names)
746720
{
747721
$abbrevs = [];
748722
foreach ($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-
privatefunctiongetAbbreviationSuggestions($abbrevs)
999+
privatefunctiongetAbbreviationSuggestions(array$abbrevs)
10281000
{
10291001
return''.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-
publicfunctionextractNamespace($name,$limit =null)
1011+
publicfunctionextractNamespace(string$name,int$limit =null)
10431012
{
10441013
$parts =explode(':',$name);
10451014
array_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-
privatefunctionfindAlternatives($name,$collection)
1025+
privatefunctionfindAlternatives(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-
publicfunctionsetDefaultCommand($commandName,$isSingleCommand =false)
1072+
publicfunctionsetDefaultCommand(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-
privatefunctionextractAllNamespaces($name)
1129+
privatefunctionextractAllNamespaces(string$name)
11691130
{
11701131
// -1 as third argument is needed to skip the command short name when exploding
11711132
$parts =explode(':',$name, -1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp