8000 Add more scalar type-hints · symfony/symfony@342ae44 · GitHub
[go: up one dir, main page]

Skip to content

Commit 342ae44

Browse files
Add more scalar type-hints
1 parent da0b075 commit 342ae44

File tree

539 files changed

+867
-2922
lines changed

Some content is hidden

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

539 files changed

+867
-2922
lines changed

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,8 @@ private function sanitizeQuery($connectionName, $query)
165165
* The return value is an array with the sanitized value and a boolean
166166
* indicating if the original value was kept (allowing to use the sanitized
167167
* value to explain the query).
168-
*
169-
* @param mixed $var
170-
*
171-
* @return array
172168
*/
173-
private function sanitizeParam($var)
169+
private function sanitizeParam($var): array
174170
{
175171
if (is_object($var)) {
176172
$className = get_class($var);

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ class DoctrineValidationPass implements CompilerPassInterface
2323
{
2424
private $managerType;
2525

26-
/**
27-
* @param string $managerType
28-
*/
29-
public function __construct($managerType)
26+
public function __construct(string $managerType)
3027
{
3128
$this->managerType = $managerType;
3229
}
@@ -43,12 +40,8 @@ public function process(ContainerBuilder $container)
4340
/**
4441
* Gets the validation mapping files for the format and extends them with
4542
* files matching a doctrine search pattern (Resources/config/validation.orm.xml).
46-
*
47-
* @param ContainerBuilder $container
48-
* @param string $mapping
49-
* @param string $extension
5043
*/
51-
private function updateValidatorMappingFiles(ContainerBuilder $container, $mapping, $extension)
44+
private function updateValidatorMappingFiles(ContainerBuilder $container, string $mapping, string $extension)
5245
{
5346
if (!$container->hasParameter('validator.mapping.loader.'.$mapping.'_files_loader.mapping_files')) {
5447
return;

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
3737
* manager's service ID for a connection name
3838
* @param string $tagPrefix Tag prefix for listeners and subscribers
3939
*/
40-
public function __construct($connections, $managerTemplate, $tagPrefix)
40+
public function __construct(string $connections, string $managerTemplate, string $tagPrefix)
4141
{
4242
$this->connections = $connections;
4343
$this->managerTemplate = $managerTemplate;

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
117117
* register alias
118118
* @param string[] $aliasMap Map of alias to namespace
119119
*/
120-
public function __construct($driver, array $namespaces, array $managerParameters, $driverPattern, $enabledParameter = false, $configurationPattern = '', $registerAliasMethodName = '', array $aliasMap = array())
120+
public function __construct($driver, array $namespaces, array $managerParameters, string $driverPattern, $enabledParameter = false, string $configurationPattern = '', string $registerAliasMethodName = '', array $aliasMap = array())
121121
{
122122
$this->driver = $driver;
123123
$this->namespaces = $namespaces;

src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class EntityFactory implements UserProviderFactoryInterface
2727
private $key;
2828
private $providerId;
2929

30-
public function __construct($key, $providerId)
30+
public function __construct(string $key, string $providerId)
3131
{
3232
$this->key = $key;
3333
$this->providerId = $providerId;

src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Doctrine\Common\Persistence\ObjectManager;
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
17-
use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
1817
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1918

2019
/**
@@ -45,9 +44,8 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
4544
* @param string $class The class name of the loaded objects
4645
* @param IdReader $idReader The reader for the object IDs
4746
* @param null|EntityLoaderInterface $objectLoader The objects loader
48-
* @param ChoiceListFactoryInterface $factory The factory for creating the loaded choice list
4947
*/
50-
public function __construct(ObjectManager $manager, $class, $idReader = null, $objectLoader = null, $factory = null)
48+
public function __construct(ObjectManager $manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
5149
{
5250
$classMetadata = $manager->getClassMetadata($class);
5351

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,9 @@ public function getTypes($class, $property, array $context = array())
157157
/**
158158
* Determines whether an association is nullable.
159159
*
160-
* @param array $associationMapping
161-
*
162-
* @return bool
163-
*
164160
* @see https://github.com/doctrine/doctrine2/blob/v2.5.4/lib/Doctrine/ORM/Tools/EntityGenerator.php#L1221-L1246
165161
*/
166-
private function isAssociationNullable(array $associationMapping)
162+
private function isAssociationNullable(array $associationMapping): bool
167163
{
168164
if (isset($associationMapping['id']) && $associationMapping['id']) {
169165
return false;
@@ -185,12 +181,8 @@ private function isAssociationNullable(array $associationMapping)
185181

186182
/**
187183
* Gets the corresponding built-in PHP type.
188-
*
189-
* @param string $doctrineType
190-
*
191-
* @return string|null
192184
*/
193-
private function getPhpType($doctrineType)
185+
private function getPhpType(string $doctrineType): ?string
194186
{
195187
switch ($doctrineType) {
196188
case DBALType::SMALLINT:
@@ -217,5 +209,7 @@ private function getPhpType($doctrineType)
217209
case DBALType::OBJECT:
218210
return Type::BUILTIN_TYPE_OBJECT;
219211
}
212+
213+
return null;
220214
}
221215
}

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class EntityUserProvider implements UserProviderInterface
3333
private $class;
3434
private $property;
3535

36-
public function __construct(ManagerRegistry $registry, $classOrAlias, $property = null, $managerName = null)
36+
public function __construct(ManagerRegistry $registry, string $classOrAlias, string $property = null, string $managerName = null)
3737
{
3838
$this->registry = $registry;
3939
$this->managerName = $managerName;

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,9 @@ public function providerBasicDrivers()
187187
}
188188

189189
/**
190-
* @param string $class
191-
* @param array $config
192-
*
193190
* @dataProvider providerBasicDrivers
194191
*/
195-
public function testLoadBasicCacheDriver($class, array $config, array $expectedCalls = array())
192+
public function testLoadBasicCacheDriver(string $class, array $config, array $expectedCalls = array())
196193
{
197194
$container = $this->createContainer();
198195
$cacheName = 'metadata_cache';

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@
1313

1414
class StringWrapper
1515
{
16-
/**
17-
* @var string
18-
*/
1916
private $string;
2017

21-
/**
22-
* @param string $string
23-
*/
24-
public function __construct($string = null)
18+
public function __construct(string $string = null)
2519
{
2620
$this->string = $string;
2721
}

src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe
5858
* @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging
5959
* level (leave empty to use the default mapping)
6060
*/
61-
public function __construct(OutputInterface $output = null, $bubble = true, array $verbosityLevelMap = array())
61+
public function __construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = array())
6262
{
6363
parent::__construct(Logger::DEBUG, $bubble);
6464
$this->output = $output;

src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ServerLogHandler extends AbstractHandler
2424
private $context;
2525
private $socket;
2626

27-
public function __construct($host, $level = Logger::DEBUG, $bubble = true, $context = array())
27+
public function __construct(string $host, int $level = Logger::DEBUG, bool $bubble = true, array $context = array())
2828
{
2929
parent::__construct($level, $bubble);
3030

src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ public function testCanBeConstructedWithExtraFields()
6868
$this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
6969
}
7070

71-
/**
72-
* @return array
73-
*/
74-
private function createRequestEvent($additionalServerParameters = array())
71+
private function createRequestEvent($additionalServerParameters = array()): array
7572
{
7673
$server = array_merge(
7774
array(
@@ -101,13 +98,7 @@ private function createRequestEvent($additionalServerParameters = array())
10198
return array($event, $server);
10299
}
103100

104-
/**
105-
* @param int $level
106-
* @param string $message
107-
*
108-
* @return array Record
109-
*/
110-
private function getRecord($level = Logger::WARNING, $message = 'test')
101+
private function getRecord(int $level = Logger::WARNING, string $message = 'test'): array
111102
{
112103
return array(
113104
'message' => $message,

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,9 @@ public function handleError($type, $msg, $file, $line, $context = array())
315315
}
316316

317317
/**
318-
* @param Test $test
319-
*
320-
* @return bool
318+
* @param TestCase $test
321319
*/
322-
private function willBeIsolated($test)
320+
private function willBeIsolated($test): bool
323321
{
324322
if ($test->isInIsolation()) {
325323
return false;

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Lines changed: 1 addition & 4 deletions
< 10000 tbody>
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ protected function setUp()
3737

3838
/**
3939
* @dataProvider getProxyCandidates
40-
*
41-
* @param Definition $definition
42-
* @param bool $expected
4340
*/
44-
public function testIsProxyCandidate(Definition $definition, $expected)
41+
public function testIsProxyCandidate(Definition $definition, bool $expected)
4542
{
4643
$this->assertSame($expected, $this->dumper->isProxyCandidate($definition));
4744
}

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DebugCommand extends Command
3232
private $twig;
3333
private $projectDir;
3434

35-
public function __construct(Environment $twig, $projectDir = null)
35+
public function __construct(Environment $twig, string $projectDir = null)
3636
{
3737
parent::__construct();
3838

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CodeExtension extends AbstractExtension
3131
* @param string $rootDir The project root directory
3232
* @param string $charset The charset
3333
*/
34-
public function __construct($fileLinkFormat, $rootDir, $charset)
34+
public function __construct($fileLinkFormat, string $rootDir, string $charset)
3535
{
3636
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
3737
$this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR;

src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class StopwatchExtension extends AbstractExtension
2525
private $stopwatch;
2626
private $enabled;
2727

28-
public function __construct(Stopwatch $stopwatch = null, $enabled = true)
28+
public function __construct(Stopwatch $stopwatch = null, bool $enabled = true)
2929
{
3030
$this->stopwatch = $stopwatch;
3131
$this->enabled = $enabled;

src/Symfony/Bridge/Twig/Node/DumpNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DumpNode extends Node
2121
{
2222
private $varPrefix;
2323

24-
public function __construct($varPrefix, Node $values = null, $lineno, $tag = null)
24+
public function __construct($varPrefix, Node $values = null, int $lineno, string $tag = null)
2525
{
2626
$nodes = array();
2727
if (null !== $values) {

src/Symfony/Bridge/Twig/Node/FormThemeNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
*/
2121
class FormThemeNode extends Node
2222
{
23-
public function __construct(Node $form, Node $resources, $lineno, $tag = null, $only = false)
23+
public function __construct(Node $form, Node $resources, int $lineno, string $tag = null, bool $only = false)
2424
{
25-
parent::__construct(array('form' => $form, 'resources' => $resources), array('only' => (bool) $only), $lineno, $tag);
25+
parent::__construct(array('form' => $form, 'resources' => $resources), array('only' => $only), $lineno, $tag);
2626
}
2727

2828
public function compile(Compiler $compiler)

src/Symfony/Bridge/Twig/Node/StopwatchNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class StopwatchNode extends Node
2424
{
25-
public function __construct(Node $name, Node $body, AssignNameExpression $var, $lineno = 0, $tag = null)
25+
public function __construct(Node $name, Node $body, AssignNameExpression $var, int $lineno = 0, string $tag = null)
2626
{
2727
parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag);
2828
}

src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class TransDefaultDomainNode extends Node
2222
{
23-
public function __construct(AbstractExpression $expr, $lineno = 0, $tag = null)
23+
public function __construct(AbstractExpression $expr, int $lineno = 0, string $tag = null)
2424
{
2525
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
2626
}

src/Symfony/Bridge/Twig/Node/TransNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class_exists('Twig\Node\Expression\ArrayExpression');
2727
*/
2828
class TransNode extends Node
2929
{
30-
public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, $lineno = 0, $tag = null)
30+
public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, int $lineno = 0, string $tag = null)
3131
{
3232
$nodes = array('body' => $body);
3333
if (null !== $domain) {

src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,20 @@ public function getPriority()
103103
return 0;
104104
}
105105

106-
/**
107-
* @param Node $arguments
108-
* @param int $index
109-
*
110-
* @return string|null
111-
*/
112-
private function getReadDomainFromArguments(Node $arguments, $index)
106+
private function getReadDomainFromArguments(Node $arguments, int $index): ?string
113107
{
114108
if ($arguments->hasNode('domain')) {
115109
$argument = $arguments->getNode('domain');
116110
} elseif ($arguments->hasNode($index)) {
117111
$argument = $arguments->getNode($index);
118112
} else {
119-
return;
113+
return null;
120114
}
121115

122116
return $this->getReadDomainFromNode($argument);
123117
}
124118

125-
/**
126-
* @return string|null
127-
*/
128-
private function getReadDomainFromNode(Node $node)
119+
private function getReadDomainFromNode(Node $node): ?string
129120
{
130121
if ($node instanceof ConstantExpression) {
131122
return $node->getAttribute('value');

src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class StopwatchTokenParser extends AbstractTokenParser
2525
{
2626
protected $stopwatchIsAvailable;
2727

28-
public function __construct($stopwatchIsAvailable)
28+
public function __construct(bool $stopwatchIsAvailable)
2929
{
3030
$this->stopwatchIsAvailable = $stopwatchIsAvailable;
3131
}

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface
3030
* @param string $phpArrayFile The PHP file where metadata are cached
3131
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached
3232
*/
33-
public function __construct($phpArrayFile, CacheItemPoolInterface $fallbackPool)
33+
public function __construct(string $phpArrayFile, CacheItemPoolInterface $fallbackPool)
3434
{
3535
$this->phpArrayFile = $phpArrayFile;
3636
if (!$fallbackPool instanceof AdapterInterface) {

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
3333
* @param string $phpArrayFile The PHP file where annotations are cached
3434
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached
3535
*/
36-
public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
36+
public function __construct(Reader $annotationReader, string $phpArrayFile, CacheItemPoolInterface $fallbackPool)
3737
{
3838
parent::__construct($phpArrayFile, $fallbackPool);
3939
$this->annotationReader = $annotationReader;

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer
3535
* @param string $phpArrayFile The PHP file where metadata are cached
3636
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached
3737
*/
38-
public function __construct(array $loaders, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
38+
public function __construct(array $loaders, string $phpArrayFile, CacheItemPoolInterface $fallbackPool)
3939
{
4040
parent::__construct($phpArrayFile, $fallbackPool);
4141
$this->loaders = $loaders;

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TemplateFinder implements TemplateFinderInterface
3434
* @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance
3535
* @param string $rootDir The directory where global templates can be stored
3636
*/
37-
public function __construct(KernelInterface $kernel, TemplateNameParserInterface $parser, $rootDir)
37+
public function __construct(KernelInterface $kernel, TemplateNameParserInterface $parser, string $rootDir)
3838
{
3939
$this->kernel = $kernel;
4040
$this->parser = $parser;

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer
3737
* @param string $phpArrayFile The PHP file where metadata are cached
3838
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached
3939
*/
40-
public function __construct(ValidatorBuilderInterface $validatorBuilder, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
40+
public function __construct(ValidatorBuilderInterface $validatorBuilder, string $phpArrayFile, CacheItemPoolInterface $fallbackPool)
4141
{
4242
parent::__construct($phpArrayFile, $fallbackPool);
4343
$this->validatorBuilder = $validatorBuilder;

0 commit comments

Comments
 (0)
0