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

Commitc11267f

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

File tree

34 files changed

+171
-300
lines changed

34 files changed

+171
-300
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ public function isAutoExitEnabled()
365365
*
366366
* @param bool $boolean Whether to automatically exit after a command execution or not
367367
*/
368-
publicfunctionsetAutoExit($boolean)
368+
publicfunctionsetAutoExit(bool$boolean)
369369
{
370-
$this->autoExit =(bool)$boolean;
370+
$this->autoExit =$boolean;
371371
}
372372

373373
/**
@@ -385,7 +385,7 @@ public function getName()
385385
*
386386
* @param string $name The application name
387387
*/
388-
publicfunctionsetName($name)
388+
publicfunctionsetName(string$name)
389389
{
390390
$this->name =$name;
391391
}
@@ -405,7 +405,7 @@ public function getVersion()
405405
*
406406
* @param string $version The application version
407407
*/
408-
publicfunctionsetVersion($version)
408+
publicfunctionsetVersion(string$version)
409409
{
410410
$this->version =$version;
411411
}
@@ -435,7 +435,7 @@ public function getLongVersion()
435435
*
436436
* @return Command The newly created command
437437
*/
438-
publicfunctionregister($name)
438+
publicfunctionregister(string$name)
439439
{
440440
return$this->add(newCommand($name));
441441
}
@@ -500,7 +500,7 @@ public function add(Command $command)
500500
*
501501
* @throws CommandNotFoundException When given command name does not exist
502502
*/
503-
publicfunctionget($name)
503+
publicfunctionget(string$name)
504504
{
505505
$this->init();
506506

@@ -529,7 +529,7 @@ public function get($name)
529529
*
530530
* @return bool true if the command exists, false otherwise
531531
*/
532-
publicfunctionhas($name)
532+
publicfunctionhas(string$name)
533533
{
534534
$this->init();
535535

@@ -566,7 +566,7 @@ public function getNamespaces()
566566
*
567567
* @throws NamespaceNotFoundException When namespace is incorrect or ambiguous
568568
*/
569-
publicfunctionfindNamespace($namespace)
569+
publicfunctionfindNamespace(string$namespace)
570570
{
571571
$allNamespaces =$this->getNamespaces();
572572
$expr =preg_replace_callback('{([^:]+|)}',function ($matches) {returnpreg_quote($matches[1]).'[^:]*'; },$namespace);
@@ -608,7 +608,7 @@ public function findNamespace($namespace)
608608
*
609609
* @throws CommandNotFoundException When command name is incorrect or ambiguous
610610
*/
611-
publicfunctionfind($name)
611+
publicfunctionfind(string$name)
612612
{
613613
$this->init();
614614

@@ -698,7 +698,7 @@ public function find($name)
698698
*
699699
* @return Command[] An array of Command instances
700700
*/
701-
publicfunctionall($namespace =null)
701+
publicfunctionall(string$namespace =null)
702702
{
703703
$this->init();
704704

@@ -742,7 +742,7 @@ public function all($namespace = null)
742742
*
743743
* @return array An array of abbreviations
744744
*/
745-
publicstaticfunctiongetAbbreviations($names)
745+
publicstaticfunctiongetAbbreviations(array$names)
746746
{
747747
$abbrevs = [];
748748
foreach ($namesas$name) {
@@ -1039,7 +1039,7 @@ private function getAbbreviationSuggestions($abbrevs)
10391039
*
10401040
* @return string The namespace of the command
10411041
*/
1042-
publicfunctionextractNamespace($name,$limit =null)
1042+
publicfunctionextractNamespace(string$name,string$limit =null)
10431043
{
10441044
$parts =explode(':',$name);
10451045
array_pop($parts);
@@ -1056,7 +1056,7 @@ public function extractNamespace($name, $limit = null)
10561056
*
10571057
* @return string[] A sorted array of similar string
10581058
*/
1059-
privatefunctionfindAlternatives($name,$collection)
1059+
privatefunctionfindAlternatives(string$name,iterable$collection)
10601060
{
10611061
$threshold =1e3;
10621062
$alternatives = [];
@@ -1106,7 +1106,7 @@ private function findAlternatives($name, $collection)
11061106
*
11071107
* @return self
11081108
*/
1109-
publicfunctionsetDefaultCommand($commandName,$isSingleCommand =false)
1109+
publicfunctionsetDefaultCommand(string$commandName,bool$isSingleCommand =false)
11101110
{
11111111
$this->defaultCommand =$commandName;
11121112

@@ -1165,7 +1165,7 @@ private function splitStringByWidth($string, $width)
11651165
*
11661166
* @return string[] The namespaces of the command
11671167
*/
1168-
privatefunctionextractAllNamespaces($name)
1168+
privatefunctionextractAllNamespaces(string$name)
11691169
{
11701170
// -1 as third argument is needed to skip the command short name when exploding
11711171
$parts =explode(':',$name, -1);

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function setCode(callable $code)
293293
*
294294
* @param bool $mergeArgs Whether to merge or not the Application definition arguments to Command definition arguments
295295
*/
296-
publicfunctionmergeApplicationDefinition($mergeArgs =true)
296+
publicfunctionmergeApplicationDefinition(bool$mergeArgs =true)
297297
{
298298
if (null ===$this->application || (true ===$this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
299299
return;
@@ -360,16 +360,13 @@ public function getNativeDefinition()
360360
/**
361361
* Adds an argument.
362362
*
363-
* @param string $name The argument name
364-
* @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
365-
* @param string $description A description text
366363
* @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only)
367364
*
368365
* @throws InvalidArgumentException When argument mode is not valid
369366
*
370367
* @return $this
371368
*/
372-
publicfunctionaddArgument($name,$mode =null,$description ='',$default =null)
369+
publicfunctionaddArgument(string$name,int$mode =null,string$description ='',$default =null)
373370
{
374371
$this->definition->addArgument(newInputArgument($name,$mode,$description,$default));
375372

@@ -389,7 +386,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n
389386
*
390387
* @return $this
391388
*/
392-
publicfunctionaddOption($name,$shortcut =null,$mode =null,$description ='',$default =null)
389+
publicfunctionaddOption(string$name,$shortcut =null,int$mode =null,string$description ='',$default =null)
393390
{
394391
$this->definition->addOption(newInputOption($name,$shortcut,$mode,$description,$default));
395392

@@ -410,7 +407,7 @@ public function addOption($name, $shortcut = null, $mode = null, $description =
410407
*
411408
* @throws InvalidArgumentException When the name is invalid
412409
*/
413-
publicfunctionsetName($name)
410+
publicfunctionsetName(string$name)
414411
{
415412
$this->validateName($name);
416413

@@ -431,7 +428,7 @@ public function setName($name)
431428
*
432429
* @return $this
433430
*/
434-
publicfunctionsetProcessTitle($title)
431+
publicfunctionsetProcessTitle(string$title)
435432
{
436433
$this->processTitle =$title;
437434

@@ -453,9 +450,9 @@ public function getName()
453450
*
454451
* @return Command The current instance
455452
*/
456-
publicfunctionsetHidden($hidden)
453+
publicfunctionsetHidden(bool$hidden)
457454
{
458-
$this->hidden =(bool)$hidden;
455+
$this->hidden =$hidden;
459456

460457
return$this;
461458
}
@@ -475,7 +472,7 @@ public function isHidden()
475472
*
476473
* @return $this
477474
*/
478-
publicfunctionsetDescription($description)
475+
publicfunctionsetDescription(string$description)
479476
{
480477
$this->description =$description;
481478

@@ -499,7 +496,7 @@ public function getDescription()
499496
*
500497
* @return $this
501498
*/
502-
publicfunctionsetHelp($help)
499+
publicfunctionsetHelp(string$help)
503500
{
504501
$this->help =$help;
505502

@@ -548,12 +545,8 @@ public function getProcessedHelp()
548545
*
549546
* @throws InvalidArgumentException When an alias is invalid
550547
*/
551-
publicfunctionsetAliases($aliases)
548+
publicfunctionsetAliases(array$aliases)
552549
{
553-
if (!\is_array($aliases) && !$aliasesinstanceof \Traversable) {
554-
thrownewInvalidArgumentException('$aliases must be an array or an instance of \Traversable');
555-
}
556-
557550
foreach ($aliasesas$alias) {
558551
$this->validateName($alias);
559552
}
@@ -580,7 +573,7 @@ public function getAliases()
580573
*
581574
* @return string The synopsis
582575
*/
583-
publicfunctiongetSynopsis($short =false)
576+
publicfunctiongetSynopsis(bool$short =false)
584577
{
585578
$key =$short ?'short' :'long';
586579

@@ -598,7 +591,7 @@ public function getSynopsis($short = false)
598591
*
599592
* @return $this
600593
*/
601-
publicfunctionaddUsage($usage)
594+
publicfunctionaddUsage(string$usage)
602595
{
603596
if (0 !==strpos($usage,$this->name)) {
604597
$usage =sprintf('%s %s',$this->name,$usage);
@@ -629,7 +622,7 @@ public function getUsages()
629622
* @throws LogicException if no HelperSet is defined
630623
* @throws InvalidArgumentException if the helper is not defined
631624
*/
632-
publicfunctiongetHelper($name)
625+
publicfunctiongetHelper(string$name)
633626
{
634627
if (null ===$this->helperSet) {
635628
thrownewLogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.',$name));

‎src/Symfony/Component/Console/Command/LockableTrait.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ trait LockableTrait
3232
*
3333
* @return bool
3434
*/
35-
privatefunctionlock($name =null,$blocking =false)
35+
privatefunctionlock(?string$name =null,bool$blocking =false)
3636
{
3737
if (!class_exists(SemaphoreStore::class)) {
3838
thrownewLogicException('To enable the locking feature you must install the symfony/lock component.');

‎src/Symfony/Component/Console/CommandLoader/CommandLoaderInterface.php‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,18 @@ interface CommandLoaderInterface
1313
/**
1414
* Loads a command.
1515
*
16-
* @param string $name
17-
*
1816
* @return Command
1917
*
2018
* @throws CommandNotFoundException
2119
*/
22-
publicfunctionget($name);
20+
publicfunctionget(string$name);
2321

2422
/**
2523
* Checks if a command exists.
2624
*
27-
* @param string $name
28-
*
2925
* @return bool
3026
*/
31-
publicfunctionhas($name);
27+
publicfunctionhas(string$name);
3228

3329
/**
3430
* @return string[] All registered command names

‎src/Symfony/Component/Console/CommandLoader/ContainerCommandLoader.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(ContainerInterface $container, array $commandMap)
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
publicfunctionget($name)
31+
publicfunctionget(string$name)
3232
{
3333
if (!$this->has($name)) {
3434
thrownewCommandNotFoundException(sprintf('Command "%s" does not exist.',$name));
@@ -40,7 +40,7 @@ public function get($name)
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
publicfunctionhas($name)
43+
publicfunctionhas(string$name)
4444
{
4545
returnisset($this->commandMap[$name]) &&$this->container->has($this->commandMap[$name]);
4646
}

‎src/Symfony/Component/Console/CommandLoader/FactoryCommandLoader.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public function __construct(array $factories)
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
publicfunctionhas($name)
36+
publicfunctionhas(string$name)
3737
{
3838
returnisset($this->factories[$name]);
3939
}
4040

4141
/**
4242
* {@inheritdoc}
4343
*/
44-
publicfunctionget($name)
44+
publicfunctionget(string$name)
4545
{
4646
if (!isset($this->factories[$name])) {
4747
thrownewCommandNotFoundException(sprintf('Command "%s" does not exist.',$name));

‎src/Symfony/Component/Console/Descriptor/ApplicationDescription.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getCommands()
8181
*
8282
* @throws CommandNotFoundException
8383
*/
84-
publicfunctiongetCommand($name)
84+
publicfunctiongetCommand(string$name)
8585
{
8686
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
8787
thrownewCommandNotFoundException(sprintf('Command %s does not exist.',$name));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function describe(OutputInterface $output, $object, array $options = [])
6565
* @param string $content
6666
* @param bool $decorated
6767
*/
68-
protectedfunctionwrite($content,$decorated =false)
68+
protectedfunctionwrite(string$content,bool$decorated =false)
6969
{
7070
$this->output->write($content,false,$decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
7171
}

‎src/Symfony/Component/Console/Descriptor/XmlDescriptor.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getCommandDocument(Command $command)
8686
*
8787
* @return \DOMDocument
8888
*/
89-
publicfunctiongetApplicationDocument(Application$application,$namespace =null)
89+
publicfunctiongetApplicationDocument(Application$application,string$namespace =null)
9090
{
9191
$dom =new \DOMDocument('1.0','UTF-8');
9292
$dom->appendChild($rootXml =$dom->createElement('symfony'));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp