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

Commit72c85c5

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

File tree

38 files changed

+201
-320
lines changed

38 files changed

+201
-320
lines changed

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

Lines changed: 16 additions & 19 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.
@@ -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) {
@@ -1034,12 +1034,9 @@ private function getAbbreviationSuggestions($abbrevs)
10341034
*
10351035
* This method is not part of public API and should not be used directly.
10361036
*
1037-
* @param string $name The full name of the command
1038-
* @param string $limit The maximum number of parts of the namespace
1039-
*
10401037
* @return string The namespace of the command
10411038
*/
1042-
publicfunctionextractNamespace($name,$limit =null)
1039+
publicfunctionextractNamespace(string$name,int$limit =null)
10431040
{
10441041
$parts =explode(':',$name);
10451042
array_pop($parts);
@@ -1056,7 +1053,7 @@ public function extractNamespace($name, $limit = null)
10561053
*
10571054
* @return string[] A sorted array of similar string
10581055
*/
1059-
privatefunctionfindAlternatives($name,$collection)
1056+
privatefunctionfindAlternatives(string$name,iterable$collection)
10601057
{
10611058
$threshold =1e3;
10621059
$alternatives = [];
@@ -1106,7 +1103,7 @@ private function findAlternatives($name, $collection)
11061103
*
11071104
* @return self
11081105
*/
1109-
publicfunctionsetDefaultCommand($commandName,$isSingleCommand =false)
1106+
publicfunctionsetDefaultCommand(string$commandName,bool$isSingleCommand =false)
11101107
{
11111108
$this->defaultCommand =$commandName;
11121109

@@ -1165,7 +1162,7 @@ private function splitStringByWidth($string, $width)
11651162
*
11661163
* @return string[] The namespaces of the command
11671164
*/
1168-
privatefunctionextractAllNamespaces($name)
1165+
privatefunctionextractAllNamespaces(string$name)
11691166
{
11701167
// -1 as third argument is needed to skip the command short name when exploding
11711168
$parts =explode(':',$name, -1);

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

Lines changed: 14 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,14 @@ public function getNativeDefinition()
360360
/**
361361
* Adds an argument.
362362
*
363-
* @param string $name The argument name
364363
* @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
365-
* @param string $description A description text
366-
* @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only)
364+
* @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only)
367365
*
368366
* @throws InvalidArgumentException When argument mode is not valid
369367
*
370368
* @return $this
371369
*/
372-
publicfunctionaddArgument($name,$mode =null,$description ='',$default =null)
370+
publicfunctionaddArgument(string$name,int$mode =null,string$description ='',$default =null)
373371
{
374372
$this->definition->addArgument(newInputArgument($name,$mode,$description,$default));
375373

@@ -389,7 +387,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n
389387
*
390388
* @return $this
391389
*/
392-
publicfunctionaddOption($name,$shortcut =null,$mode =null,$description ='',$default =null)
390+
publicfunctionaddOption(string$name,$shortcut =null,int$mode =null,string$description ='',$default =null)
393391
{
394392
$this->definition->addOption(newInputOption($name,$shortcut,$mode,$description,$default));
395393

@@ -410,7 +408,7 @@ public function addOption($name, $shortcut = null, $mode = null, $description =
410408
*
411409
* @throws InvalidArgumentException When the name is invalid
412410
*/
413-
publicfunctionsetName($name)
411+
publicfunctionsetName(string$name)
414412
{
415413
$this->validateName($name);
416414

@@ -431,7 +429,7 @@ public function setName($name)
431429
*
432430
* @return $this
433431
*/
434-
publicfunctionsetProcessTitle($title)
432+
publicfunctionsetProcessTitle(string$title)
435433
{
436434
$this->processTitle =$title;
437435

@@ -453,9 +451,9 @@ public function getName()
453451
*
454452
* @return Command The current instance
455453
*/
456-
publicfunctionsetHidden($hidden)
454+
publicfunctionsetHidden(bool$hidden)
457455
{
458-
$this->hidden =(bool)$hidden;
456+
$this->hidden =$hidden;
459457

460458
return$this;
461459
}
@@ -475,7 +473,7 @@ public function isHidden()
475473
*
476474
* @return $this
477475
*/
478-
publicfunctionsetDescription($description)
476+
publicfunctionsetDescription(string$description)
479477
{
480478
$this->description =$description;
481479

@@ -499,7 +497,7 @@ public function getDescription()
499497
*
500498
* @return $this
501499
*/
502-
publicfunctionsetHelp($help)
500+
publicfunctionsetHelp(string$help)
503501
{
504502
$this->help =$help;
505503

@@ -548,12 +546,8 @@ public function getProcessedHelp()
548546
*
549547
* @throws InvalidArgumentException When an alias is invalid
550548
*/
551-
publicfunctionsetAliases($aliases)
549+
publicfunctionsetAliases(?iterable$aliases)
552550
{
553-
if (!\is_array($aliases) && !$aliasesinstanceof \Traversable) {
554-
thrownewInvalidArgumentException('$aliases must be an array or an instance of \Traversable');
555-
}
556-
557551
foreach ($aliasesas$alias) {
558552
$this->validateName($alias);
559553
}
@@ -580,7 +574,7 @@ public function getAliases()
580574
*
581575
* @return string The synopsis
582576
*/
583-
publicfunctiongetSynopsis($short =false)
577+
publicfunctiongetSynopsis(bool$short =false)
584578
{
585579
$key =$short ?'short' :'long';
586580

@@ -598,7 +592,7 @@ public function getSynopsis($short = false)
598592
*
599593
* @return $this
600594
*/
601-
publicfunctionaddUsage($usage)
595+
publicfunctionaddUsage(string$usage)
602596
{
603597
if (0 !==strpos($usage,$this->name)) {
604598
$usage =sprintf('%s %s',$this->name,$usage);
@@ -629,7 +623,7 @@ public function getUsages()
629623
* @throws LogicException if no HelperSet is defined
630624
* @throws InvalidArgumentException if the helper is not defined
631625
*/
632-
publicfunctiongetHelper($name)
626+
publicfunctiongetHelper(string$name)
633627
{
634628
if (null ===$this->helperSet) {
635629
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: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespaceSymfony\Component\Console\CommandLoader;
413

514
useSymfony\Component\Console\Command\Command;
@@ -13,22 +22,18 @@ interface CommandLoaderInterface
1322
/**
1423
* Loads a command.
1524
*
16-
* @param string $name
17-
*
1825
* @return Command
1926
*
2027
* @throws CommandNotFoundException
2128
*/
22-
publicfunctionget($name);
29+
publicfunctionget(string$name);
2330

2431
/**
2532
* Checks if a command exists.
2633
*
27-
* @param string $name
28-
*
2934
* @return bool
3035
*/
31-
publicfunctionhas($name);
36+
publicfunctionhas(string$name);
3237

3338
/**
3439
* @return string[] All registered command names

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespaceSymfony\Component\Console\CommandLoader;
413

514
usePsr\Container\ContainerInterface;
@@ -28,7 +37,7 @@ public function __construct(ContainerInterface $container, array $commandMap)
2837
/**
2938
* {@inheritdoc}
3039
*/
31-
publicfunctionget($name)
40+
publicfunctionget(string$name)
3241
{
3342
if (!$this->has($name)) {
3443
thrownewCommandNotFoundException(sprintf('Command "%s" does not exist.',$name));
@@ -40,7 +49,7 @@ public function get($name)
4049
/**
4150
* {@inheritdoc}
4251
*/
43-
publicfunctionhas($name)
52+
publicfunctionhas(string$name)
4453
{
4554
returnisset($this->commandMap[$name]) &&$this->container->has($this->commandMap[$name]);
4655
}

‎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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,8 @@ public function describe(OutputInterface $output, $object, array $options = [])
6161

6262
/**
6363
* Writes content to output.
64-
*
65-
* @param string $content
66-
* @param bool $decorated
6764
*/
68-
protectedfunctionwrite($content,$decorated =false)
65+
protectedfunctionwrite(string$content,bool$decorated =false)
6966
{
7067
$this->output->write($content,false,$decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
7168
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp