diff --git a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php index bca53ef4092b7..e605c057e353f 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php @@ -165,12 +165,8 @@ private function sanitizeQuery($connectionName, $query) * The return value is an array with the sanitized value and a boolean * indicating if the original value was kept (allowing to use the sanitized * value to explain the query). - * - * @param mixed $var - * - * @return array */ - private function sanitizeParam($var) + private function sanitizeParam($var): array { if (is_object($var)) { $className = get_class($var); diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php index f154083b29de6..5f74ecfbcc5ae 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php @@ -23,10 +23,7 @@ class DoctrineValidationPass implements CompilerPassInterface { private $managerType; - /** - * @param string $managerType - */ - public function __construct($managerType) + public function __construct(string $managerType) { $this->managerType = $managerType; } @@ -43,12 +40,8 @@ public function process(ContainerBuilder $container) /** * Gets the validation mapping files for the format and extends them with * files matching a doctrine search pattern (Resources/config/validation.orm.xml). - * - * @param ContainerBuilder $container - * @param string $mapping - * @param string $extension */ - private function updateValidatorMappingFiles(ContainerBuilder $container, $mapping, $extension) + private function updateValidatorMappingFiles(ContainerBuilder $container, string $mapping, string $extension) { if (!$container->hasParameter('validator.mapping.loader.'.$mapping.'_files_loader.mapping_files')) { return; diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php index f918d0d211c94..93a7a4e0bcfcd 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php @@ -37,7 +37,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface * manager's service ID for a connection name * @param string $tagPrefix Tag prefix for listeners and subscribers */ - public function __construct($connections, $managerTemplate, $tagPrefix) + public function __construct(string $connections, string $managerTemplate, string $tagPrefix) { $this->connections = $connections; $this->managerTemplate = $managerTemplate; diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php index 21a9fd29a80cb..4f140f81edd0e 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php @@ -117,7 +117,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface * register alias * @param string[] $aliasMap Map of alias to namespace */ - public function __construct($driver, array $namespaces, array $managerParameters, $driverPattern, $enabledParameter = false, $configurationPattern = '', $registerAliasMethodName = '', array $aliasMap = array()) + public function __construct($driver, array $namespaces, array $managerParameters, string $driverPattern, $enabledParameter = false, string $configurationPattern = '', string $registerAliasMethodName = '', array $aliasMap = array()) { $this->driver = $driver; $this->namespaces = $namespaces; diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php index 49c528ba00fdb..1f946266a0958 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php @@ -27,7 +27,7 @@ class EntityFactory implements UserProviderFactoryInterface private $key; private $providerId; - public function __construct($key, $providerId) + public function __construct(string $key, string $providerId) { $this->key = $key; $this->providerId = $providerId; diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php index 27bd3316c9842..a5a08b13ea426 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php @@ -14,7 +14,6 @@ use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; /** @@ -45,9 +44,8 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface * @param string $class The class name of the loaded objects * @param IdReader $idReader The reader for the object IDs * @param null|EntityLoaderInterface $objectLoader The objects loader - * @param ChoiceListFactoryInterface $factory The factory for creating the loaded choice list */ - public function __construct(ObjectManager $manager, $class, $idReader = null, $objectLoader = null, $factory = null) + public function __construct(ObjectManager $manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null) { $classMetadata = $manager->getClassMetadata($class); diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 079ff8263fe29..aa1d95ecc6bb7 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -157,13 +157,9 @@ public function getTypes($class, $property, array $context = array()) /** * Determines whether an association is nullable. * - * @param array $associationMapping - * - * @return bool - * * @see https://github.com/doctrine/doctrine2/blob/v2.5.4/lib/Doctrine/ORM/Tools/EntityGenerator.php#L1221-L1246 */ - private function isAssociationNullable(array $associationMapping) + private function isAssociationNullable(array $associationMapping): bool { if (isset($associationMapping['id']) && $associationMapping['id']) { return false; @@ -185,12 +181,8 @@ private function isAssociationNullable(array $associationMapping) /** * Gets the corresponding built-in PHP type. - * - * @param string $doctrineType - * - * @return string|null */ - private function getPhpType($doctrineType) + private function getPhpType(string $doctrineType): ?string { switch ($doctrineType) { case DBALType::SMALLINT: @@ -217,5 +209,7 @@ private function getPhpType($doctrineType) case DBALType::OBJECT: return Type::BUILTIN_TYPE_OBJECT; } + + return null; } } diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 22f6b388a1c4c..ea2793d471e33 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -33,7 +33,7 @@ class EntityUserProvider implements UserProviderInterface private $class; private $property; - public function __construct(ManagerRegistry $registry, $classOrAlias, $property = null, $managerName = null) + public function __construct(ManagerRegistry $registry, string $classOrAlias, string $property = null, string $managerName = null) { $this->registry = $registry; $this->managerName = $managerName; diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 82558c724af9b..4ea059f3b6468 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -187,12 +187,9 @@ public function providerBasicDrivers() } /** - * @param string $class - * @param array $config - * * @dataProvider providerBasicDrivers */ - public function testLoadBasicCacheDriver($class, array $config, array $expectedCalls = array()) + public function testLoadBasicCacheDriver(string $class, array $config, array $expectedCalls = array()) { $container = $this->createContainer(); $cacheName = 'metadata_cache'; diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php index 4f647627bb2f0..d46798aa84bb4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Type/StringWrapper.php @@ -15,10 +15,7 @@ class StringWrapper { private $string; - /** - * @param string $string - */ - public function __construct($string = null) + public function __construct(string $string = null) { $this->string = $string; } diff --git a/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php b/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php index 04943779dd241..a23dc327c48f6 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php @@ -58,7 +58,7 @@ class ConsoleHandler extends AbstractProcessingHandler implements EventSubscribe * @param array $verbosityLevelMap Array that maps the OutputInterface verbosity to a minimum logging * level (leave empty to use the default mapping) */ - public function __construct(OutputInterface $output = null, $bubble = true, array $verbosityLevelMap = array()) + public function __construct(OutputInterface $output = null, bool $bubble = true, array $verbosityLevelMap = array()) { parent::__construct(Logger::DEBUG, $bubble); $this->output = $output; diff --git a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php index d1d4968df4cda..99979c5a80ba1 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php @@ -24,7 +24,7 @@ class ServerLogHandler extends AbstractHandler private $context; private $socket; - public function __construct($host, $level = Logger::DEBUG, $bubble = true, $context = array()) + public function __construct(string $host, int $level = Logger::DEBUG, bool $bubble = true, array $context = array()) { parent::__construct($level, $bubble); diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index e73002e0292fa..5f2be509231a8 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -68,10 +68,7 @@ public function testCanBeConstructedWithExtraFields() $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); } - /** - * @return array - */ - private function createRequestEvent($additionalServerParameters = array()) + private function createRequestEvent($additionalServerParameters = array()): array { $server = array_merge( array( @@ -101,13 +98,7 @@ private function createRequestEvent($additionalServerParameters = array()) return array($event, $server); } - /** - * @param int $level - * @param string $message - * - * @return array Record - */ - private function getRecord($level = Logger::WARNING, $message = 'test') + private function getRecord(int $level = Logger::WARNING, string $message = 'test'): array { return array( 'message' => $message, diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 2d64381304c6c..f2fc08df42921 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -30,10 +30,7 @@ class ProxyDumper implements DumperInterface private $proxyGenerator; private $classGenerator; - /** - * @param string $salt - */ - public function __construct($salt = '') + public function __construct(string $salt = '') { $this->salt = $salt; $this->proxyGenerator = new LazyLoadingValueHolderGenerator(); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index 2c6c6a2da8efb..6dee01fccec85 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -37,11 +37,8 @@ protected function setUp() /** * @dataProvider getProxyCandidates - * - * @param Definition $definition - * @param bool $expected */ - public function testIsProxyCandidate(Definition $definition, $expected) + public function testIsProxyCandidate(Definition $definition, bool $expected) { $this->assertSame($expected, $this->dumper->isProxyCandidate($definition)); } diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index 91fda7324086d..d6d8f1cdc816a 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -32,7 +32,7 @@ class DebugCommand extends Command private $twig; private $projectDir; - public function __construct(Environment $twig, $projectDir = null) + public function __construct(Environment $twig, string $projectDir = null) { parent::__construct(); diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index e47772481bdb7..cc9dfe36de64b 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -31,7 +31,7 @@ class CodeExtension extends AbstractExtension * @param string $rootDir The project root directory * @param string $charset The charset */ - public function __construct($fileLinkFormat, $rootDir, $charset) + public function __construct($fileLinkFormat, string $rootDir, string $charset) { $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR; diff --git a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php index 48d99b8c7eac3..1afbea5f363a3 100644 --- a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php @@ -25,7 +25,7 @@ class StopwatchExtension extends AbstractExtension private $stopwatch; private $enabled; - public function __construct(Stopwatch $stopwatch = null, $enabled = true) + public function __construct(Stopwatch $stopwatch = null, bool $enabled = true) { $this->stopwatch = $stopwatch; $this->enabled = $enabled; diff --git a/src/Symfony/Bridge/Twig/Node/DumpNode.php b/src/Symfony/Bridge/Twig/Node/DumpNode.php index d820d75cc7db9..452b64ccb1011 100644 --- a/src/Symfony/Bridge/Twig/Node/DumpNode.php +++ b/src/Symfony/Bridge/Twig/Node/DumpNode.php @@ -21,7 +21,7 @@ class DumpNode extends Node { private $varPrefix; - public function __construct($varPrefix, Node $values = null, $lineno, $tag = null) + public function __construct($varPrefix, Node $values = null, int $lineno, string $tag = null) { $nodes = array(); if (null !== $values) { diff --git a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php index 707a79e912b00..b898ec58bf26c 100644 --- a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php +++ b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php @@ -20,9 +20,9 @@ */ class FormThemeNode extends Node { - public function __construct(Node $form, Node $resources, $lineno, $tag = null, $only = false) + public function __construct(Node $form, Node $resources, int $lineno, string $tag = null, bool $only = false) { - parent::__construct(array('form' => $form, 'resources' => $resources), array('only' => (bool) $only), $lineno, $tag); + parent::__construct(array('form' => $form, 'resources' => $resources), array('only' => $only), $lineno, $tag); } public function compile(Compiler $compiler) diff --git a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php index fac770c2499ba..d95c63028c2eb 100644 --- a/src/Symfony/Bridge/Twig/Node/StopwatchNode.php +++ b/src/Symfony/Bridge/Twig/Node/StopwatchNode.php @@ -22,7 +22,7 @@ */ class StopwatchNode extends Node { - public function __construct(Node $name, Node $body, AssignNameExpression $var, $lineno = 0, $tag = null) + public function __construct(Node $name, Node $body, AssignNameExpression $var, int $lineno = 0, string $tag = null) { parent::__construct(array('body' => $body, 'name' => $name, 'var' => $var), array(), $lineno, $tag); } diff --git a/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php b/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php index c9c82b33e541c..63ad1f6796152 100644 --- a/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php @@ -20,7 +20,7 @@ */ class TransDefaultDomainNode extends Node { - public function __construct(AbstractExpression $expr, $lineno = 0, $tag = null) + public function __construct(AbstractExpression $expr, int $lineno = 0, string $tag = null) { parent::__construct(array('expr' => $expr), array(), $lineno, $tag); } diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index 020810f7b7c55..7eb8d743e9b3e 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -27,7 +27,7 @@ class_exists('Twig\Node\Expression\ArrayExpression'); */ class TransNode extends Node { - public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, $lineno = 0, $tag = null) + public function __construct(Node $body, Node $domain = null, AbstractExpression $count = null, AbstractExpression $vars = null, AbstractExpression $locale = null, int $lineno = 0, string $tag = null) { $nodes = array('body' => $body); if (null !== $domain) { diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index 1fbce9c6af811..fef722be64ce5 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -103,29 +103,20 @@ public function getPriority() return 0; } - /** - * @param Node $arguments - * @param int $index - * - * @return string|null - */ - private function getReadDomainFromArguments(Node $arguments, $index) + private function getReadDomainFromArguments(Node $arguments, int $index): ?string { if ($arguments->hasNode('domain')) { $argument = $arguments->getNode('domain'); } elseif ($arguments->hasNode($index)) { $argument = $arguments->getNode($index); } else { - return; + return null; } return $this->getReadDomainFromNode($argument); } - /** - * @return string|null - */ - private function getReadDomainFromNode(Node $node) + private function getReadDomainFromNode(Node $node): ?string { if ($node instanceof ConstantExpression) { return $node->getAttribute('value'); diff --git a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php index 82c58d40bbf8d..dd78175d219fa 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/StopwatchTokenParser.php @@ -25,7 +25,7 @@ class StopwatchTokenParser extends AbstractTokenParser { protected $stopwatchIsAvailable; - public function __construct($stopwatchIsAvailable) + public function __construct(bool $stopwatchIsAvailable) { $this->stopwatchIsAvailable = $stopwatchIsAvailable; } diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php index 25801a7829c91..cbd864d2ede3e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php @@ -30,7 +30,7 @@ abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface * @param string $phpArrayFile The PHP file where metadata are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached */ - public function __construct($phpArrayFile, CacheItemPoolInterface $fallbackPool) + public function __construct(string $phpArrayFile, CacheItemPoolInterface $fallbackPool) { $this->phpArrayFile = $phpArrayFile; if (!$fallbackPool instanceof AdapterInterface) { diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php index 4026b53bd7740..9a2905eb24cdd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php @@ -33,7 +33,7 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer * @param string $phpArrayFile The PHP file where annotations are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached */ - public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool) + public function __construct(Reader $annotationReader, string $phpArrayFile, CacheItemPoolInterface $fallbackPool) { parent::__construct($phpArrayFile, $fallbackPool); $this->annotationReader = $annotationReader; diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php index 22d2bcfe9cf50..0b2ede48646a0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php @@ -35,7 +35,7 @@ class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer * @param string $phpArrayFile The PHP file where metadata are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached */ - public function __construct(array $loaders, $phpArrayFile, CacheItemPoolInterface $fallbackPool) + public function __construct(array $loaders, string $phpArrayFile, CacheItemPoolInterface $fallbackPool) { parent::__construct($phpArrayFile, $fallbackPool); $this->loaders = $loaders; diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php index 9c69980ab14f9..cd1e4806b71b6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php @@ -34,7 +34,7 @@ class TemplateFinder implements TemplateFinderInterface * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance * @param string $rootDir The directory where global templates can be stored */ - public function __construct(KernelInterface $kernel, TemplateNameParserInterface $parser, $rootDir) + public function __construct(KernelInterface $kernel, TemplateNameParserInterface $parser, string $rootDir) { $this->kernel = $kernel; $this->parser = $parser; diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php index 2fb4ace86401c..51a965f71baa2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php @@ -37,7 +37,7 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer * @param string $phpArrayFile The PHP file where metadata are cached * @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached */ - public function __construct(ValidatorBuilderInterface $validatorBuilder, $phpArrayFile, CacheItemPoolInterface $fallbackPool) + public function __construct(ValidatorBuilderInterface $validatorBuilder, string $phpArrayFile, CacheItemPoolInterface $fallbackPool) { parent::__construct($phpArrayFile, $fallbackPool); $this->validatorBuilder = $validatorBuilder; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index bc0f980e51da4..ed60620b0afb2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -37,10 +37,6 @@ class CacheClearCommand extends Command private $cacheClearer; private $filesystem; - /** - * @param CacheClearerInterface $cacheClearer - * @param Filesystem|null $filesystem - */ public function __construct(CacheClearerInterface $cacheClearer, Filesystem $filesystem = null) { parent::__construct(); @@ -79,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new SymfonyStyle($input, $output); $kernel = $this->getApplication()->getKernel(); - $realCacheDir = isset($realCacheDir) ? $realCacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir'); + $realCacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir'); // the old cache dir name must not be longer than the real one to avoid exceeding // the maximum length of a directory or file path within it (esp. Windows MAX_PATH) $oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php index 1c9cef9b93eda..145ef4fee6fdf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolPruneCommand.php @@ -31,7 +31,7 @@ final class CachePoolPruneCommand extends Command /** * @param iterable|PruneableInterface[] $pools */ - public function __construct($pools) + public function __construct(iterable $pools) { parent::__construct(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index a019e6c4b03e7..03fb20c441d3d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -207,13 +207,7 @@ protected function getRouteData(Route $route) ); } - /** - * @param Definition $definition - * @param bool $omitTags - * - * @return array - */ - private function getContainerDefinitionData(Definition $definition, $omitTags = false, $showArguments = false) + private function getContainerDefinitionData(Definition $definition, bool $omitTags = false, bool $showArguments = false): array { $data = array( 'class' => (string) $definition->getClass(), @@ -267,10 +261,7 @@ private function getContainerDefinitionData(Definition $definition, $omitTags = return $data; } - /** - * @return array - */ - private function getContainerAliasData(Alias $alias) + private function getContainerAliasData(Alias $alias): array { return array( 'service' => (string) $alias, @@ -278,13 +269,7 @@ private function getContainerAliasData(Alias $alias) ); } - /** - * @param EventDispatcherInterface $eventDispatcher - * @param string|null $event - * - * @return array - */ - private function getEventDispatcherListenersData(EventDispatcherInterface $eventDispatcher, $event = null) + private function getEventDispatcherListenersData(EventDispatcherInterface $eventDispatcher, string $event = null): array { $data = array(); @@ -310,13 +295,7 @@ private function getEventDispatcherListenersData(EventDispatcherInterface $event return $data; } - /** - * @param callable $callable - * @param array $options - * - * @return array - */ - private function getCallableData($callable, array $options = array()) + private function getCallableData($callable, array $options = array()): array { $data = array(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index ff57f478fdd18..e4bb3f66a7516 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -426,12 +426,7 @@ private function renderEventListenerTable(EventDispatcherInterface $eventDispatc $io->table($tableHeaders, $tableRows); } - /** - * @param array $config - * - * @return string - */ - private function formatRouterConfig(array $config) + private function formatRouterConfig(array $config): string { if (empty($config)) { return 'NONE'; @@ -447,12 +442,7 @@ private function formatRouterConfig(array $config) return trim($configAsString); } - /** - * @param callable $callable - * - * @return string - */ - private function formatCallable($callable) + private function formatCallable($callable): string { if (is_array($callable)) { if (is_object($callable[0])) { @@ -477,11 +467,7 @@ private function formatCallable($callable) throw new \InvalidArgumentException('Callable is not describable.'); } - /** - * @param string $content - * @param array $options - */ - private function writeText($content, array $options = array()) + private function writeText(string $content, array $options = array()) { $this->write( isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content, diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index da878b1ee6d53..37af3802bea67 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -141,10 +141,7 @@ private function writeDocument(\DOMDocument $dom) $this->write($dom->saveXML()); } - /** - * @return \DOMDocument - */ - private function getRouteCollectionDocument(RouteCollection $routes) + private function getRouteCollectionDocument(RouteCollection $routes): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($routesXML = $dom->createElement('routes')); @@ -157,13 +154,7 @@ private function getRouteCollectionDocument(RouteCollection $routes) return $dom; } - /** - * @param Route $route - * @param string|null $name - * - * @return \DOMDocument - */ - private function getRouteDocument(Route $route, $name = null) + private function getRouteDocument(Route $route, string $name = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($routeXML = $dom->createElement('route')); @@ -226,10 +217,7 @@ private function getRouteDocument(Route $route, $name = null) return $dom; } - /** - * @return \DOMDocument - */ - private function getContainerParametersDocument(ParameterBag $parameters) + private function getContainerParametersDocument(ParameterBag $parameters): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($parametersXML = $dom->createElement('parameters')); @@ -243,13 +231,7 @@ private function getContainerParametersDocument(ParameterBag $parameters) return $dom; } - /** - * @param ContainerBuilder $builder - * @param bool $showPrivate - * - * @return \DOMDocument - */ - private function getContainerTagsDocument(ContainerBuilder $builder, $showPrivate = false) + private function getContainerTagsDocument(ContainerBuilder $builder, bool $showPrivate = false): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($containerXML = $dom->createElement('container')); @@ -267,15 +249,7 @@ private function getContainerTagsDocument(ContainerBuilder $builder, $showPrivat return $dom; } - /** - * @param mixed $service - * @param string $id - * @param ContainerBuilder|null $builder - * @param bool $showArguments - * - * @return \DOMDocument - */ - private function getContainerServiceDocument($service, $id, ContainerBuilder $builder = null, $showArguments = false) + private function getContainerServiceDocument($service, string $id, ContainerBuilder $builder = null, bool $showArguments = false): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); @@ -295,16 +269,7 @@ private function getContainerServiceDocument($service, $id, ContainerBuilder $bu return $dom; } - /** - * @param ContainerBuilder $builder - * @param string|null $tag - * @param bool $showPrivate - * @param bool $showArguments - * @param callable $filter - * - * @return \DOMDocument - */ - private function getContainerServicesDocument(ContainerBuilder $builder, $tag = null, $showPrivate = false, $showArguments = false, $filter = null) + private function getContainerServicesDocument(ContainerBuilder $builder, string $tag = null, bool $showPrivate = false, bool $showArguments = false, callable $filter = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($containerXML = $dom->createElement('container')); @@ -329,14 +294,7 @@ private function getContainerServicesDocument(ContainerBuilder $builder, $tag = return $dom; } - /** - * @param Definition $definition - * @param string|null $id - * @param bool $omitTags - * - * @return \DOMDocument - */ - private function getContainerDefinitionDocument(Definition $definition, $id = null, $omitTags = false, $showArguments = false) + private function getContainerDefinitionDocument(Definition $definition, string $id = null, bool $omitTags = false, bool $showArguments = false): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($serviceXML = $dom->createElement('definition')); @@ -453,13 +411,7 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom) return $nodes; } - /** - * @param Alias $alias - * @param string|null $id - * - * @return \DOMDocument - */ - private function getContainerAliasDocument(Alias $alias, $id = null) + private function getContainerAliasDocument(Alias $alias, string $id = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($aliasXML = $dom->createElement('alias')); @@ -474,10 +426,7 @@ private function getContainerAliasDocument(Alias $alias, $id = null) return $dom; } - /** - * @return \DOMDocument - */ - private function getContainerParameterDocument($parameter, $options = array()) + private function getContainerParameterDocument($parameter, $options = array()): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($parameterXML = $dom->createElement('parameter')); @@ -491,13 +440,7 @@ private function getContainerParameterDocument($parameter, $options = array()) return $dom; } - /** - * @param EventDispatcherInterface $eventDispatcher - * @param string|null $event - * - * @return \DOMDocument - */ - private function getEventDispatcherListenersDocument(EventDispatcherInterface $eventDispatcher, $event = null) + private function getEventDispatcherListenersDocument(EventDispatcherInterface $eventDispatcher, string $event = null): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($eventDispatcherXML = $dom->createElement('event-dispatcher')); @@ -529,12 +472,7 @@ private function appendEventListenerDocument(EventDispatcherInterface $eventDisp } } - /** - * @param callable $callable - * - * @return \DOMDocument - */ - private function getCallableDocument($callable) + private function getCallableDocument($callable): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->appendChild($callableXML = $dom->createElement('callable')); diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index b9f15d7c2507b..c104ba10c2465 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -29,13 +29,11 @@ abstract class Controller implements ContainerAwareInterface /** * Gets a container configuration parameter by its name. * - * @param string $name The parameter name - * * @return mixed * * @final since version 3.4 */ - protected function getParameter($name) + protected function getParameter(string $name) { return $this->container->getParameter($name); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php index 49c33c06503a7..21b13f91e8cc7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php @@ -106,12 +106,8 @@ public function build($controller) /** * Attempts to find a bundle that is *similar* to the given bundle name. - * - * @param string $nonExistentBundleName - * - * @return string */ - private function findAlternative($nonExistentBundleName) + private function findAlternative(string $nonExistentBundleName): ?string { $bundleNames = array_map(function ($b) { return $b->getName(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index fab8f5659613d..96b4fa10fb22a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -42,13 +42,9 @@ trait ControllerTrait /** * Returns true if the service id is defined. * - * @param string $id The service id - * - * @return bool true if the service id is defined, false otherwise - * * @final since version 3.4 */ - protected function has($id) + protected function has(string $id): bool { return $this->container->has($id); } @@ -56,13 +52,11 @@ protected function has($id) /** * Gets a container service by its id. * - * @param string $id The service id - * * @return object The service * * @final since version 3.4 */ - protected function get($id) + protected function get(string $id) { return $this->container->get($id); } @@ -70,17 +64,11 @@ protected function get($id) /** * Generates a URL from the given parameters. * - * @param string $route The name of the route - * @param array $parameters An array of parameters - * @param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface) - * - * @return string The generated URL - * * @see UrlGeneratorInterface * * @final since version 3.4 */ - protected function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) + protected function generateUrl(string $route, array $parameters = array(), int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string { return $this->container->get('router')->generate($route, $parameters, $referenceType); } @@ -89,14 +77,10 @@ protected function generateUrl($route, $parameters = array(), $referenceType = U * Forwards the request to another controller. * * @param string $controller The controller name (a string like BlogBundle:Post:index) - * @param array $path An array of path parameters - * @param array $query An array of query parameters - * - * @return Response A Response instance * * @final since version 3.4 */ - protected function forward($controller, array $path = array(), array $query = array()) + protected function forward(string $controller, array $path = array(), array $query = array()): Response { $request = $this->container->get('request_stack')->getCurrentRequest(); $path['_forwarded'] = $request->attributes; @@ -109,14 +93,9 @@ protected function forward($controller, array $path = array(), array $query = ar /** * Returns a RedirectResponse to the given URL. * - * @param string $url The URL to redirect to - * @param int $status The status code to use for the Response - * - * @return RedirectResponse - * * @final since version 3.4 */ - protected function redirect($url, $status = 302) + protected function redirect(string $url, int $status = 302): RedirectResponse { return new RedirectResponse($url, $status); } @@ -124,15 +103,9 @@ protected function redirect($url, $status = 302) /** * Returns a RedirectResponse to the given route with the given parameters. * - * @param string $route The name of the route - * @param array $parameters An array of parameters - * @param int $status The status code to use for the Response - * - * @return RedirectResponse - * * @final since version 3.4 */ - protected function redirectToRoute($route, array $parameters = array(), $status = 302) + protected function redirectToRoute(string $route, array $parameters = array(), int $status = 302): RedirectResponse { return $this->redirect($this->generateUrl($route, $parameters), $status); } @@ -140,16 +113,9 @@ protected function redirectToRoute($route, array $parameters = array(), $status /** * Returns a JsonResponse that uses the serializer component if enabled, or json_encode. * - * @param mixed $data The response data - * @param int $status The status code to use for the Response - * @param array $headers Array of extra headers to add - * @param array $context Context to pass to serializer when using serializer component - * - * @return JsonResponse - * * @final since version 3.4 */ - protected function json($data, $status = 200, $headers = array(), $context = array()) + protected function json($data, int $status = 200, array $headers = array(), array $context = array()): JsonResponse { if ($this->container->has('serializer')) { $json = $this->container->get('serializer')->serialize($data, 'json', array_merge(array( @@ -165,15 +131,11 @@ protected function json($data, $status = 200, $headers = array(), $context = arr /** * Returns a BinaryFileResponse object with original or customized file name and disposition header. * - * @param \SplFileInfo|string $file File object or path to file to be sent as response - * @param string|null $fileName File name to be sent to response or null (will use original file name) - * @param string $disposition Disposition of response ("attachment" is default, other type is "inline") - * - * @return BinaryFileResponse + * @param \SplFileInfo|string $file File object or path to file to be sent as response * * @final since version 3.4 */ - protected function file($file, $fileName = null, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT) + protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse { $response = new BinaryFileResponse($file); $response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName); @@ -184,14 +146,11 @@ protected function file($file, $fileName = null, $disposition = ResponseHeaderBa /** * Adds a flash message to the current session for type. * - * @param string $type The type - * @param string $message The message - * * @throws \LogicException * * @final since version 3.4 */ - protected function addFlash($type, $message) + protected function addFlash(string $type, string $message) { if (!$this->container->has('session')) { throw new \LogicException('You can not use the addFlash method if sessions are disabled.'); @@ -203,16 +162,11 @@ protected function addFlash($type, $message) /** * Checks if the attributes are granted against the current authentication token and optionally supplied subject. * - * @param mixed $attributes The attributes - * @param mixed $subject The subject - * - * @return bool - * * @throws \LogicException * * @final since version 3.4 */ - protected function isGranted($attributes, $subject = null) + protected function isGranted($attributes, $subject = null): bool { if (!$this->container->has('security.authorization_checker')) { throw new \LogicException('The SecurityBundle is not registered in your application.'); @@ -225,15 +179,11 @@ protected function isGranted($attributes, $subject = null) * Throws an exception unless the attributes are granted against the current authentication token and optionally * supplied subject. * - * @param mixed $attributes The attributes - * @param mixed $subject The subject - * @param string $message The message passed to the exception - * * @throws AccessDeniedException * * @final since version 3.4 */ - protected function denyAccessUnlessGranted($attributes, $subject = null, $message = 'Access Denied.') + protected function denyAccessUnlessGranted($attributes, $subject = null, string $message = 'Access Denied.') { if (!$this->isGranted($attributes, $subject)) { $exception = $this->createAccessDeniedException($message); @@ -247,14 +197,9 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, $messag /** * Returns a rendered view. * - * @param string $view The view name - * @param array $parameters An array of parameters to pass to the view - * - * @return string The rendered view - * * @final since version 3.4 */ - protected function renderView($view, array $parameters = array()) + protected function renderView(string $view, array $parameters = array()): string { if ($this->container->has('templating')) { return $this->container->get('templating')->render($view, $parameters); @@ -270,15 +215,9 @@ protected function renderView($view, array $parameters = array()) /** * Renders a view. * - * @param string $view The view name - * @param array $parameters An array of parameters to pass to the view - * @param Response $response A response instance - * - * @return Response A Response instance - * * @final since version 3.4 */ - protected function render($view, array $parameters = array(), Response $response = null) + protected function render(string $view, array $parameters = array(), Response $response = null): Response { if ($this->container->has('templating')) { $content = $this->container->get('templating')->render($view, $parameters); @@ -300,15 +239,9 @@ protected function render($view, array $parameters = array(), Response $response /** * Streams a view. * - * @param string $view The view name - * @param array $parameters An array of parameters to pass to the view - * @param StreamedResponse $response A response instance - * - * @return StreamedResponse A StreamedResponse instance - * * @final since version 3.4 */ - protected function stream($view, array $parameters = array(), StreamedResponse $response = null) + protected function stream(string $view, array $parameters = array(), StreamedResponse $response = null): StreamedResponse { if ($this->container->has('templating')) { $templating = $this->container->get('templating'); @@ -342,14 +275,9 @@ protected function stream($view, array $parameters = array(), StreamedResponse $ * * throw $this->createNotFoundException('Page not found!'); * - * @param string $message A message - * @param \Exception|null $previous The previous exception - * - * @return NotFoundHttpException - * * @final since version 3.4 */ - protected function createNotFoundException($message = 'Not Found', \Exception $previous = null) + protected function createNotFoundException(string $message = 'Not Found', \Exception $previous = null): NotFoundHttpException { return new NotFoundHttpException($message, $previous); } @@ -361,14 +289,9 @@ protected function createNotFoundException($message = 'Not Found', \Exception $p * * throw $this->createAccessDeniedException('Unable to access this page!'); * - * @param string $message A message - * @param \Exception|null $previous The previous exception - * - * @return AccessDeniedException - * * @final since version 3.4 */ - protected function createAccessDeniedException($message = 'Access Denied.', \Exception $previous = null) + protected function createAccessDeniedException(string $message = 'Access Denied.', \Exception $previous = null): AccessDeniedException { return new AccessDeniedException($message, $previous); } @@ -376,15 +299,9 @@ protected function createAccessDeniedException($message = 'Access Denied.', \Exc /** * Creates and returns a Form instance from the type of the form. * - * @param string $type The fully qualified class name of the form type - * @param mixed $data The initial data for the form - * @param array $options Options for the form - * - * @return FormInterface - * * @final since version 3.4 */ - protected function createForm($type, $data = null, array $options = array()) + protected function createForm(string $type, $data = null, array $options = array()): FormInterface { return $this->container->get('form.factory')->create($type, $data, $options); } @@ -392,14 +309,9 @@ protected function createForm($type, $data = null, array $options = array()) /** * Creates and returns a form builder instance. * - * @param mixed $data The initial data for the form - * @param array $options Options for the form - * - * @return FormBuilderInterface - * * @final since version 3.4 */ - protected function createFormBuilder($data = null, array $options = array()) + protected function createFormBuilder($data = null, array $options = array()): FormBuilderInterface { return $this->container->get('form.factory')->createBuilder(FormType::class, $data, $options); } @@ -407,13 +319,11 @@ protected function createFormBuilder($data = null, array $options = array()) /** * Shortcut to return the Doctrine Registry service. * - * @return ManagerRegistry - * * @throws \LogicException If DoctrineBundle is not available * * @final since version 3.4 */ - protected function getDoctrine() + protected function getDoctrine(): ManagerRegistry { if (!$this->container->has('doctrine')) { throw new \LogicException('The DoctrineBundle is not registered in your application.'); @@ -457,11 +367,9 @@ protected function getUser() * @param string $id The id used when generating the token * @param string $token The actual token sent with the request that should be validated * - * @return bool - * * @final since version 3.4 */ - protected function isCsrfTokenValid($id, $token) + protected function isCsrfTokenValid(string $id, string $token): bool { if (!$this->container->has('security.csrf.token_manager')) { throw new \LogicException('CSRF protection is not enabled in your application.'); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php index d02e2c372c3d4..bd692e4261d5d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CachePoolPrunerPass.php @@ -27,7 +27,7 @@ class CachePoolPrunerPass implements CompilerPassInterface private $cacheCommandServiceId; private $cachePoolTag; - public function __construct($cacheCommandServiceId = CachePoolPruneCommand::class, $cachePoolTag = 'cache.pool') + public function __construct(string $cacheCommandServiceId = CachePoolPruneCommand::class, string $cachePoolTag = 'cache.pool') { $this->cacheCommandServiceId = $cacheCommandServiceId; $this->cachePoolTag = $cachePoolTag; diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 1e66e1bb2fdea..998bd98789273 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -38,9 +38,9 @@ class Configuration implements ConfigurationInterface /** * @param bool $debug Whether debugging is enabled or not */ - public function __construct($debug) + public function __construct(bool $debug) { - $this->debug = (bool) $debug; + $this->debug = $debug; } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php index 68dc1bc05f4de..5877caaf592ac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpCache/HttpCache.php @@ -32,7 +32,7 @@ abstract class HttpCache extends BaseHttpCache * @param HttpKernelInterface $kernel An HttpKernelInterface instance * @param string $cacheDir The cache directory (default used if null) */ - public function __construct(HttpKernelInterface $kernel, $cacheDir = null) + public function __construct(HttpKernelInterface $kernel, string $cacheDir = null) { $this->kernel = $kernel; $this->cacheDir = $cacheDir; diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index fc17906330059..a3b9c573bc135 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -28,7 +28,7 @@ class CodeHelper extends Helper * @param string $rootDir The project root directory * @param string $charset The charset */ - public function __construct($fileLinkFormat, $rootDir, $charset) + public function __construct($fileLinkFormat, string $rootDir, string $charset) { $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); $this->rootDir = str_replace('\\', '/', $rootDir).'/'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php index dc57cc0964c56..8f9b256d6a163 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php @@ -30,7 +30,7 @@ class TemplateLocator implements FileLocatorInterface * @param FileLocatorInterface $locator A FileLocatorInterface instance * @param string $cacheDir The cache path */ - public function __construct(FileLocatorInterface $locator, $cacheDir = null) + public function __construct(FileLocatorInterface $locator, string $cacheDir = null) { if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) { $this->cache = require $cache; diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php index d9bc982d74524..d03e4f59b8697 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php @@ -20,7 +20,7 @@ */ class TemplateReference extends BaseTemplateReference { - public function __construct($bundle = null, $controller = null, $name = null, $format = null, $engine = null) + public function __construct(string $bundle = null, string $controller = null, string $name = null, string $format = null, string $engine = null) { $this->parameters = array( 'bundle' => $bundle, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php index 5356f4a0adb51..d13e1204420e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CachePruneCommandTest.php @@ -33,10 +33,7 @@ public function testCommandWithNoPools() $tester->execute(array()); } - /** - * @return RewindableGenerator - */ - private function getRewindableGenerator() + private function getRewindableGenerator(): RewindableGenerator { return new RewindableGenerator(function () { yield 'foo_pool' => $this->getPruneableInterfaceMock(); @@ -44,10 +41,7 @@ private function getRewindableGenerator() }, 2); } - /** - * @return RewindableGenerator - */ - private function getEmptyRewindableGenerator() + private function getEmptyRewindableGenerator(): RewindableGenerator { return new RewindableGenerator(function () { return new \ArrayIterator(array()); @@ -96,10 +90,7 @@ private function getPruneableInterfaceMock() return $pruneable; } - /** - * @return CommandTester - */ - private function getCommandTester(KernelInterface $kernel, RewindableGenerator $generator) + private function getCommandTester(KernelInterface $kernel, RewindableGenerator $generator): CommandTester { $application = new Application($kernel); $application->add(new CachePoolPruneCommand($generator)); diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php index 6ca9af76b2424..3b98b0e4cadd3 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php @@ -28,7 +28,7 @@ class FirewallMap implements FirewallMapInterface private $map; private $contexts; - public function __construct(ContainerInterface $container, $map) + public function __construct(ContainerInterface $container, iterable $map) { $this->container = $container; $this->map = $map; diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php index b2dfab96ea278..e4ad1b0daaaa0 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php @@ -35,7 +35,7 @@ class ExceptionController * @param Environment $twig * @param bool $debug Show error (false) or exception (true) pages by default */ - public function __construct(Environment $twig, $debug) + public function __construct(Environment $twig, bool $debug) { $this->twig = $twig; $this->debug = $debug; diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php index 1612b6eb5fec2..7ea0dafe7cbf0 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configurator/EnvironmentConfigurator.php @@ -30,7 +30,7 @@ class EnvironmentConfigurator private $decimalPoint; private $thousandsSeparator; - public function __construct($dateFormat, $intervalFormat, $timezone, $decimals, $decimalPoint, $thousandsSeparator) + public function __construct(string $dateFormat, string $intervalFormat, ?string $timezone, int $decimals, string $decimalPoint, string $thousandsSeparator) { $this->dateFormat = $dateFormat; $this->intervalFormat = $intervalFormat; diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index a938cb01d9e05..ff092c3d199c4 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -31,7 +31,7 @@ class FilesystemLoader extends BaseFilesystemLoader /** * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) */ - public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, $rootPath = null) + public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, string $rootPath = null) { parent::__construct(array(), $rootPath); diff --git a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php index 63f8da549fdd4..1b700a2d36b24 100644 --- a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php +++ b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php @@ -31,7 +31,7 @@ class TemplateIterator implements \IteratorAggregate * @param string $rootDir The directory where global templates can be stored * @param array $paths Additional Twig paths to warm */ - public function __construct(KernelInterface $kernel, $rootDir, array $paths = array()) + public function __construct(KernelInterface $kernel, string $rootDir, array $paths = array()) { $this->kernel = $kernel; $this->rootDir = $rootDir; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php index 3f9d873e1d40f..98536397a18ea 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ExceptionController.php @@ -30,7 +30,7 @@ class ExceptionController protected $debug; protected $profiler; - public function __construct(Profiler $profiler = null, Environment $twig, $debug) + public function __construct(Profiler $profiler = null, Environment $twig, bool $debug) { $this->profiler = $profiler; $this->twig = $twig; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 00ed2f6ba597e..1f6644d5ddc30 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -35,15 +35,7 @@ class ProfilerController private $cspHandler; private $baseDir; - /** - * @param UrlGeneratorInterface $generator The URL Generator - * @param Profiler $profiler The profiler - * @param Environment $twig The twig environment - * @param array $templates The templates - * @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler - * @param string $baseDir The project root directory - */ - public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null) + public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, Environment $twig, array $templates, ContentSecurityPolicyHandler $cspHandler = null, string $baseDir = null) { $this->generator = $generator; $this->profiler = $profiler; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php index 80946ac428c02..685f08d18f381 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/RouterController.php @@ -77,13 +77,8 @@ public function panelAction($token) /** * Returns the routing traces associated to the given request. - * - * @param RequestDataCollector $request - * @param string $method - * - * @return array */ - private function getTraces(RequestDataCollector $request, $method) + private function getTraces(RequestDataCollector $request, string $method): array { $traceRequest = Request::create( $request->getPathInfo(), diff --git a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php index d99f9d5b32d9c..490e16382fe01 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php @@ -43,12 +43,12 @@ class WebDebugToolbarListener implements EventSubscriberInterface protected $excludedAjaxPaths; private $cspHandler; - public function __construct(Environment $twig, $interceptRedirects = false, $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null) + public function __construct(Environment $twig, bool $interceptRedirects = false, int $mode = self::ENABLED, UrlGeneratorInterface $urlGenerator = null, string $excludedAjaxPaths = '^/bundles|^/_wdt', ContentSecurityPolicyHandler $cspHandler = null) { $this->twig = $twig; $this->urlGenerator = $urlGenerator; - $this->interceptRedirects = (bool) $interceptRedirects; - $this->mode = (int) $mode; + $this->interceptRedirects = $interceptRedirects; + $this->mode = $mode; $this->excludedAjaxPaths = $excludedAjaxPaths; $this->cspHandler = $cspHandler; } diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php index 7207a722ce2d0..07f66294e2c16 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php @@ -34,7 +34,7 @@ class ServerRunCommand extends Command protected static $defaultName = 'server:run'; - public function __construct($documentRoot = null, $environment = null) + public function __construct(string $documentRoot = null, string $environment = null) { $this->documentRoot = $documentRoot; $this->environment = $environment; diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php index b0d7886c4aa43..d7316093c55bb 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php @@ -33,7 +33,7 @@ class ServerStartCommand extends Command protected static $defaultName = 'server:start'; - public function __construct($documentRoot = null, $environment = null) + public function __construct(string $documentRoot = null, string $environment = null) { $this->documentRoot = $documentRoot; $this->environment = $environment; diff --git a/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php b/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php index 6c17d110feb01..6f39880083a3f 100644 --- a/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php +++ b/src/Symfony/Bundle/WebServerBundle/WebServerConfig.php @@ -22,7 +22,7 @@ class WebServerConfig private $env; private $router; - public function __construct($documentRoot, $env, $address = null, $router = null) + public function __construct(string $documentRoot, string $env, string $address = null, string $router = null) { if (!is_dir($documentRoot)) { throw new \InvalidArgumentException(sprintf('The document root directory "%s" does not exist.', $documentRoot)); diff --git a/src/Symfony/Component/Asset/PathPackage.php b/src/Symfony/Component/Asset/PathPackage.php index 31cbc5df507f2..1fd9926b31ead 100644 --- a/src/Symfony/Component/Asset/PathPackage.php +++ b/src/Symfony/Component/Asset/PathPackage.php @@ -33,7 +33,7 @@ class PathPackage extends Package * @param VersionStrategyInterface $versionStrategy The version strategy * @param ContextInterface|null $context The context */ - public function __construct($basePath, VersionStrategyInterface $versionStrategy, ContextInterface $context = null) + public function __construct(string $basePath, VersionStrategyInterface $versionStrategy, ContextInterface $context = null) { parent::__construct($versionStrategy, $context); diff --git a/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php b/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php index 378ad54346d7f..7bbfa90786ef9 100644 --- a/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php +++ b/src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php @@ -30,7 +30,7 @@ class JsonManifestVersionStrategy implements VersionStrategyInterface /** * @param string $manifestPath Absolute path to the manifest file */ - public function __construct($manifestPath) + public function __construct(string $manifestPath) { $this->manifestPath = $manifestPath; } diff --git a/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php b/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php index 857cf9432bfa3..e7ce0ec218976 100644 --- a/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php +++ b/src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php @@ -25,7 +25,7 @@ class StaticVersionStrategy implements VersionStrategyInterface * @param string $version Version number * @param string $format Url format */ - public function __construct($version, $format = null) + public function __construct(string $version, string $format = null) { $this->version = $version; $this->format = $format ?: '%s?%s'; diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 23f7ccbff1f9c..9c96a91dc3446 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -272,7 +272,7 @@ public function submit(Form $form, array $values = array()) * * @return Crawler */ - public function request($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) + public function request(string $method, string $uri, array $parameters = array(), array $files = array(), array $server = array(), string $content = null, bool $changeHistory = true) { if ($this->isMainRequest) { $this->redirectCount = 0; diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index e6159da74dc0b..a2201c9ce13df 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -53,7 +53,7 @@ class Cookie * @param bool $httponly The cookie httponly flag * @param bool $encodedValue Whether the value is encoded or not */ - public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false) + public function __construct(string $name, ?string $value, string $expires = null, string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false) { if ($encodedValue) { $this->value = urldecode($value); @@ -65,8 +65,8 @@ public function __construct($name, $value, $expires = null, $path = null, $domai $this->name = $name; $this->path = empty($path) ? '/' : $path; $this->domain = $domain; - $this->secure = (bool) $secure; - $this->httponly = (bool) $httponly; + $this->secure = $secure; + $this->httponly = $httponly; if (null !== $expires) { $timestampAsDateTime = \DateTime::createFromFormat('U', $expires); diff --git a/src/Symfony/Component/BrowserKit/Request.php b/src/Symfony/Component/BrowserKit/Request.php index d78868e539022..d06868660b2d7 100644 --- a/src/Symfony/Component/BrowserKit/Request.php +++ b/src/Symfony/Component/BrowserKit/Request.php @@ -33,7 +33,7 @@ class Request * @param array $server An array of server parameters * @param string $content The raw body data */ - public function __construct($uri, $method, array $parameters = array(), array $files = array(), array $cookies = array(), array $server = array(), $content = null) + public function __construct(string $uri, string $method, array $parameters = array(), array $files = array(), array $cookies = array(), array $server = array(), string $content = null) { $this->uri = $uri; $this->method = $method; diff --git a/src/Symfony/Component/BrowserKit/Response.php b/src/Symfony/Component/BrowserKit/Response.php index ba4e416bf8048..16b2f5bcfe254 100644 --- a/src/Symfony/Component/BrowserKit/Response.php +++ b/src/Symfony/Component/BrowserKit/Response.php @@ -28,7 +28,7 @@ class Response * @param int $status The response status code * @param array $headers An array of headers */ - public function __construct($content = '', $status = 200, array $headers = array()) + public function __construct(string $content = '', int $status = 200, array $headers = array()) { $this->content = $content; $this->status = $status; diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 180275ee60f62..96a41fe235d93 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -224,10 +224,7 @@ public function commit() return $this->pool->commit(); } - /** - * @return \Generator - */ - private function generateItems(array $keys) + private function generateItems(array $keys): \Generator { $f = $this->createCacheItem; $fallbackKeys = array(); diff --git a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php index 62d502f01fd6b..33e08f167fbdc 100644 --- a/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php +++ b/src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php @@ -105,10 +105,7 @@ public function getCalls() return $this->data['instances']['calls']; } - /** - * @return array - */ - private function calculateStatistics() + private function calculateStatistics(): array { $statistics = array(); foreach ($this->data['instances']['calls'] as $name => $calls) { @@ -160,10 +157,7 @@ private function calculateStatistics() return $statistics; } - /** - * @return array - */ - private function calculateTotalStatistics() + private function calculateTotalStatistics(): array { $statistics = $this->getStatistics(); $totals = array( diff --git a/src/Symfony/Component/Cache/Simple/AbstractCache.php b/src/Symfony/Component/Cache/Simple/AbstractCache.php index ae1e61ed86480..51d2d32ba6ed6 100644 --- a/src/Symfony/Component/Cache/Simple/AbstractCache.php +++ b/src/Symfony/Component/Cache/Simple/AbstractCache.php @@ -33,7 +33,7 @@ abstract class AbstractCache implements CacheInterface, LoggerAwareInterface, Re protected function __construct(string $namespace = '', int $defaultLifetime = 0) { - $this->defaultLifetime = max(0, (int) $defaultLifetime); + $this->defaultLifetime = max(0, $defaultLifetime); $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':'; if (null !== $this->maxIdLength && strlen($namespace) > $this->maxIdLength - 24) { throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, strlen($namespace), $namespace)); diff --git a/src/Symfony/Component/Cache/Simple/ArrayCache.php b/src/Symfony/Component/Cache/Simple/ArrayCache.php index 05640dfd17aa9..452b42853ef2c 100644 --- a/src/Symfony/Component/Cache/Simple/ArrayCache.php +++ b/src/Symfony/Component/Cache/Simple/ArrayCache.php @@ -36,7 +36,7 @@ class ArrayCache implements CacheInterface, LoggerAwareInterface, ResettableInte */ public function __construct(int $defaultLifetime = 0, bool $storeSerialized = true) { - $this->defaultLifetime = (int) $defaultLifetime; + $this->defaultLifetime = $defaultLifetime; $this->storeSerialized = $storeSerialized; } diff --git a/src/Symfony/Component/Cache/Simple/ChainCache.php b/src/Symfony/Component/Cache/Simple/ChainCache.php index 05805b91e574a..64cca2e91c246 100644 --- a/src/Symfony/Component/Cache/Simple/ChainCache.php +++ b/src/Symfony/Component/Cache/Simple/ChainCache.php @@ -50,7 +50,7 @@ public function __construct(array $caches, int $defaultLifetime = 0) $this->miss = new \stdClass(); $this->caches = array_values($caches); $this->cacheCount = count($this->caches); - $this->defaultLifetime = 0 < $defaultLifetime ? (int) $defaultLifetime : null; + $this->defaultLifetime = 0 < $defaultLifetime ? $defaultLifetime : null; } /** diff --git a/src/Symfony/Component/Config/ConfigCache.php b/src/Symfony/Component/Config/ConfigCache.php index 591c89bc4ff02..1d00933c839ca 100644 --- a/src/Symfony/Component/Config/ConfigCache.php +++ b/src/Symfony/Component/Config/ConfigCache.php @@ -31,9 +31,9 @@ class ConfigCache extends ResourceCheckerConfigCache * @param string $file The absolute cache path * @param bool $debug Whether debugging is enabled or not */ - public function __construct($file, $debug) + public function __construct(string $file, bool $debug) { - $this->debug = (bool) $debug; + $this->debug = $debug; $checkers = array(); if (true === $this->debug) { diff --git a/src/Symfony/Component/Config/ConfigCacheFactory.php b/src/Symfony/Component/Config/ConfigCacheFactory.php index 06dbe6c2947ed..e43e1a190be13 100644 --- a/src/Symfony/Component/Config/ConfigCacheFactory.php +++ b/src/Symfony/Component/Config/ConfigCacheFactory.php @@ -27,7 +27,7 @@ class ConfigCacheFactory implements ConfigCacheFactoryInterface /** * @param bool $debug The debug flag to pass to ConfigCache */ - public function __construct($debug) + public function __construct(bool $debug) { $this->debug = $debug; } diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index ec927e0a97344..d082a6e8d2c8d 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -34,12 +34,9 @@ abstract class BaseNode implements NodeInterface protected $attributes = array(); /** - * @param string $name The name of the node - * @param NodeInterface $parent The parent of this node - * * @throws \InvalidArgumentException if the name contains a period */ - public function __construct($name, NodeInterface $parent = null) + public function __construct(?string $name, NodeInterface $parent = null) { if (false !== strpos($name, '.')) { throw new \InvalidArgumentException('The name must not contain ".".'); diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index c8d929e95149e..9a79747bfece6 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -39,7 +39,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition /** * {@inheritdoc} */ - public function __construct($name, NodeParentInterface $parent = null) + public function __construct(?string $name, NodeParentInterface $parent = null) { parent::__construct($name, $parent); diff --git a/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php index 28e56579ada52..0504d13ec2485 100644 --- a/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php @@ -24,7 +24,7 @@ class BooleanNodeDefinition extends ScalarNodeDefinition /** * {@inheritdoc} */ - public function __construct($name, NodeParentInterface $parent = null) + public function __construct(?string $name, NodeParentInterface $parent = null) { parent::__construct($name, $parent); diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 4539b316bf96e..6284edfc787af 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -36,11 +36,7 @@ abstract class NodeDefinition implements NodeParentInterface protected $parent; protected $attributes = array(); - /** - * @param string $name The name of the node - * @param NodeParentInterface|null $parent The parent - */ - public function __construct($name, NodeParentInterface $parent = null) + public function __construct(?string $name, NodeParentInterface $parent = null) { $this->parent = $parent; $this->name = $name; diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index f78bc7c3a258b..b87acc93d4c7c 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -41,13 +41,7 @@ public function dumpNode(NodeInterface $node, $namespace = null) return $ref; } - /** - * @param NodeInterface $node - * @param int $depth - * @param bool $root If the node is the root node - * @param string $namespace The namespace of the node - */ - private function writeNode(NodeInterface $node, $depth = 0, $root = false, $namespace = null) + private function writeNode(NodeInterface $node, int $depth = 0, bool $root = false, string $namespace = null) { $rootName = ($root ? 'config' : $node->getName()); $rootNamespace = ($namespace ?: ($root ? 'http://example.org/schema/dic/'.$node->getName() : null)); @@ -259,11 +253,8 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name /** * Outputs a single config reference line. - * - * @param string $text - * @param int $indent */ - private function writeLine($text, $indent = 0) + private function writeLine(string $text, int $indent = 0) { $indent = strlen($text) + $indent; $format = '%'.$indent.'s'; @@ -275,10 +266,8 @@ private function writeLine($text, $indent = 0) * Renders the string conversion of the value. * * @param mixed $value - * - * @return string */ - private function writeValue($value) + private function writeValue($value): string { if ('%%%%not_defined%%%%' === $value) { return ''; diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index 5a0e76c5255a3..960d136231079 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -69,13 +69,7 @@ public function dumpNode(NodeInterface $node) return $ref; } - /** - * @param NodeInterface $node - * @param NodeInterface|null $parentNode - * @param int $depth - * @param bool $prototypedArray - */ - private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, $depth = 0, $prototypedArray = false) + private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, int $depth = 0, bool $prototypedArray = false) { $comments = array(); $default = ''; @@ -179,11 +173,8 @@ private function writeNode(NodeInterface $node, NodeInterface $parentNode = null /** * Outputs a single config reference line. - * - * @param string $text - * @param int $indent */ - private function writeLine($text, $indent = 0) + private function writeLine(string $text, int $indent = 0) { $indent = strlen($text) + $indent; $format = '%'.$indent.'s'; @@ -214,12 +205,7 @@ private function writeArray(array $array, $depth) } } - /** - * @param PrototypedArrayNode $node - * - * @return array - */ - private function getPrototypeChildren(PrototypedArrayNode $node) + private function getPrototypeChildren(PrototypedArrayNode $node): array { $prototype = $node->getPrototype(); $key = $node->getKeyAttribute(); diff --git a/src/Symfony/Component/Config/Definition/EnumNode.php b/src/Symfony/Component/Config/Definition/EnumNode.php index 9b4c4156e311e..e8821cf51a6e6 100644 --- a/src/Symfony/Component/Config/Definition/EnumNode.php +++ b/src/Symfony/Component/Config/Definition/EnumNode.php @@ -22,7 +22,7 @@ class EnumNode extends ScalarNode { private $values; - public function __construct($name, NodeInterface $parent = null, array $values = array()) + public function __construct(string $name, NodeInterface $parent = null, array $values = array()) { $values = array_unique($values); if (empty($values)) { diff --git a/src/Symfony/Component/Config/Definition/NumericNode.php b/src/Symfony/Component/Config/Definition/NumericNode.php index 439935e4559f8..d51f0035ebcba 100644 --- a/src/Symfony/Component/Config/Definition/NumericNode.php +++ b/src/Symfony/Component/Config/Definition/NumericNode.php @@ -23,7 +23,7 @@ class NumericNode extends ScalarNode protected $min; protected $max; - public function __construct($name, NodeInterface $parent = null, $min = null, $max = null) + public function __construct(?string $name, NodeInterface $parent = null, $min = null, $max = null) { parent::__construct($name, $parent); $this->min = $min; diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 08f335a015f30..c576198b54089 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -371,11 +371,9 @@ protected function mergeValues($leftSide, $rightSide) * Now, the key becomes 'name001' and the child node becomes 'value001' and * the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance. * - * @param string $key The key of the child node - * * @return mixed The prototype instance */ - private function getPrototypeForChild($key) + private function getPrototypeForChild(string $key) { $prototype = isset($this->valuePrototypes[$key]) ? $this->valuePrototypes[$key] : $this->prototype; $prototype->setName($key); diff --git a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php index 6a3b01cfbe097..d75860ecf0086 100644 --- a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php +++ b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php @@ -18,7 +18,7 @@ */ class FileLoaderImportCircularReferenceException extends FileLoaderLoadException { - public function __construct(array $resources, $code = null, $previous = null) + public function __construct(array $resources, int $code = null, \Exception $previous = null) { $message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]); diff --git a/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php b/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php index a19069a6aeb0e..62e56622f3d4a 100644 --- a/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php +++ b/src/Symfony/Component/Config/Exception/FileLoaderLoadException.php @@ -25,7 +25,7 @@ class FileLoaderLoadException extends \Exception * @param \Exception $previous A previous exception * @param string $type The type of resource */ - public function __construct($resource, $sourceResource = null, $code = null, $previous = null, $type = null) + public function __construct(string $resource, string $sourceResource = null, int $code = null, \Exception $previous = null, string $type = null) { $message = ''; if ($previous) { diff --git a/src/Symfony/Component/Config/Exception/FileLocatorFileNotFoundException.php b/src/Symfony/Component/Config/Exception/FileLocatorFileNotFoundException.php index af764eb4718d8..09b71606732d7 100644 --- a/src/Symfony/Component/Config/Exception/FileLocatorFileNotFoundException.php +++ b/src/Symfony/Component/Config/Exception/FileLocatorFileNotFoundException.php @@ -20,7 +20,7 @@ class FileLocatorFileNotFoundException extends \InvalidArgumentException { private $paths; - public function __construct($message = '', $code = 0, $previous = null, array $paths = array()) + public function __construct(string $message = '', int $code = 0, \Exception $previous = null, array $paths = array()) { parent::__construct($message, $code, $previous); diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index f5593cbbe2550..a3e8fd1104377 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -23,7 +23,7 @@ class FileLocator implements FileLocatorInterface protected $paths; /** - * @param string|array $paths A path or an array of paths where to look for resources + * @param string|string[] $paths A path or an array of paths where to look for resources */ public function __construct($paths = array()) { diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index e3fd095b6008d..a4dd74b1f9db5 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -32,12 +32,10 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ * @param string $resource The fully-qualified class name * @param bool|null $exists Boolean when the existency check has already been done */ - public function __construct($resource, $exists = null) + public function __construct(string $resource, bool $exists = null) { $this->resource = $resource; - if (null !== $exists) { - $this->exists = (bool) $exists; - } + $this->exists = $exists; } /** diff --git a/src/Symfony/Component/Config/Resource/DirectoryResource.php b/src/Symfony/Component/Config/Resource/DirectoryResource.php index b1786397d1865..b6d1f9a24a863 100644 --- a/src/Symfony/Component/Config/Resource/DirectoryResource.php +++ b/src/Symfony/Component/Config/Resource/DirectoryResource.php @@ -27,7 +27,7 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable * * @throws \InvalidArgumentException */ - public function __construct($resource, $pattern = null) + public function __construct(string $resource, string $pattern = null) { $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false); $this->pattern = $pattern; diff --git a/src/Symfony/Component/Config/Resource/FileExistenceResource.php b/src/Symfony/Component/Config/Resource/FileExistenceResource.php index 6396ddd524852..a4eb8f354449e 100644 --- a/src/Symfony/Component/Config/Resource/FileExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/FileExistenceResource.php @@ -28,9 +28,9 @@ class FileExistenceResource implements SelfCheckingResourceInterface, \Serializa /** * @param string $resource The file path to the resource */ - public function __construct($resource) + public function __construct(string $resource) { - $this->resource = (string) $resource; + $this->resource = $resource; $this->exists = file_exists($resource); } diff --git a/src/Symfony/Component/Config/Resource/FileResource.php b/src/Symfony/Component/Config/Resource/FileResource.php index 5d71d87918c8f..8fa97162d4de7 100644 --- a/src/Symfony/Component/Config/Resource/FileResource.php +++ b/src/Symfony/Component/Config/Resource/FileResource.php @@ -30,7 +30,7 @@ class FileResource implements SelfCheckingResourceInterface, \Serializable * * @throws \InvalidArgumentException */ - public function __construct($resource) + public function __construct(string $resource) { $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false); diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index 1edd7cd22e44a..c188f80ce4eca 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -35,7 +35,7 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface, * * @throws \InvalidArgumentException */ - public function __construct($prefix, $pattern, $recursive) + public function __construct(?string $prefix, string $pattern, bool $recursive) { $this->prefix = realpath($prefix) ?: (file_exists($prefix) ? $prefix : false); $this->pattern = $pattern; diff --git a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php index b65991a0b755a..35cdcc4c1c2c7 100644 --- a/src/Symfony/Component/Config/Resource/ReflectionClassResource.php +++ b/src/Symfony/Component/Config/Resource/ReflectionClassResource.php @@ -22,7 +22,7 @@ class ReflectionClassResource implements SelfCheckingResourceInterface, \Seriali private $excludedVendors = array(); private $hash; - public function __construct(\ReflectionClass $classReflector, $excludedVendors = array()) + public function __construct(\ReflectionClass $classReflector, array $excludedVendors = array()) { $this->className = $classReflector->name; $this->classReflector = $classReflector; diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php index 10257d5dd4f1b..d22ec5f0f588a 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php @@ -37,7 +37,7 @@ class ResourceCheckerConfigCache implements ConfigCacheInterface * @param string $file The absolute cache path * @param iterable|ResourceCheckerInterface[] $resourceCheckers The ResourceCheckers to use for the freshness check */ - public function __construct($file, $resourceCheckers = array()) + public function __construct(string $file, iterable $resourceCheckers = array()) { $this->file = $file; $this->resourceCheckers = $resourceCheckers; diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php b/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php index 2493f34663e75..845eabdee8764 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php @@ -24,7 +24,7 @@ class ResourceCheckerConfigCacheFactory implements ConfigCacheFactoryInterface /** * @param iterable|ResourceCheckerInterface[] $resourceCheckers */ - public function __construct($resourceCheckers = array()) + public function __construct(iterable $resourceCheckers = array()) { $this->resourceCheckers = $resourceCheckers; } diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index bca5883baeac5..6fe7692d3eed7 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -79,7 +79,7 @@ class Application * @param string $name The name of the application * @param string $version The version of the application */ - public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') + public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN') { $this->name = $name; $this->version = $version; diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index fec96dba2c5bc..f42ee945f5111 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -66,7 +66,7 @@ public static function getDefaultName() * * @throws LogicException When the command name is empty */ - public function __construct($name = null) + public function __construct(string $name = null) { $this->definition = new InputDefinition(); @@ -636,11 +636,9 @@ public function getHelper($name) * * It must be non-empty and parts can optionally be separated by ":". * - * @param string $name - * * @throws InvalidArgumentException When the name is invalid */ - private function validateName($name) + private function validateName(string $name) { if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); diff --git a/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php b/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php index 39d53ef8e37d3..18452d419fa44 100644 --- a/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php +++ b/src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php @@ -29,7 +29,7 @@ class AddConsoleCommandPass implements CompilerPassInterface private $commandLoaderServiceId; private $commandTag; - public function __construct($commandLoaderServiceId = 'console.command_loader', $commandTag = 'console.command') + public function __construct(string $commandLoaderServiceId = 'console.command_loader', string $commandTag = 'console.command') { $this->commandLoaderServiceId = $commandLoaderServiceId; $this->commandTag = $commandTag; diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index ef4c673b7bcf3..5d34778621774 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -43,12 +43,7 @@ class ApplicationDescription */ private $aliases; - /** - * @param Application $application - * @param string|null $namespace - * @param bool $showHidden - */ - public function __construct(Application $application, $namespace = null, $showHidden = false) + public function __construct(Application $application, string $namespace = null, bool $showHidden = false) { $this->application = $application; $this->namespace = $namespace; @@ -123,10 +118,7 @@ private function inspectApplication() } } - /** - * @return array - */ - private function sortCommands(array $commands) + private function sortCommands(array $commands): array { $namespacedCommands = array(); $globalCommands = array(); diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index a79df7e230d85..ac848184c0323 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -252,10 +252,8 @@ private function writeText($content, array $options = array()) /** * Formats command aliases to show them in the command description. - * - * @return string */ - private function getCommandAliasesText(Command $command) + private function getCommandAliasesText(Command $command): string { $text = ''; $aliases = $command->getAliases(); @@ -271,10 +269,8 @@ private function getCommandAliasesText(Command $command) * Formats input option/argument default value. * * @param mixed $default - * - * @return string */ - private function formatDefaultValue($default) + private function formatDefaultValue($default): string { if (INF === $default) { return 'INF'; @@ -295,10 +291,8 @@ private function formatDefaultValue($default) /** * @param (Command|string)[] $commands - * - * @return int */ - private function getColumnWidth(array $commands) + private function getColumnWidth(array $commands): int { $widths = array(); @@ -318,10 +312,8 @@ private function getColumnWidth(array $commands) /** * @param InputOption[] $options - * - * @return int */ - private function calculateTotalWidthForOptions(array $options) + private function calculateTotalWidthForOptions(array $options): int { $totalWidth = 0; foreach ($options as $option) { diff --git a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php index f05756ca309da..0d239868c4c99 100644 --- a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php @@ -188,10 +188,7 @@ private function writeDocument(\DOMDocument $dom) $this->write($dom->saveXML()); } - /** - * @return \DOMDocument - */ - private function getInputArgumentDocument(InputArgument $argument) + private function getInputArgumentDocument(InputArgument $argument): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); @@ -212,10 +209,7 @@ private function getInputArgumentDocument(InputArgument $argument) return $dom; } - /** - * @return \DOMDocument - */ - private function getInputOptionDocument(InputOption $option) + private function getInputOptionDocument(InputOption $option): \DOMDocument { $dom = new \DOMDocument('1.0', 'UTF-8'); diff --git a/src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php b/src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php index b6a5d7c0dc48c..ff0c749d1dc3a 100644 --- a/src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php +++ b/src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php @@ -22,14 +22,9 @@ */ class ConsoleTerminateEvent extends ConsoleEvent { - /** - * The exit code of the command. - * - * @var int - */ private $exitCode; - public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode) + public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $exitCode) { parent::__construct($command, $input, $output); diff --git a/src/Symfony/Component/Console/Exception/CommandNotFoundException.php b/src/Symfony/Component/Console/Exception/CommandNotFoundException.php index cb7d1131fa776..2f6e644b99a9c 100644 --- a/src/Symfony/Component/Console/Exception/CommandNotFoundException.php +++ b/src/Symfony/Component/Console/Exception/CommandNotFoundException.php @@ -26,7 +26,7 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce * @param int $code Exception code * @param \Exception $previous Previous exception used for the exception chaining */ - public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null) + public function __construct(string $message, array $alternatives = array(), int $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 63d8e8ce3b9fd..a78bd952051c7 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -65,9 +65,9 @@ public static function escapeTrailingBackslash($text) * @param bool $decorated Whether this formatter should actually decorate strings * @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances */ - public function __construct($decorated = false, array $styles = array()) + public function __construct(bool $decorated = false, array $styles = array()) { - $this->decorated = (bool) $decorated; + $this->decorated = $decorated; $this->setStyle('error', new OutputFormatterStyle('white', 'red')); $this->setStyle('info', new OutputFormatterStyle('green')); @@ -186,11 +186,9 @@ public function getStyleStack() /** * Tries to create new style instance from string. * - * @param string $string - * - * @return OutputFormatterStyle|false false if string is not format string + * @return OutputFormatterStyle|false False if string is not format string */ - private function createStyleFromString($string) + private function createStyleFromString(string $string) { if (isset($this->styles[$string])) { return $this->styles[$string]; @@ -224,12 +222,8 @@ private function createStyleFromString($string) /** * Applies current style from stack to text, if must be applied. - * - * @param string $text Input text - * - * @return string Styled text */ - private function applyCurrentStyle($text) + private function applyCurrentStyle(string $text): string { return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text; } diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php index 7ada54f4c11b9..900f2ef31b058 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php @@ -61,7 +61,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface * @param string|null $background The style background color name * @param array $options The style options */ - public function __construct($foreground = null, $background = null, array $options = array()) + public function __construct(string $foreground = null, string $background = null, array $options = array()) { if (null !== $foreground) { $this->setForeground($foreground); diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 1534fd6c2cfa0..7c0c09a97d375 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -272,8 +272,6 @@ public function advance(int $step = 1) /** * Sets whether to overwrite the progressbar, false for new line. - * - * @param bool $overwrite */ public function setOverwrite(bool $overwrite) { @@ -372,8 +370,6 @@ private function setMaxSteps(int $max) /** * Overwrites a previous message to the output. - * - * @param string $message The message */ private function overwrite(string $message): void { diff --git a/src/Symfony/Component/Console/Helper/ProgressIndicator.php b/src/Symfony/Component/Console/Helper/ProgressIndicator.php index d441accd46e11..e6094647fa312 100644 --- a/src/Symfony/Component/Console/Helper/ProgressIndicator.php +++ b/src/Symfony/Component/Console/Helper/ProgressIndicator.php @@ -39,7 +39,7 @@ class ProgressIndicator * @param int $indicatorChangeInterval Change interval in milliseconds * @param array|null $indicatorValues Animated indicator characters */ - public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null) + public function __construct(OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null) { $this->output = $output; @@ -219,10 +219,8 @@ private function determineBestFormat() /** * Overwrites a previous message to the output. - * - * @param string $message The message */ - private function overwrite($message) + private function overwrite(string $message) { if ($this->output->isDecorated()) { $this->output->write("\x0D\x1B[2K"); diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index c4201932d5c9e..ddfddd6fcdd1e 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -170,10 +170,8 @@ protected function writeError(OutputInterface $output, \Exception $error) * @param OutputInterface $output * @param Question $question * @param resource $inputStream - * - * @return string */ - private function autocomplete(OutputInterface $output, Question $question, $inputStream) + private function autocomplete(OutputInterface $output, Question $question, $inputStream): string { $autocomplete = $question->getAutocompleterValues(); $ret = ''; @@ -289,11 +287,9 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu * @param OutputInterface $output An Output instance * @param resource $inputStream The handler resource * - * @return string The answer - * * @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden */ - private function getHiddenResponse(OutputInterface $output, $inputStream) + private function getHiddenResponse(OutputInterface $output, $inputStream): string { if ('\\' === DIRECTORY_SEPARATOR) { $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; @@ -404,10 +400,8 @@ private function getShell() /** * Returns whether Stty is available or not. - * - * @return bool */ - private function hasSttyAvailable() + private function hasSttyAvailable(): bool { if (null !== self::$stty) { return self::$stty; diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index b4db5bdb4f0b0..6e5820e405a9d 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -335,11 +335,8 @@ private function renderColumnSeparator() * Renders table row. * * Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | - * - * @param array $row - * @param string $cellFormat */ - private function renderRow(array $row, $cellFormat) + private function renderRow(array $row, string $cellFormat) { if (empty($row)) { return; @@ -355,12 +352,8 @@ private function renderRow(array $row, $cellFormat) /** * Renders table cell with padding. - * - * @param array $row - * @param int $column - * @param string $cellFormat */ - private function renderCell(array $row, $column, $cellFormat) + private function renderCell(array $row, int $column, string $cellFormat) { $cell = isset($row[$column]) ? $row[$column] : ''; $width = $this->effectiveColumnWidths[$column]; @@ -447,13 +440,8 @@ private function buildTableRows($rows) /** * fill rows that contains rowspan > 1. - * - * @param array $rows - * @param int $line - * - * @return array */ - private function fillNextRows(array $rows, $line) + private function fillNextRows(array $rows, int $line): array { $unmergedRows = array(); foreach ($rows[$line] as $column => $cell) { @@ -503,8 +491,6 @@ private function fillNextRows(array $rows, $line) /** * fill cells for a row that contains colspan > 1. - * - * @return array */ private function fillCells($row) { @@ -522,13 +508,7 @@ private function fillCells($row) return $newRow ?: $row; } - /** - * @param array $rows - * @param int $line - * - * @return array - */ - private function copyRow(array $rows, $line) + private function copyRow(array $rows, int $line): array { $row = $rows[$line]; foreach ($row as $cellKey => $cellValue) { @@ -543,10 +523,8 @@ private function copyRow(array $rows, $line) /** * Gets number of columns by row. - * - * @return int */ - private function getNumberOfColumns(array $row) + private function getNumberOfColumns(array $row): int { $columns = count($row); foreach ($row as $column) { @@ -558,10 +536,8 @@ private function getNumberOfColumns(array $row) /** * Gets list of columns for the given row. - * - * @return array */ - private function getRowColumns(array $row) + private function getRowColumns(array $row): array { $columns = range(0, $this->numberOfColumns - 1); foreach ($row as $cellKey => $cell) { @@ -606,25 +582,12 @@ private function calculateColumnsWidth(array $rows) } } - /** - * Gets column width. - * - * @return int - */ - private function getColumnSeparatorWidth() + private function getColumnSeparatorWidth(): int { return strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar())); } - /** - * Gets cell width. - * - * @param array $row - * @param int $column - * - * @return int - */ - private function getCellWidth(array $row, $column) + private function getCellWidth(array $row, int $column): int { $cellWidth = 0; diff --git a/src/Symfony/Component/Console/Helper/TableCell.php b/src/Symfony/Component/Console/Helper/TableCell.php index 6fc7d3b913b62..f800fb44e30d4 100644 --- a/src/Symfony/Component/Console/Helper/TableCell.php +++ b/src/Symfony/Component/Console/Helper/TableCell.php @@ -24,16 +24,8 @@ class TableCell 'colspan' => 1, ); - /** - * @param string $value - * @param array $options - */ - public function __construct($value = '', array $options = array()) + public function __construct(string $value = '', array $options = array()) { - if (is_numeric($value) && !is_string($value)) { - $value = (string) $value; - } - $this->value = $value; // check option names diff --git a/src/Symfony/Component/Console/Input/InputArgument.php b/src/Symfony/Component/Console/Input/InputArgument.php index a969d2c5adc0a..b5cbbaf1b476e 100644 --- a/src/Symfony/Component/Console/Input/InputArgument.php +++ b/src/Symfony/Component/Console/Input/InputArgument.php @@ -38,11 +38,11 @@ class InputArgument * * @throws InvalidArgumentException When argument mode is not valid */ - public function __construct($name, $mode = null, $description = '', $default = null) + public function __construct(string $name, int $mode = null, string $description = '', $default = null) { if (null === $mode) { $mode = self::OPTIONAL; - } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { + } elseif ($mode > 7 || $mode < 1) { throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); } diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 3af8077c94b81..e4c855cae1706 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -41,7 +41,7 @@ class InputOption * * @throws InvalidArgumentException If option mode is invalid or incompatible */ - public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) + public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) { if (0 === strpos($name, '--')) { $name = substr($name, 2); @@ -70,7 +70,7 @@ public function __construct($name, $shortcut = null, $mode = null, $description if (null === $mode) { $mode = self::VALUE_NONE; - } elseif (!is_int($mode) || $mode > 15 || $mode < 1) { + } elseif ($mode > 15 || $mode < 1) { throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); } diff --git a/src/Symfony/Component/Console/Input/StringInput.php b/src/Symfony/Component/Console/Input/StringInput.php index d3630fc0d6157..f773402839e83 100644 --- a/src/Symfony/Component/Console/Input/StringInput.php +++ b/src/Symfony/Component/Console/Input/StringInput.php @@ -30,7 +30,7 @@ class StringInput extends ArgvInput /** * @param string $input An array of parameters from the CLI (in the argv format) */ - public function __construct($input) + public function __construct(string $input) { parent::__construct(array()); diff --git a/src/Symfony/Component/Console/Logger/ConsoleLogger.php b/src/Symfony/Component/Console/Logger/ConsoleLogger.php index 05dd3b966ee62..9f07e1fb03f4c 100644 --- a/src/Symfony/Component/Console/Logger/ConsoleLogger.php +++ b/src/Symfony/Component/Console/Logger/ConsoleLogger.php @@ -99,13 +99,8 @@ public function hasErrored() * Interpolates context values into the message placeholders. * * @author PHP Framework Interoperability Group - * - * @param string $message - * @param array $context - * - * @return string */ - private function interpolate($message, array $context) + private function interpolate(string $message, array $context): string { if (false === strpos($message, '{')) { return $message; diff --git a/src/Symfony/Component/Console/Output/ConsoleOutput.php b/src/Symfony/Component/Console/Output/ConsoleOutput.php index edef356c4e2bf..cff6cd5a4a420 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutput.php @@ -36,7 +36,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ - public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) + public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) { parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); diff --git a/src/Symfony/Component/Console/Output/Output.php b/src/Symfony/Component/Console/Output/Output.php index 371735e142c80..20635a5f730d3 100644 --- a/src/Symfony/Component/Console/Output/Output.php +++ b/src/Symfony/Component/Console/Output/Output.php @@ -37,7 +37,7 @@ abstract class Output implements OutputInterface * @param bool $decorated Whether to decorate messages * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) */ - public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null) + public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) { $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; $this->formatter = $formatter ?: new OutputFormatter(); diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index 51cad9b176a08..e0ade2482db5c 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -40,7 +40,7 @@ class StreamOutput extends Output * * @throws InvalidArgumentException When first argument is not a real stream */ - public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) + public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) { if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) { throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); diff --git a/src/Symfony/Component/Console/Question/ChoiceQuestion.php b/src/Symfony/Component/Console/Question/ChoiceQuestion.php index 46cc72a368ee7..b66f2c685bf10 100644 --- a/src/Symfony/Component/Console/Question/ChoiceQuestion.php +++ b/src/Symfony/Component/Console/Question/ChoiceQuestion.php @@ -30,7 +30,7 @@ class ChoiceQuestion extends Question * @param array $choices The list of available choices * @param mixed $default The default answer to return */ - public function __construct($question, array $choices, $default = null) + public function __construct(string $question, array $choices, $default = null) { if (!$choices) { throw new \LogicException('Choice question must have at least 1 choice available.'); @@ -121,12 +121,7 @@ public function setErrorMessage($errorMessage) return $this; } - /** - * Returns the default answer validator. - * - * @return callable - */ - private function getDefaultValidator() + private function getDefaultValidator(): callable { $choices = $this->choices; $errorMessage = $this->errorMessage; diff --git a/src/Symfony/Component/Console/Question/ConfirmationQuestion.php b/src/Symfony/Component/Console/Question/ConfirmationQuestion.php index 40f54b4e9b8d8..7a15e5afb5ae9 100644 --- a/src/Symfony/Component/Console/Question/ConfirmationQuestion.php +++ b/src/Symfony/Component/Console/Question/ConfirmationQuestion.php @@ -25,9 +25,9 @@ class ConfirmationQuestion extends Question * @param bool $default The default answer to return, true or false * @param string $trueAnswerRegex A regex to match the "yes" answer */ - public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') + public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i') { - parent::__construct($question, (bool) $default); + parent::__construct($question, $default); $this->trueAnswerRegex = $trueAnswerRegex; $this->setNormalizer($this->getDefaultNormalizer()); diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 302e3d77588cf..4f9f3c46d5f9a 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -34,7 +34,7 @@ class Question * @param string $question The question to ask to the user * @param mixed $default The default answer to return if the user enters nothing */ - public function __construct($question, $default = null) + public function __construct(string $question, $default = null) { $this->question = $question; $this->default = $default; diff --git a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php index 66af98b33b666..881300c2576f3 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php @@ -38,26 +38,12 @@ public function testModes() } /** - * @dataProvider provideInvalidModes + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Argument mode "-1" is not valid. */ - public function testInvalidModes($mode) + public function testInvalidModes() { - if (method_exists($this, 'expectException')) { - $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage(sprintf('Argument mode "%s" is not valid.', $mode)); - } else { - $this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode)); - } - - new InputArgument('foo', $mode); - } - - public function provideInvalidModes() - { - return array( - array('ANOTHER_ONE'), - array(-1), - ); + new InputArgument('foo', '-1'); } public function testIsArray() diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index 943bf607f5e5a..66a6dd5ac32f9 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -74,26 +74,12 @@ public function testModes() } /** - * @dataProvider provideInvalidModes + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Option mode "-1" is not valid. */ - public function testInvalidModes($mode) - { - if (method_exists($this, 'expectException')) { - $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage(sprintf('Option mode "%s" is not valid.', $mode)); - } else { - $this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode)); - } - - new InputOption('foo', 'f', $mode); - } - - public function provideInvalidModes() + public function testInvalidModes() { - return array( - array('ANOTHER_ONE'), - array(-1), - ); + new InputOption('foo', 'f', '-1'); } /** diff --git a/src/Symfony/Component/CssSelector/CssSelectorConverter.php b/src/Symfony/Component/CssSelector/CssSelectorConverter.php index 8d66dbd0e18f2..d1aeb7eb1702e 100644 --- a/src/Symfony/Component/CssSelector/CssSelectorConverter.php +++ b/src/Symfony/Component/CssSelector/CssSelectorConverter.php @@ -31,7 +31,7 @@ class CssSelectorConverter /** * @param bool $html Whether HTML support should be enabled. Disable it for XML documents */ - public function __construct($html = true) + public function __construct(bool $html = true) { $this->translator = new Translator(); diff --git a/src/Symfony/Component/CssSelector/Node/AttributeNode.php b/src/Symfony/Component/CssSelector/Node/AttributeNode.php index 2c1005b7c3967..bf702d9ce44e4 100644 --- a/src/Symfony/Component/CssSelector/Node/AttributeNode.php +++ b/src/Symfony/Component/CssSelector/Node/AttributeNode.php @@ -29,14 +29,7 @@ class AttributeNode extends AbstractNode private $operator; private $value; - /** - * @param NodeInterface $selector - * @param string $namespace - * @param string $attribute - * @param string $operator - * @param string $value - */ - public function __construct(NodeInterface $selector, $namespace, $attribute, $operator, $value) + public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value) { $this->selector = $selector; $this->namespace = $namespace; @@ -45,42 +38,27 @@ public function __construct(NodeInterface $selector, $namespace, $attribute, $op $this->value = $value; } - /** - * @return NodeInterface - */ - public function getSelector() + public function getSelector(): NodeInterface { return $this->selector; } - /** - * @return string - */ - public function getNamespace() + public function getNamespace(): ?string { return $this->namespace; } - /** - * @return string - */ - public function getAttribute() + public function getAttribute(): string { return $this->attribute; } - /** - * @return string - */ - public function getOperator() + public function getOperator(): string { return $this->operator; } - /** - * @return string - */ - public function getValue() + public function getValue(): ?string { return $this->value; } diff --git a/src/Symfony/Component/CssSelector/Node/ClassNode.php b/src/Symfony/Component/CssSelector/Node/ClassNode.php index 1c5d6f1a00e07..1998b4bd5b0ec 100644 --- a/src/Symfony/Component/CssSelector/Node/ClassNode.php +++ b/src/Symfony/Component/CssSelector/Node/ClassNode.php @@ -26,28 +26,18 @@ class ClassNode extends AbstractNode private $selector; private $name; - /** - * @param NodeInterface $selector - * @param string $name - */ - public function __construct(NodeInterface $selector, $name) + public function __construct(NodeInterface $selector, string $name) { $this->selector = $selector; $this->name = $name; } - /** - * @return NodeInterface - */ - public function getSelector() + public function getSelector(): NodeInterface { return $this->selector; } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } diff --git a/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php b/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php index d55b5306feff4..f97fd21aebba7 100644 --- a/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php +++ b/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php @@ -27,38 +27,24 @@ class CombinedSelectorNode extends AbstractNode private $combinator; private $subSelector; - /** - * @param NodeInterface $selector - * @param string $combinator - * @param NodeInterface $subSelector - */ - public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector) + public function __construct(NodeInterface $selector, string $combinator, NodeInterface $subSelector) { $this->selector = $selector; $this->combinator = $combinator; $this->subSelector = $subSelector; } - /** - * @return NodeInterface - */ - public function getSelector() + public function getSelector(): NodeInterface { return $this->selector; } - /** - * @return string - */ - public function getCombinator() + public function getCombinator(): string { return $this->combinator; } - /** - * @return NodeInterface - */ - public function getSubSelector() + public function getSubSelector(): NodeInterface { return $this->subSelector; } diff --git a/src/Symfony/Component/CssSelector/Node/ElementNode.php b/src/Symfony/Component/CssSelector/Node/ElementNode.php index 048acc2746d34..7d405b31f77ce 100644 --- a/src/Symfony/Component/CssSelector/Node/ElementNode.php +++ b/src/Symfony/Component/CssSelector/Node/ElementNode.php @@ -30,7 +30,7 @@ class ElementNode extends AbstractNode * @param string|null $namespace * @param string|null $element */ - public function __construct($namespace = null, $element = null) + public function __construct(string $namespace = null, string $element = null) { $this->namespace = $namespace; $this->element = $element; diff --git a/src/Symfony/Component/CssSelector/Node/FunctionNode.php b/src/Symfony/Component/CssSelector/Node/FunctionNode.php index 72e4a02d7fceb..89b6437801d82 100644 --- a/src/Symfony/Component/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -34,25 +34,19 @@ class FunctionNode extends AbstractNode * @param string $name * @param Token[] $arguments */ - public function __construct(NodeInterface $selector, $name, array $arguments = array()) + public function __construct(NodeInterface $selector, string $name, array $arguments = array()) { $this->selector = $selector; $this->name = strtolower($name); $this->arguments = $arguments; } - /** - * @return NodeInterface - */ - public function getSelector() + public function getSelector(): NodeInterface { return $this->selector; } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } diff --git a/src/Symfony/Component/CssSelector/Node/HashNode.php b/src/Symfony/Component/CssSelector/Node/HashNode.php index 6c72012626703..f73fa2e7402bd 100644 --- a/src/Symfony/Component/CssSelector/Node/HashNode.php +++ b/src/Symfony/Component/CssSelector/Node/HashNode.php @@ -26,28 +26,18 @@ class HashNode extends AbstractNode private $selector; private $id; - /** - * @param NodeInterface $selector - * @param string $id - */ - public function __construct(NodeInterface $selector, $id) + public function __construct(NodeInterface $selector, string $id) { $this->selector = $selector; $this->id = $id; } - /** - * @return NodeInterface - */ - public function getSelector() + public function getSelector(): NodeInterface { return $this->selector; } - /** - * @return string - */ - public function getId() + public function getId(): string { return $this->id; } diff --git a/src/Symfony/Component/CssSelector/Node/PseudoNode.php b/src/Symfony/Component/CssSelector/Node/PseudoNode.php index afc32f82c3d6d..7d4a011e1faf3 100644 --- a/src/Symfony/Component/CssSelector/Node/PseudoNode.php +++ b/src/Symfony/Component/CssSelector/Node/PseudoNode.php @@ -26,28 +26,18 @@ class PseudoNode extends AbstractNode private $selector; private $identifier; - /** - * @param NodeInterface $selector - * @param string $identifier - */ - public function __construct(NodeInterface $selector, $identifier) + public function __construct(NodeInterface $selector, string $identifier) { $this->selector = $selector; $this->identifier = strtolower($identifier); } - /** - * @return NodeInterface - */ - public function getSelector() + public function getSelector(): NodeInterface { return $this->selector; } - /** - * @return string - */ - public function getIdentifier() + public function getIdentifier(): string { return $this->identifier; } diff --git a/src/Symfony/Component/CssSelector/Node/SelectorNode.php b/src/Symfony/Component/CssSelector/Node/SelectorNode.php index 35392474a9ed9..a76aa5bb5f48a 100644 --- a/src/Symfony/Component/CssSelector/Node/SelectorNode.php +++ b/src/Symfony/Component/CssSelector/Node/SelectorNode.php @@ -26,28 +26,18 @@ class SelectorNode extends AbstractNode private $tree; private $pseudoElement; - /** - * @param NodeInterface $tree - * @param null|string $pseudoElement - */ - public function __construct(NodeInterface $tree, $pseudoElement = null) + public function __construct(NodeInterface $tree, string $pseudoElement = null) { $this->tree = $tree; $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; } - /** - * @return NodeInterface - */ - public function getTree() + public function getTree(): NodeInterface { return $this->tree; } - /** - * @return null|string - */ - public function getPseudoElement() + public function getPseudoElement(): ?string { return $this->pseudoElement; } diff --git a/src/Symfony/Component/CssSelector/Parser/Parser.php b/src/Symfony/Component/CssSelector/Parser/Parser.php index c4c3ddd47d0ac..dc84cc1826197 100644 --- a/src/Symfony/Component/CssSelector/Parser/Parser.php +++ b/src/Symfony/Component/CssSelector/Parser/Parser.php @@ -50,11 +50,9 @@ public function parse(string $source): array * * @param Token[] $tokens * - * @return array - * * @throws SyntaxErrorException */ - public static function parseSeries(array $tokens) + public static function parseSeries(array $tokens): array { foreach ($tokens as $token) { if ($token->isString()) { @@ -146,14 +144,9 @@ private function parserSelectorNode(TokenStream $stream): Node\SelectorNode /** * Parses next simple node (hash, class, pseudo, negation). * - * @param TokenStream $stream - * @param bool $insideNegation - * - * @return array - * * @throws SyntaxErrorException */ - private function parseSimpleSelector(TokenStream $stream, $insideNegation = false) + private function parseSimpleSelector(TokenStream $stream, bool $insideNegation = false): array { $stream->skipWhitespace(); diff --git a/src/Symfony/Component/CssSelector/Parser/ParserInterface.php b/src/Symfony/Component/CssSelector/Parser/ParserInterface.php index 88c8879e0b6e8..51c3d935069aa 100644 --- a/src/Symfony/Component/CssSelector/Parser/ParserInterface.php +++ b/src/Symfony/Component/CssSelector/Parser/ParserInterface.php @@ -28,8 +28,6 @@ interface ParserInterface /** * Parses given selector source into an array of tokens. * - * @param string $source - * * @return SelectorNode[] */ public function parse(string $source): array; diff --git a/src/Symfony/Component/CssSelector/Parser/Reader.php b/src/Symfony/Component/CssSelector/Parser/Reader.php index 5a1be30cd957a..adfd3c2113940 100644 --- a/src/Symfony/Component/CssSelector/Parser/Reader.php +++ b/src/Symfony/Component/CssSelector/Parser/Reader.php @@ -27,56 +27,33 @@ class Reader private $length; private $position = 0; - /** - * @param string $source - */ - public function __construct($source) + public function __construct(string $source) { $this->source = $source; $this->length = strlen($source); } - /** - * @return bool - */ - public function isEOF() + public function isEOF(): bool { return $this->position >= $this->length; } - /** - * @return int - */ - public function getPosition() + public function getPosition(): int { return $this->position; } - /** - * @return int - */ - public function getRemainingLength() + public function getRemainingLength(): int { return $this->length - $this->position; } - /** - * @param int $length - * @param int $offset - * - * @return string - */ - public function getSubstring($length, $offset = 0) + public function getSubstring(int $length, int $offset = 0): string { return substr($this->source, $this->position + $offset, $length); } - /** - * @param string $string - * - * @return int - */ - public function getOffset($string) + public function getOffset(string $string) { $position = strpos($this->source, $string, $this->position); @@ -84,11 +61,9 @@ public function getOffset($string) } /** - * @param string $pattern - * * @return array|false */ - public function findPattern($pattern) + public function findPattern(string $pattern) { $source = substr($this->source, $this->position); @@ -99,10 +74,7 @@ public function findPattern($pattern) return false; } - /** - * @param int $length - */ - public function moveForward($length) + public function moveForward(int $length) { $this->position += $length; } diff --git a/src/Symfony/Component/CssSelector/Parser/Token.php b/src/Symfony/Component/CssSelector/Parser/Token.php index 79a7cf1616f66..554deb8e4aefd 100644 --- a/src/Symfony/Component/CssSelector/Parser/Token.php +++ b/src/Symfony/Component/CssSelector/Parser/Token.php @@ -35,38 +35,24 @@ class Token private $value; private $position; - /** - * @param string $type - * @param string $value - * @param int $position - */ - public function __construct($type, $value, $position) + public function __construct(?string $type, ?string $value, ?int $position) { $this->type = $type; $this->value = $value; $this->position = $position; } - /** - * @return int - */ - public function getType() + public function getType(): ?int { return $this->type; } - /** - * @return string - */ - public function getValue() + public function getValue(): ?string { return $this->value; } - /** - * @return int - */ - public function getPosition() + public function getPosition(): ?int { return $this->position; } diff --git a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php index 30584ca92ee85..dffb079d75059 100644 --- a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php +++ b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php @@ -52,60 +52,37 @@ public function __construct() $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*'; } - /** - * @return string - */ - public function getNewLineEscapePattern() + public function getNewLineEscapePattern(): string { return '~^'.$this->newLineEscapePattern.'~'; } - /** - * @return string - */ - public function getSimpleEscapePattern() + public function getSimpleEscapePattern(): string { return '~^'.$this->simpleEscapePattern.'~'; } - /** - * @return string - */ - public function getUnicodeEscapePattern() + public function getUnicodeEscapePattern(): string { return '~^'.$this->unicodeEscapePattern.'~i'; } - /** - * @return string - */ - public function getIdentifierPattern() + public function getIdentifierPattern(): string { return '~^'.$this->identifierPattern.'~i'; } - /** - * @return string - */ - public function getHashPattern() + public function getHashPattern(): string { return '~^'.$this->hashPattern.'~i'; } - /** - * @return string - */ - public function getNumberPattern() + public function getNumberPattern(): string { return '~^'.$this->numberPattern.'~'; } - /** - * @param string $quote - * - * @return string - */ - public function getQuotedStringPattern($quote) + public function getQuotedStringPattern(string $quote): string { return '~^'.sprintf($this->quotedStringPattern, $quote).'~i'; } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php index 6ace8b5925969..ee8976fdd03fa 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php @@ -43,38 +43,17 @@ public function getAttributeMatchingTranslators() ); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translateExists(XPathExpr $xpath, $attribute, $value) + public function translateExists(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition($attribute); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translateEquals(XPathExpr $xpath, $attribute, $value) + public function translateEquals(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition(sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value))); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translateIncludes(XPathExpr $xpath, $attribute, $value) + public function translateIncludes(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition($value ? sprintf( '%1$s and contains(concat(\' \', normalize-space(%1$s), \' \'), %2$s)', @@ -83,14 +62,7 @@ public function translateIncludes(XPathExpr $xpath, $attribute, $value) ) : '0'); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translateDashMatch(XPathExpr $xpath, $attribute, $value) + public function translateDashMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition(sprintf( '%1$s and (%1$s = %2$s or starts-with(%1$s, %3$s))', @@ -100,14 +72,7 @@ public function translateDashMatch(XPathExpr $xpath, $attribute, $value) )); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value) + public function translatePrefixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition($value ? sprintf( '%1$s and starts-with(%1$s, %2$s)', @@ -116,14 +81,7 @@ public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value) ) : '0'); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value) + public function translateSuffixMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition($value ? sprintf( '%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s', @@ -133,14 +91,7 @@ public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value) ) : '0'); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value) + public function translateSubstringMatch(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition($value ? sprintf( '%1$s and contains(%1$s, %2$s)', @@ -149,14 +100,7 @@ public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value) ) : '0'); } - /** - * @param XPathExpr $xpath - * @param string $attribute - * @param string $value - * - * @return XPathExpr - */ - public function translateDifferent(XPathExpr $xpath, $attribute, $value) + public function translateDifferent(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr { return $xpath->addCondition(sprintf( $value ? 'not(%1$s) or %1$s != %2$s' : '%s != %s', diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php index c2606b5ad4308..52b9c2f63cfaa 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php @@ -46,16 +46,9 @@ public function getFunctionTranslators() } /** - * @param XPathExpr $xpath - * @param FunctionNode $function - * @param bool $last - * @param bool $addNameTest - * - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $last = false, $addNameTest = true) + public function translateNthChild(XPathExpr $xpath, FunctionNode $function, bool $last = false, bool $addNameTest = true): XPathExpr { try { list($a, $b) = Parser::parseSeries($function->getArguments()); @@ -110,28 +103,20 @@ public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $las // -1n+6 means elements 6 and previous } - /** - * @return XPathExpr - */ - public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function) + public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function): XPathExpr { return $this->translateNthChild($xpath, $function, true); } - /** - * @return XPathExpr - */ - public function translateNthOfType(XPathExpr $xpath, FunctionNode $function) + public function translateNthOfType(XPathExpr $xpath, FunctionNode $function): XPathExpr { return $this->translateNthChild($xpath, $function, false, false); } /** - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function) + public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function): XPathExpr { if ('*' === $xpath->getElement()) { throw new ExpressionErrorException('"*:nth-of-type()" is not implemented.'); @@ -141,11 +126,9 @@ public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function) } /** - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateContains(XPathExpr $xpath, FunctionNode $function) + public function translateContains(XPathExpr $xpath, FunctionNode $function): XPathExpr { $arguments = $function->getArguments(); foreach ($arguments as $token) { @@ -164,11 +147,9 @@ public function translateContains(XPathExpr $xpath, FunctionNode $function) } /** - * @return XPathExpr - * * @throws ExpressionErrorException */ - public function translateLang(XPathExpr $xpath, FunctionNode $function) + public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr { $arguments = $function->getArguments(); foreach ($arguments as $token) { diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php index 715d9611a8267..61442b6f7a530 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -33,21 +33,15 @@ class NodeExtension extends AbstractExtension private $flags; - /** - * @param int $flags - */ - public function __construct($flags = 0) + public function __construct(int $flags = 0) { $this->flags = $flags; } /** - * @param int $flag - * @param bool $on - * * @return $this */ - public function setFlag($flag, $on) + public function setFlag(int $flag, bool $on) { if ($on && !$this->hasFlag($flag)) { $this->flags += $flag; @@ -60,12 +54,7 @@ public function setFlag($flag, $on) return $this; } - /** - * @param int $flag - * - * @return bool - */ - public function hasFlag($flag) + public function hasFlag(int $flag): bool { return (bool) ($this->flags & $flag); } @@ -88,26 +77,17 @@ public function getNodeTranslators() ); } - /** - * @return XPathExpr - */ - public function translateSelector(Node\SelectorNode $node, Translator $translator) + public function translateSelector(Node\SelectorNode $node, Translator $translator): XPathExpr { return $translator->nodeToXPath($node->getTree()); } - /** - * @return XPathExpr - */ - public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator) + public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator): XPathExpr { return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); } - /** - * @return XPathExpr - */ - public function translateNegation(Node\NegationNode $node, Translator $translator) + public function translateNegation(Node\NegationNode $node, Translator $translator): XPathExpr { $xpath = $translator->nodeToXPath($node->getSelector()); $subXpath = $translator->nodeToXPath($node->getSubSelector()); @@ -120,30 +100,21 @@ public function translateNegation(Node\NegationNode $node, Translator $translato return $xpath->addCondition('0'); } - /** - * @return XPathExpr - */ - public function translateFunction(Node\FunctionNode $node, Translator $translator) + public function translateFunction(Node\FunctionNode $node, Translator $translator): XPathExpr { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addFunction($xpath, $node); } - /** - * @return XPathExpr - */ - public function translatePseudo(Node\PseudoNode $node, Translator $translator) + public function translatePseudo(Node\PseudoNode $node, Translator $translator): XPathExpr { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addPseudoClass($xpath, $node->getIdentifier()); } - /** - * @return XPathExpr - */ - public function translateAttribute(Node\AttributeNode $node, Translator $translator) + public function translateAttribute(Node\AttributeNode $node, Translator $translator): XPathExpr { $name = $node->getAttribute(); $safe = $this->isSafeName($name); @@ -168,30 +139,21 @@ public function translateAttribute(Node\AttributeNode $node, Translator $transla return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); } - /** - * @return XPathExpr - */ - public function translateClass(Node\ClassNode $node, Translator $translator) + public function translateClass(Node\ClassNode $node, Translator $translator): XPathExpr { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); } - /** - * @return XPathExpr - */ - public function translateHash(Node\HashNode $node, Translator $translator) + public function translateHash(Node\HashNode $node, Translator $translator): XPathExpr { $xpath = $translator->nodeToXPath($node->getSelector()); return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); } - /** - * @return XPathExpr - */ - public function translateElement(Node\ElementNode $node) + public function translateElement(Node\ElementNode $node): XPathExpr { $element = $node->getElement(); @@ -228,14 +190,7 @@ public function getName() return 'node'; } - /** - * Tests if given name is safe. - * - * @param string $name - * - * @return bool - */ - private function isSafeName($name) + private function isSafeName(string $name): bool { return 0 < preg_match('~^[a-zA-Z_][a-zA-Z0-9_.-]*$~', $name); } diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index f66a13d685778..28478b3db7e47 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -207,11 +207,9 @@ public function addAttributeMatching(XPathExpr $xpath, string $operator, string } /** - * @param string $css - * * @return SelectorNode[] */ - private function parseSelectors($css) + private function parseSelectors(string $css) { foreach ($this->shortcutParsers as $shortcut) { $tokens = $shortcut->parse($css); diff --git a/src/Symfony/Component/CssSelector/XPath/TranslatorInterface.php b/src/Symfony/Component/CssSelector/XPath/TranslatorInterface.php index 3224859559470..c19eefb9c99d0 100644 --- a/src/Symfony/Component/CssSelector/XPath/TranslatorInterface.php +++ b/src/Symfony/Component/CssSelector/XPath/TranslatorInterface.php @@ -27,21 +27,11 @@ interface TranslatorInterface { /** * Translates a CSS selector to an XPath expression. - * - * @param string $cssExpr - * @param string $prefix - * - * @return string */ public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string; /** * Translates a parsed selector node to an XPath expression. - * - * @param SelectorNode $selector - * @param string $prefix - * - * @return string */ public function selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::'): string; } diff --git a/src/Symfony/Component/CssSelector/XPath/XPathExpr.php b/src/Symfony/Component/CssSelector/XPath/XPathExpr.php index 44ecc093cf8b2..0b958fa1ad98e 100644 --- a/src/Symfony/Component/CssSelector/XPath/XPathExpr.php +++ b/src/Symfony/Component/CssSelector/XPath/XPathExpr.php @@ -50,9 +50,6 @@ public function addCondition(string $condition): XPathExpr return $this; } - /** - * @return string - */ public function getCondition(): string { return $this->condition; @@ -78,9 +75,6 @@ public function addStarPrefix(): XPathExpr /** * Joins another XPathExpr with a combiner. * - * @param string $combiner - * @param XPathExpr $expr - * * @return $this */ public function join(string $combiner, XPathExpr $expr): XPathExpr diff --git a/src/Symfony/Component/Debug/Exception/ClassNotFoundException.php b/src/Symfony/Component/Debug/Exception/ClassNotFoundException.php index b91bf46631bbb..45d4c253c992a 100644 --- a/src/Symfony/Component/Debug/Exception/ClassNotFoundException.php +++ b/src/Symfony/Component/Debug/Exception/ClassNotFoundException.php @@ -18,7 +18,7 @@ */ class ClassNotFoundException extends FatalErrorException { - public function __construct($message, \ErrorException $previous) + public function __construct(string $message, \ErrorException $previous) { parent::__construct( $message, diff --git a/src/Symfony/Component/Debug/Exception/FatalErrorException.php b/src/Symfony/Component/Debug/Exception/FatalErrorException.php index 8418c940a90a3..46c7ad72b5f16 100644 --- a/src/Symfony/Component/Debug/Exception/FatalErrorException.php +++ b/src/Symfony/Component/Debug/Exception/FatalErrorException.php @@ -18,7 +18,7 @@ */ class FatalErrorException extends \ErrorException { - public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null) + public function __construct(string $message, int $code, int $severity, string $filename, int $lineno, int $traceOffset = null, bool $traceArgs = true, array $trace = null) { parent::__construct($message, $code, $severity, $filename, $lineno); diff --git a/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php b/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php index 4be83491b9df7..6f84617c466f1 100644 --- a/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php +++ b/src/Symfony/Component/Debug/Exception/SilencedErrorContext.php @@ -25,7 +25,7 @@ class SilencedErrorContext implements \JsonSerializable private $line; private $trace; - public function __construct($severity, $file, $line, array $trace = array(), $count = 1) + public function __construct(int $severity, string $file, int $line, array $trace = array(), int $count = 1) { $this->severity = $severity; $this->file = $file; diff --git a/src/Symfony/Component/Debug/Exception/UndefinedFunctionException.php b/src/Symfony/Component/Debug/Exception/UndefinedFunctionException.php index a66ae2a3879c9..89710671d1d33 100644 --- a/src/Symfony/Component/Debug/Exception/UndefinedFunctionException.php +++ b/src/Symfony/Component/Debug/Exception/UndefinedFunctionException.php @@ -18,7 +18,7 @@ */ class UndefinedFunctionException extends FatalErrorException { - public function __construct($message, \ErrorException $previous) + public function __construct(string $message, \ErrorException $previous) { parent::__construct( $message, diff --git a/src/Symfony/Component/Debug/Exception/UndefinedMethodException.php b/src/Symfony/Component/Debug/Exception/UndefinedMethodException.php index 350dc3187f475..e895274711988 100644 --- a/src/Symfony/Component/Debug/Exception/UndefinedMethodException.php +++ b/src/Symfony/Component/Debug/Exception/UndefinedMethodException.php @@ -18,7 +18,7 @@ */ class UndefinedMethodException extends FatalErrorException { - public function __construct($message, \ErrorException $previous) + public function __construct(string $message, \ErrorException $previous) { parent::__construct( $message, diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 97470cb6b4d01..a6ae71f8f1091 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -36,7 +36,7 @@ class ExceptionHandler private $caughtLength; private $fileLinkFormat; - public function __construct($debug = true, $charset = null, $fileLinkFormat = null) + public function __construct(bool $debug = true, string $charset = null, $fileLinkFormat = null) { $this->debug = $debug; $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8'; diff --git a/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php index 32ba9a09c5777..25030e5606d28 100644 --- a/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php +++ b/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -83,7 +83,7 @@ public function handleError(array $error, FatalErrorException $exception) * * @return array An array of possible fully qualified class names */ - private function getClassCandidates($class) + private function getClassCandidates(string $class): array { if (!is_array($functions = spl_autoload_functions())) { return array(); @@ -124,14 +124,7 @@ private function getClassCandidates($class) return array_unique($classes); } - /** - * @param string $path - * @param string $class - * @param string $prefix - * - * @return array - */ - private function findClassInPath($path, $class, $prefix) + private function findClassInPath(string $path, string $class, string $prefix): array { if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) { return array(); @@ -148,14 +141,7 @@ private function findClassInPath($path, $class, $prefix) return $classes; } - /** - * @param string $path - * @param string $file - * @param string $prefix - * - * @return string|null - */ - private function convertFileToClass($path, $file, $prefix) + private function convertFileToClass(string $path, string $file, string $prefix): ?string { $candidates = array( // namespaced class @@ -192,14 +178,11 @@ private function convertFileToClass($path, $file, $prefix) return $candidate; } } + + return null; } - /** - * @param string $class - * - * @return bool - */ - private function classExists($class) + private function classExists(string $class): bool { return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); } diff --git a/src/Symfony/Component/DependencyInjection/Alias.php b/src/Symfony/Component/DependencyInjection/Alias.php index 8773b8389110f..55e385f674e48 100644 --- a/src/Symfony/Component/DependencyInjection/Alias.php +++ b/src/Symfony/Component/DependencyInjection/Alias.php @@ -17,13 +17,9 @@ class Alias private $public; private $private; - /** - * @param string $id Alias identifier - * @param bool $public If this alias is public - */ - public function __construct($id, $public = true) + public function __construct(string $id, bool $public = true) { - $this->id = (string) $id; + $this->id = $id; $this->public = $public; $this->private = 2 > func_num_args(); } diff --git a/src/Symfony/Component/DependencyInjection/Argument/TaggedIteratorArgument.php b/src/Symfony/Component/DependencyInjection/Argument/TaggedIteratorArgument.php index 19e0d2b97152c..3a6fab8b995ff 100644 --- a/src/Symfony/Component/DependencyInjection/Argument/TaggedIteratorArgument.php +++ b/src/Symfony/Component/DependencyInjection/Argument/TaggedIteratorArgument.php @@ -20,14 +20,11 @@ class TaggedIteratorArgument extends IteratorArgument { private $tag; - /** - * @param string $tag - */ - public function __construct($tag) + public function __construct(string $tag) { parent::__construct(array()); - $this->tag = (string) $tag; + $this->tag = $tag; } public function getTag() diff --git a/src/Symfony/Component/DependencyInjection/ChildDefinition.php b/src/Symfony/Component/DependencyInjection/ChildDefinition.php index 21ad794845ca9..bcb7ff4838f64 100644 --- a/src/Symfony/Component/DependencyInjection/ChildDefinition.php +++ b/src/Symfony/Component/DependencyInjection/ChildDefinition.php @@ -27,7 +27,7 @@ class ChildDefinition extends Definition /** * @param string $parent The id of Definition instance to decorate */ - public function __construct($parent) + public function __construct(string $parent) { $this->parent = $parent; $this->setPrivate(false); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index 096b044dc04b9..967d6bb41cfee 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -40,9 +40,9 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe /** * @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls */ - public function __construct($onlyConstructorArguments = false) + public function __construct(bool $onlyConstructorArguments = false) { - $this->onlyConstructorArguments = (bool) $onlyConstructorArguments; + $this->onlyConstructorArguments = $onlyConstructorArguments; } /** diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 7ec193d18e4b7..afda55c94f21b 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -32,10 +32,7 @@ class AutowirePass extends AbstractRecursivePass private $lastFailure; private $throwOnAutowiringException; - /** - * @param bool $throwOnAutowireException Errors can be retrieved via Definition::getErrors() - */ - public function __construct($throwOnAutowireException = true) + public function __construct(bool $throwOnAutowireException = true) { $this->throwOnAutowiringException = $throwOnAutowireException; } @@ -150,14 +147,11 @@ private function autowireCalls(\ReflectionClass $reflectionClass, array $methodC /** * Autowires the constructor or a method. * - * @param \ReflectionFunctionAbstract $reflectionMethod - * @param array $arguments - * * @return array The autowired arguments * * @throws AutowiringFailedException */ - private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, array $arguments) + private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, array $arguments): array { $class = $reflectionMethod instanceof \ReflectionMethod ? $reflectionMethod->class : $this->currentId; $method = $reflectionMethod->name; @@ -269,11 +263,8 @@ private function populateAvailableTypes() /** * Populates the list of available types for a given definition. - * - * @param string $id - * @param Definition $definition */ - private function populateAvailableType($id, Definition $definition) + private function populateAvailableType(string $id, Definition $definition) { // Never use abstract services if ($definition->isAbstract()) { @@ -295,11 +286,8 @@ private function populateAvailableType($id, Definition $definition) /** * Associates a type and a service id if applicable. - * - * @param string $type - * @param string $id */ - private function set($type, $id) + private function set(string $type, string $id) { // is this already a type/class that is known to match multiple services? if (isset($this->ambiguousServiceTypes[$type])) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php index 7f032058ab139..6e5e9042c8c20 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckArgumentsValidityPass.php @@ -24,7 +24,7 @@ class CheckArgumentsValidityPass extends AbstractRecursivePass { private $throwExceptions; - public function __construct($throwExceptions = true) + public function __construct(bool $throwExceptions = true) { $this->throwExceptions = $throwExceptions; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php index 9733e5d094333..3988f6dc2783e 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php @@ -25,7 +25,7 @@ class ResolveParameterPlaceHoldersPass extends AbstractRecursivePass private $bag; private $resolveArrays; - public function __construct($resolveArrays = true) + public function __construct(bool $resolveArrays = true) { $this->resolveArrays = $resolveArrays; } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php index a46c74fbb65f1..83677a0dd3096 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php @@ -53,15 +53,7 @@ protected function processValue($value, $isRoot = false) return parent::processValue($value); } - /** - * Resolves an alias into a definition id. - * - * @param string $id The definition or alias id to resolve - * @param ContainerBuilder $container - * - * @return string The definition id with aliases resolved - */ - private function getDefinitionId($id, ContainerBuilder $container) + private function getDefinitionId(string $id, ContainerBuilder $container): string { $seen = array(); while ($container->hasAlias($id)) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php index 3219d06e96989..d655dba69a6a7 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php @@ -32,7 +32,7 @@ class ServiceReferenceGraphNode * @param string $id The node identifier * @param mixed $value The node value */ - public function __construct($id, $value) + public function __construct(string $id, $value) { $this->id = $id; $this->value = $value; diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 4f753748fc813..f2d121be5a9fd 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -1424,10 +1424,8 @@ protected function getEnv($name) /** * Retrieves the currently set proxy instantiator or instantiates one. - * - * @return InstantiatorInterface */ - private function getProxyInstantiator() + private function getProxyInstantiator(): InstantiatorInterface { if (!$this->proxyInstantiator) { $this->proxyInstantiator = new RealServiceInstantiator(); diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 989725d53db5b..1621b1e723a7a 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -53,7 +53,7 @@ class Definition * @param string|null $class The service class * @param array $arguments An array of arguments to pass to the service constructor */ - public function __construct($class = null, array $arguments = array()) + public function __construct(string $class = null, array $arguments = array()) { if (null !== $class) { $this->setClass($class); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php index 8d21ef1fde984..84cc1f59a5ef7 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php @@ -83,12 +83,7 @@ public function dump(array $options = array()) return $this->container->resolveEnvPlaceholders($this->startDot().$this->addNodes().$this->addEdges().$this->endDot(), '__ENV_%s__'); } - /** - * Returns all nodes. - * - * @return string A string representation of all nodes - */ - private function addNodes() + private function addNodes(): string { $code = ''; foreach ($this->nodes as $id => $node) { @@ -100,12 +95,7 @@ private function addNodes() return $code; } - /** - * Returns all edges. - * - * @return string A string representation of all edges - */ - private function addEdges() + private function addEdges(): string { $code = ''; foreach ($this->edges as $id => $edges) { @@ -119,15 +109,8 @@ private function addEdges() /** * Finds all edges belonging to a specific service id. - * - * @param string $id The service id used to find edges - * @param array $arguments An array of arguments - * @param bool $required - * @param string $name - * - * @return array An array of edges */ - private function findEdges($id, array $arguments, $required, $name, $lazy = false) + private function findEdges(string $id, array $arguments, bool $required, string $name, bool $lazy = false): array { $edges = array(); foreach ($arguments as $argument) { @@ -157,12 +140,7 @@ private function findEdges($id, array $arguments, $required, $name, $lazy = fals return $edges; } - /** - * Finds all nodes. - * - * @return array An array of all nodes - */ - private function findNodes() + private function findNodes(): array { $nodes = array(); @@ -212,12 +190,7 @@ private function cloneContainer() return $container; } - /** - * Returns the start dot. - * - * @return string The string representation of a start dot - */ - private function startDot() + private function startDot(): string { return sprintf("digraph sc {\n %s\n node [%s];\n edge [%s];\n\n", $this->addOptions($this->options['graph']), @@ -226,24 +199,12 @@ private function startDot() ); } - /** - * Returns the end dot. - * - * @return string - */ - private function endDot() + private function endDot(): string { return "}\n"; } - /** - * Adds attributes. - * - * @param array $attributes An array of attributes - * - * @return string A comma separated list of attributes - */ - private function addAttributes(array $attributes) + private function addAttributes(array $attributes): string { $code = array(); foreach ($attributes as $k => $v) { @@ -253,14 +214,7 @@ private function addAttributes(array $attributes) return $code ? ', '.implode(', ', $code) : ''; } - /** - * Adds options. - * - * @param array $options An array of options - * - * @return string A space separated list of options - */ - private function addOptions(array $options) + private function addOptions(array $options): string { $code = array(); foreach ($options as $k => $v) { @@ -270,26 +224,12 @@ private function addOptions(array $options) return implode(' ', $code); } - /** - * Dotizes an identifier. - * - * @param string $id The identifier to dotize - * - * @return string A dotized string - */ - private function dotize($id) + private function dotize(string $id): string { return preg_replace('/\W/i', '_', $id); } - /** - * Compiles an array of aliases for a specified service id. - * - * @param string $id A service id - * - * @return array An array of aliases - */ - private function getAliases($id) + private function getAliases(string $id): array { $aliases = array(); foreach ($this->container->getAliases() as $alias => $origin) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 98b29c2385859..6d23641326640 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -237,10 +237,8 @@ class_alias(Container{$hash}::class, {$options['class']}::class, false); /** * Retrieves the currently set proxy dumper or instantiates one. - * - * @return ProxyDumper */ - private function getProxyDumper() + private function getProxyDumper(): ProxyDumper { if (!$this->proxyDumper) { $this->proxyDumper = new NullDumper(); @@ -249,16 +247,7 @@ private function getProxyDumper() return $this->proxyDumper; } - /** - * Generates Service local temp variables. - * - * @param string $cId - * @param Definition $definition - * @param array $inlinedDefinitions - * - * @return string - */ - private function addServiceLocalTempVariables($cId, Definition $definition, array $inlinedDefinitions) + private function addServiceLocalTempVariables(string $cId, Definition $definition, array $inlinedDefinitions): string { static $template = " \$%s = %s;\n"; @@ -330,12 +319,7 @@ private function generateProxyClasses() } } - /** - * Generates the require_once statement for service includes. - * - * @return string - */ - private function addServiceInclude(Definition $definition, array $inlinedDefinitions) + private function addServiceInclude(Definition $definition, array $inlinedDefinitions): string { $template = " require_once %s;\n"; $code = ''; @@ -360,15 +344,10 @@ private function addServiceInclude(Definition $definition, array $inlinedDefinit /** * Generates the inline definition of a service. * - * @param string $id - * @param array $inlinedDefinitions - * - * @return string - * * @throws RuntimeException When the factory definition is incomplete * @throws ServiceCircularReferenceException When a circular reference is detected */ - private function addServiceInlinedDefinitions($id, array $inlinedDefinitions) + private function addServiceInlinedDefinitions(string $id, array $inlinedDefinitions): string { $code = ''; $variableMap = $this->definitionVariables; @@ -422,18 +401,10 @@ private function addServiceInlinedDefinitions($id, array $inlinedDefinitions) } /** - * Generates the service instance. - * - * @param string $id - * @param Definition $definition - * @param bool $isSimpleInstance - * - * @return string - * * @throws InvalidArgumentException * @throws RuntimeException */ - private function addServiceInstance($id, Definition $definition, $isSimpleInstance) + private function addServiceInstance(string $id, Definition $definition, string $isSimpleInstance): string { $class = $this->dumpValue($definition->getClass()); @@ -466,15 +437,7 @@ private function addServiceInstance($id, Definition $definition, $isSimpleInstan return $code; } - /** - * Checks if the definition is a simple instance. - * - * @param string $id - * @param Definition $definition - * - * @return bool - */ - private function isSimpleInstance($id, Definition $definition, array $inlinedDefinitions) + private function isSimpleInstance(string $id, Definition $definition, array $inlinedDefinitions): bool { foreach (array_merge(array($definition), $inlinedDefinitions) as $sDefinition) { if ($definition !== $sDefinition && !$this->hasReference($id, $sDefinition->getMethodCalls())) { @@ -489,14 +452,7 @@ private function isSimpleInstance($id, Definition $definition, array $inlinedDef return true; } - /** - * Checks if the definition is a trivial instance. - * - * @param Definition $definition - * - * @return bool - */ - private function isTrivialInstance(Definition $definition) + private function isTrivialInstance(Definition $definition): bool { if ($definition->isSynthetic() || $definition->getFile() || $definition->getMethodCalls() || $definition->getProperties() || $definition->getConfigurator()) { return false; @@ -533,15 +489,7 @@ private function isTrivialInstance(Definition $definition) return true; } - /** - * Adds method calls to a service definition. - * - * @param Definition $definition - * @param string $variableName - * - * @return string - */ - private function addServiceMethodCalls(Definition $definition, $variableName = 'instance') + private function addServiceMethodCalls(Definition $definition, string $variableName = 'instance'): string { $calls = ''; foreach ($definition->getMethodCalls() as $call) { @@ -567,17 +515,9 @@ private function addServiceProperties(Definition $definition, $variableName = 'i } /** - * Generates the inline definition setup. - * - * @param string $id - * @param array $inlinedDefinitions - * @param bool $isSimpleInstance - * - * @return string - * * @throws ServiceCircularReferenceException when the container contains a circular reference */ - private function addServiceInlinedDefinitionsSetup($id, array $inlinedDefinitions, $isSimpleInstance) + private function addServiceInlinedDefinitionsSetup(string $id, array $inlinedDefinitions, bool $isSimpleInstance): string { $this->referenceVariables[$id] = new Variable('instance'); @@ -612,15 +552,7 @@ private function addServiceInlinedDefinitionsSetup($id, array $inlinedDefinition return $code; } - /** - * Adds configurator definition. - * - * @param Definition $definition - * @param string $variableName - * - * @return string - */ - private function addServiceConfigurator(Definition $definition, $variableName = 'instance') + private function addServiceConfigurator(Definition $definition, string $variableName = 'instance'): string { if (!$callable = $definition->getConfigurator()) { return ''; @@ -648,16 +580,7 @@ private function addServiceConfigurator(Definition $definition, $variableName = return sprintf(" %s(\$%s);\n", $callable, $variableName); } - /** - * Adds a service. - * - * @param string $id - * @param Definition $definition - * @param string &$file - * - * @return string - */ - private function addService($id, Definition $definition, &$file = null) + private function addService(string $id, Definition $definition, string &$file = null): string { $this->definitionVariables = new \SplObjectStorage(); $this->referenceVariables = array(); @@ -757,12 +680,7 @@ protected function {$methodName}($lazyInitialization) return $code; } - /** - * Adds multiple services. - * - * @return string - */ - private function addServices() + private function addServices(): string { $publicServices = $privateServices = ''; $definitions = $this->container->getDefinitions(); @@ -841,15 +759,7 @@ private function addNewInstance(Definition $definition, $return, $instantiation, return sprintf(" $return{$instantiation}new %s(%s);\n", $this->dumpLiteralClass($class), implode(', ', $arguments)); } - /** - * Adds the class headers. - * - * @param string $class Class name - * @param string $baseClass The name of the base class - * - * @return string - */ - private function startClass($class, $baseClass) + private function startClass(string $class, string $baseClass): string { $namespaceLine = $this->namespace ? "\nnamespace {$this->namespace};\n" : ''; @@ -962,12 +872,7 @@ protected function createProxy(\$class, \Closure \$factory) return $code; } - /** - * Adds the syntheticIds definition. - * - * @return string - */ - private function addSyntheticIds() + private function addSyntheticIds(): string { $code = ''; $definitions = $this->container->getDefinitions(); @@ -981,12 +886,7 @@ private function addSyntheticIds() return $code ? " \$this->syntheticIds = array(\n{$code} );\n" : ''; } - /** - * Adds the removedIds definition. - * - * @return string - */ - private function addRemovedIds() + private function addRemovedIds(): string { $ids = $this->container->getRemovedIds(); foreach ($this->container->getDefinitions() as $id => $definition) { @@ -1020,12 +920,7 @@ public function getRemovedIds() EOF; } - /** - * Adds the methodMap property definition. - * - * @return string - */ - private function addMethodMap() + private function addMethodMap(): string { $code = ''; $definitions = $this->container->getDefinitions(); @@ -1039,12 +934,7 @@ private function addMethodMap() return $code ? " \$this->methodMap = array(\n{$code} );\n" : ''; } - /** - * Adds the fileMap property definition. - * - * @return string - */ - private function addFileMap() + private function addFileMap(): string { $code = ''; $definitions = $this->container->getDefinitions(); @@ -1058,12 +948,7 @@ private function addFileMap() return $code ? " \$this->fileMap = array(\n{$code} );\n" : ''; } - /** - * Adds the aliases property definition. - * - * @return string - */ - private function addAliases() + private function addAliases(): string { if (!$aliases = $this->container->getAliases()) { return "\n \$this->aliases = array();\n"; @@ -1082,12 +967,7 @@ private function addAliases() return $code." );\n"; } - /** - * Adds default parameters method. - * - * @return string - */ - private function addDefaultParametersMethod() + private function addDefaultParametersMethod(): string { if (!$this->container->getParameterBag()->all()) { return ''; @@ -1206,17 +1086,9 @@ protected function getDefaultParameters() } /** - * Exports parameters. - * - * @param array $parameters - * @param string $path - * @param int $indent - * - * @return string - * * @throws InvalidArgumentException */ - private function exportParameters(array $parameters, $path = '', $indent = 12) + private function exportParameters(array $parameters, string $path = '', int $indent = 12): string { $php = array(); foreach ($parameters as $key => $value) { @@ -1242,12 +1114,7 @@ private function exportParameters(array $parameters, $path = '', $indent = 12) return sprintf("array(\n%s\n%s)", implode("\n", $php), str_repeat(' ', $indent - 4)); } - /** - * Ends the class definition. - * - * @return string - */ - private function endClass() + private function endClass(): string { return <<<'EOF' } @@ -1255,15 +1122,7 @@ private function endClass() EOF; } - /** - * Wraps the service conditionals. - * - * @param string $value - * @param string $code - * - * @return string - */ - private function wrapServiceConditionals($value, $code) + private function wrapServiceConditionals($value, string $code): string { if (!$condition = $this->getServiceConditionals($value)) { return $code; @@ -1275,14 +1134,7 @@ private function wrapServiceConditionals($value, $code) return sprintf(" if (%s) {\n%s }\n", $condition, $code); } - /** - * Get the conditions to execute for conditional services. - * - * @param string $value - * - * @return null|string - */ - private function getServiceConditionals($value) + private function getServiceConditionals($value): string { $conditions = array(); foreach (ContainerBuilder::getInitializedConditionals($value) as $service) { @@ -1306,10 +1158,7 @@ private function getServiceConditionals($value) return implode(' && ', $conditions); } - /** - * Builds service calls from arguments. - */ - private function getServiceCallsFromArguments(array $arguments, array &$calls, array &$behavior, $isPreInstantiation) + private function getServiceCallsFromArguments(array $arguments, array &$calls, array &$behavior, bool $isPreInstantiation) { foreach ($arguments as $argument) { if (is_array($argument)) { @@ -1331,12 +1180,7 @@ private function getServiceCallsFromArguments(array $arguments, array &$calls, a } } - /** - * Returns the inline definition. - * - * @return array - */ - private function getInlinedDefinitions(Definition $definition) + private function getInlinedDefinitions(Definition $definition): array { if (false === $this->inlinedDefinitions->contains($definition)) { $definitions = array_merge( @@ -1355,12 +1199,7 @@ private function getInlinedDefinitions(Definition $definition) return $this->inlinedDefinitions->offsetGet($definition); } - /** - * Gets the definition from arguments. - * - * @return array - */ - private function getDefinitionsFromArguments(array $arguments) + private function getDefinitionsFromArguments(array $arguments): array { $definitions = array(); foreach ($arguments as $argument) { @@ -1378,17 +1217,7 @@ private function getDefinitionsFromArguments(array $arguments) return $definitions; } - /** - * Checks if a service id has a reference. - * - * @param string $id - * @param array $arguments - * @param bool $deep - * @param array $visited - * - * @return bool - */ - private function hasReference($id, array $arguments, $deep = false, array &$visited = array()) + private function hasReference(string $id, array $arguments, bool $deep = false, array &$visited = array()): bool { foreach ($arguments as $argument) { if (is_array($argument)) { @@ -1433,16 +1262,9 @@ private function hasReference($id, array $arguments, $deep = false, array &$visi } /** - * Dumps values. - * - * @param mixed $value - * @param bool $interpolate - * - * @return string - * * @throws RuntimeException */ - private function dumpValue($value, $interpolate = true) + private function dumpValue($value, bool $interpolate = true): string { if (is_array($value)) { if ($value && $interpolate && false !== $param = array_search($value, $this->container->getParameterBag()->all(), true)) { @@ -1594,13 +1416,9 @@ private function dumpValue($value, $interpolate = true) /** * Dumps a string to a literal (aka PHP Code) class value. * - * @param string $class - * - * @return string - * * @throws RuntimeException */ - private function dumpLiteralClass($class) + private function dumpLiteralClass(string $class): string { if (false !== strpos($class, '$')) { return sprintf('${($_ = %s) && false ?: "_"}', $class); @@ -1614,14 +1432,7 @@ private function dumpLiteralClass($class) return 0 === strpos($class, '\\') ? $class : '\\'.$class; } - /** - * Dumps a parameter. - * - * @param string $name - * - * @return string - */ - private function dumpParameter($name) + private function dumpParameter(string $name): string { if ($this->container->isCompiled() && $this->container->hasParameter($name)) { $value = $this->container->getParameter($name); @@ -1639,15 +1450,7 @@ private function dumpParameter($name) return sprintf("\$this->getParameter('%s')", $name); } - /** - * Gets a service call. - * - * @param string $id - * @param Reference $reference - * - * @return string - */ - private function getServiceCall($id, Reference $reference = null) + private function getServiceCall(string $id, Reference $reference = null): string { while ($this->container->hasAlias($id)) { $id = (string) $this->container->getAlias($id); @@ -1692,10 +1495,8 @@ private function getServiceCall($id, Reference $reference = null) /** * Initializes the method names map to avoid conflicts with the Container methods. - * - * @param string $class the container base class */ - private function initializeMethodNamesMap($class) + private function initializeMethodNamesMap(string $class) { $this->serviceIdToMethodNameMap = array(); $this->usedMethodNames = array(); @@ -1708,15 +1509,9 @@ private function initializeMethodNamesMap($class) } /** - * Convert a service id to a valid PHP method name. - * - * @param string $id - * - * @return string - * * @throws InvalidArgumentException */ - private function generateMethodName($id) + private function generateMethodName(string $id): string { if (isset($this->serviceIdToMethodNameMap[$id])) { return $this->serviceIdToMethodNameMap[$id]; @@ -1739,12 +1534,7 @@ private function generateMethodName($id) return $methodName; } - /** - * Returns the next name to use. - * - * @return string - */ - private function getNextVariableName() + private function getNextVariableName(): string { $firstChars = self::FIRST_CHARS; $firstCharsLength = strlen($firstChars); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index a9a11b25f30ff..25830e0bc506b 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -54,15 +54,7 @@ public function dump(array $options = array()) return $this->container->resolveEnvPlaceholders($this->addParameters()."\n".$this->addServices()); } - /** - * Adds a service. - * - * @param string $id - * @param Definition $definition - * - * @return string - */ - private function addService($id, Definition $definition) + private function addService(string $id, Definition $definition): string { $code = " $id:\n"; if ($class = $definition->getClass()) { @@ -159,15 +151,7 @@ private function addService($id, Definition $definition) return $code; } - /** - * Adds a service alias. - * - * @param string $alias - * @param Alias $id - * - * @return string - */ - private function addServiceAlias($alias, Alias $id) + private function addServiceAlias(string $alias, Alias $id): string { if ($id->isPrivate()) { return sprintf(" %s: '@%s'\n", $alias, $id); @@ -176,12 +160,7 @@ private function addServiceAlias($alias, Alias $id) return sprintf(" %s:\n alias: %s\n public: %s\n", $alias, $id, $id->isPublic() ? 'true' : 'false'); } - /** - * Adds services. - * - * @return string - */ - private function addServices() + private function addServices(): string { if (!$this->container->getDefinitions()) { return ''; @@ -203,12 +182,7 @@ private function addServices() return $code; } - /** - * Adds parameters. - * - * @return string - */ - private function addParameters() + private function addParameters(): string { if (!$this->container->getParameterBag()->all()) { return ''; @@ -288,15 +262,7 @@ private function dumpValue($value) return $value; } - /** - * Gets the service call. - * - * @param string $id - * @param Reference $reference - * - * @return string - */ - private function getServiceCall($id, Reference $reference = null) + private function getServiceCall(string $id, Reference $reference = null): string { if (null !== $reference) { switch ($reference->getInvalidBehavior()) { @@ -309,14 +275,7 @@ private function getServiceCall($id, Reference $reference = null) return sprintf('@%s', $id); } - /** - * Gets parameter call. - * - * @param string $id - * - * @return string - */ - private function getParameterCall($id) + private function getParameterCall(string $id): string { return sprintf('%%%s%%', $id); } @@ -326,15 +285,7 @@ private function getExpressionCall($expression) return sprintf('@=%s', $expression); } - /** - * Prepares parameters. - * - * @param array $parameters - * @param bool $escape - * - * @return array - */ - private function prepareParameters(array $parameters, $escape = true) + private function prepareParameters(array $parameters, bool $escape = true): array { $filtered = array(); foreach ($parameters as $key => $value) { @@ -350,12 +301,7 @@ private function prepareParameters(array $parameters, $escape = true) return $escape ? $this->escape($filtered) : $filtered; } - /** - * Escapes arguments. - * - * @return array - */ - private function escape(array $arguments) + private function escape(array $arguments): array { $args = array(); foreach ($arguments as $k => $v) { diff --git a/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php b/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php index 145cd8cbdcf24..f198cd2800289 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/AutowiringFailedException.php @@ -18,7 +18,7 @@ class AutowiringFailedException extends RuntimeException { private $serviceId; - public function __construct($serviceId, $message = '', $code = 0, \Exception $previous = null) + public function __construct(string $serviceId, string $message = '', int $code = 0, \Exception $previous = null) { $this->serviceId = $serviceId; diff --git a/src/Symfony/Component/DependencyInjection/Exception/EnvNotFoundException.php b/src/Symfony/Component/DependencyInjection/Exception/EnvNotFoundException.php index 577095e88b493..6ed18e06807f5 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/EnvNotFoundException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/EnvNotFoundException.php @@ -18,7 +18,7 @@ */ class EnvNotFoundException extends InvalidArgumentException { - public function __construct($name) + public function __construct(string $name) { parent::__construct(sprintf('Environment variable not found: "%s".', $name)); } diff --git a/src/Symfony/Component/DependencyInjection/Exception/EnvParameterException.php b/src/Symfony/Component/DependencyInjection/Exception/EnvParameterException.php index 3839a4633be40..c758ce143824a 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/EnvParameterException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/EnvParameterException.php @@ -18,7 +18,7 @@ */ class EnvParameterException extends InvalidArgumentException { - public function __construct(array $envs, \Exception $previous = null, $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.') + public function __construct(array $envs, \Exception $previous = null, string $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.') { parent::__construct(sprintf($message, implode('", "', $envs)), 0, $previous); } diff --git a/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php b/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php index 29151765dc5b6..e17e4024fdb4d 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ParameterCircularReferenceException.php @@ -20,7 +20,7 @@ class ParameterCircularReferenceException extends RuntimeException { private $parameters; - public function __construct($parameters, \Exception $previous = null) + public function __construct(array $parameters, \Exception $previous = null) { parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0]), 0, $previous); diff --git a/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php b/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php index 40c01b05081d8..ec9155bb64f72 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ParameterNotFoundException.php @@ -32,7 +32,7 @@ class ParameterNotFoundException extends InvalidArgumentException * @param string[] $alternatives Some parameter name alternatives * @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters */ - public function __construct($key, $sourceId = null, $sourceKey = null, \Exception $previous = null, array $alternatives = array(), $nonNestedAlternative = null) + public function __construct(string $key, string $sourceId = null, string $sourceKey = null, \Exception $previous = null, array $alternatives = array(), string $nonNestedAlternative = null) { $this->key = $key; $this->sourceId = $sourceId; diff --git a/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php b/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php index 26e3fb34bf3cb..5936b3a6d7944 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ServiceCircularReferenceException.php @@ -21,7 +21,7 @@ class ServiceCircularReferenceException extends RuntimeException private $serviceId; private $path; - public function __construct($serviceId, array $path, \Exception $previous = null) + public function __construct(string $serviceId, array $path, \Exception $previous = null) { parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)), 0, $previous); diff --git a/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php b/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php index 59567074ccb2c..dabd9da4a41e4 100644 --- a/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php +++ b/src/Symfony/Component/DependencyInjection/Exception/ServiceNotFoundException.php @@ -24,7 +24,7 @@ class ServiceNotFoundException extends InvalidArgumentException implements NotFo private $sourceId; private $alternatives; - public function __construct($id, $sourceId = null, \Exception $previous = null, array $alternatives = array(), $msg = null) + public function __construct(string $id, string $sourceId = null, \Exception $previous = null, array $alternatives = array(), string $msg = null) { if (null !== $msg) { // no-op diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php index 40b6c2f389723..3d89e2a99e8e7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php @@ -20,7 +20,7 @@ abstract class AbstractServiceConfigurator extends AbstractConfigurator protected $id; private $defaultTags = array(); - public function __construct(ServicesConfigurator $parent, Definition $definition, $id = null, array $defaultTags = array()) + public function __construct(ServicesConfigurator $parent, Definition $definition, string $id = null, array $defaultTags = array()) { $this->parent = $parent; $this->definition = $definition; @@ -41,13 +41,8 @@ public function __destruct() /** * Registers a service. - * - * @param string $id - * @param string|null $class - * - * @return ServiceConfigurator */ - final public function set($id, $class = null) + final public function set(string $id, string $class = null): ServiceConfigurator { $this->__destruct(); @@ -56,13 +51,8 @@ final public function set($id, $class = null) /** * Creates an alias. - * - * @param string $id - * @param string $referencedId - * - * @return AliasConfigurator */ - final public function alias($id, $referencedId) + final public function alias(string $id, string $referencedId): AliasConfigurator { $this->__destruct(); @@ -71,13 +61,8 @@ final public function alias($id, $referencedId) /** * Registers a PSR-4 namespace using a glob pattern. - * - * @param string $namespace - * @param string $resource - * - * @return PrototypeConfigurator */ - final public function load($namespace, $resource) + final public function load(string $namespace, string $resource): PrototypeConfigurator { $this->__destruct(); @@ -87,13 +72,9 @@ final public function load($namespace, $resource) /** * Gets an already defined service definition. * - * @param string $id - * - * @return ServiceConfigurator - * * @throws ServiceNotFoundException if the service definition does not exist */ - final public function get($id) + final public function get(string $id): ServiceConfigurator { $this->__destruct(); @@ -102,13 +83,8 @@ final public function get($id) /** * Registers a service. - * - * @param string $id - * @param string|null $class - * - * @return ServiceConfigurator */ - final public function __invoke($id, $class = null) + final public function __invoke(string $id, string $class = null): ServiceConfigurator { $this->__destruct(); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php index a68f83d8f583c..de365fde928d4 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php @@ -32,7 +32,7 @@ class ContainerConfigurator extends AbstractConfigurator private $path; private $file; - public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, $path, $file) + public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path, string $file) { $this->container = $container; $this->loader = $loader; @@ -41,7 +41,7 @@ public function __construct(ContainerBuilder $container, PhpFileLoader $loader, $this->file = $file; } - final public function extension($namespace, array $config) + final public function extension(string $namespace, array $config) { if (!$this->container->hasExtension($namespace)) { $extensions = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions())); @@ -57,24 +57,18 @@ final public function extension($namespace, array $config) $this->container->loadFromExtension($namespace, static::processValue($config)); } - final public function import($resource, $type = null, $ignoreErrors = false) + final public function import(string $resource, string $type = null, bool $ignoreErrors = false) { $this->loader->setCurrentDir(dirname($this->path)); $this->loader->import($resource, $type, $ignoreErrors, $this->file); } - /** - * @return ParametersConfigurator - */ - final public function parameters() + final public function parameters(): ParametersConfigurator { return new ParametersConfigurator($this->container); } - /** - * @return ServicesConfigurator - */ - final public function services() + final public function services(): ServicesConfigurator { return new ServicesConfigurator($this->container, $this->loader, $this->instanceof); } @@ -82,24 +76,16 @@ final public function services() /** * Creates a service reference. - * - * @param string $id - * - * @return ReferenceConfigurator */ -function ref($id) +function ref(string $id): ReferenceConfigurator { return new ReferenceConfigurator($id); } /** * Creates an inline service. - * - * @param string|null $class - * - * @return InlineServiceConfigurator */ -function inline($class = null) +function inline(string $class = null): InlineServiceConfigurator { return new InlineServiceConfigurator(new Definition($class)); } @@ -108,34 +94,24 @@ function inline($class = null) * Creates a lazy iterator. * * @param ReferenceConfigurator[] $values - * - * @return IteratorArgument */ -function iterator(array $values) +function iterator(array $values): IteratorArgument { return new IteratorArgument(AbstractConfigurator::processValue($values, true)); } /** * Creates a lazy iterator by tag name. - * - * @param string $tag - * - * @return TaggedIteratorArgument */ -function tagged($tag) +function tagged(string $tag): TaggedIteratorArgument { return new TaggedIteratorArgument($tag); } /** * Creates an expression. - * - * @param string $expression an expression - * - * @return Expression */ -function expr($expression) +function expr(string $expression): Expression { return new Expression($expression); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php index adf294b9928d9..aec0b2bd21032 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php @@ -15,8 +15,6 @@ /** * @author Nicolas Grekas - * - * @method InstanceofConfigurator instanceof(string $fqcn) */ class DefaultsConfigurator extends AbstractServiceConfigurator { @@ -30,14 +28,11 @@ class DefaultsConfigurator extends AbstractServiceConfigurator /** * Adds a tag for this definition. * - * @param string $name The tag name - * @param array $attributes An array of attributes - * * @return $this * * @throws InvalidArgumentException when an invalid tag name or attribute is provided */ - final public function tag($name, array $attributes = array()) + final public function tag(string $name, array $attributes = array()) { if (!is_string($name) || '' === $name) { throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.'); @@ -57,11 +52,9 @@ final public function tag($name, array $attributes = array()) /** * Defines an instanceof-conditional to be applied to following service definitions. * - * @param string $fqcn - * * @return InstanceofConfigurator */ - final protected function setInstanceof($fqcn) + final public function instanceof(string $fqcn) { return $this->parent->instanceof($fqcn); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php index 1d3975bf8794e..9ecb2a21c3deb 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/InstanceofConfigurator.php @@ -13,8 +13,6 @@ /** * @author Nicolas Grekas - * - * @method InstanceofConfigurator instanceof(string $fqcn) */ class InstanceofConfigurator extends AbstractServiceConfigurator { @@ -31,12 +29,8 @@ class InstanceofConfigurator extends AbstractServiceConfigurator /** * Defines an instanceof-conditional to be applied to following service definitions. - * - * @param string $fqcn - * - * @return InstanceofConfigurator */ - final protected function setInstanceof($fqcn) + final public function instanceof(string $fqcn): InstanceofConfigurator { return $this->parent->instanceof($fqcn); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ParametersConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ParametersConfigurator.php index 9585b1a4b5c34..bacc60f05146d 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ParametersConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ParametersConfigurator.php @@ -30,12 +30,9 @@ public function __construct(ContainerBuilder $container) /** * Creates a parameter. * - * @param string $name - * @param mixed $value - * * @return $this */ - final public function set($name, $value) + final public function set(string $name, $value) { $this->container->setParameter($name, static::processValue($value, true)); @@ -45,12 +42,9 @@ final public function set($name, $value) /** * Creates a parameter. * - * @param string $name - * @param mixed $value - * * @return $this */ - final public function __invoke($name, $value) + final public function __invoke(string $name, $value) { return $this->set($name, $value); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php index 76e7829e8fe99..573dcc51e8204 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/PrototypeConfigurator.php @@ -42,7 +42,7 @@ class PrototypeConfigurator extends AbstractServiceConfigurator private $exclude; private $allowParent; - public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, $namespace, $resource, $allowParent) + public function __construct(ServicesConfigurator $parent, PhpFileLoader $loader, Definition $defaults, string $namespace, string $resource, bool $allowParent) { $definition = new Definition(); $definition->setPublic($defaults->isPublic()); @@ -71,11 +71,9 @@ public function __destruct() /** * Excludes files from registration using a glob pattern. * - * @param string $exclude - * * @return $this */ - final public function exclude($exclude) + final public function exclude(string $exclude) { $this->exclude = $exclude; diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php index 1585c0872a694..590b60a54a390 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ReferenceConfigurator.php @@ -24,7 +24,7 @@ class ReferenceConfigurator extends AbstractConfigurator /** @internal */ protected $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE; - public function __construct($id) + public function __construct(string $id) { $this->id = $id; } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php index 12054cad0c021..8fc60fbd376bd 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php @@ -46,7 +46,7 @@ class ServiceConfigurator extends AbstractServiceConfigurator private $instanceof; private $allowParent; - public function __construct(ContainerBuilder $container, array $instanceof, $allowParent, ServicesConfigurator $parent, Definition $definition, $id, array $defaultTags) + public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, $id, array $defaultTags) { $this->container = $container; $this->instanceof = $instanceof; diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php index c9673b6c7a730..686a40532f965 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServicesConfigurator.php @@ -20,8 +20,6 @@ /** * @author Nicolas Grekas - * - * @method InstanceofConfigurator instanceof($fqcn) */ class ServicesConfigurator extends AbstractConfigurator { @@ -43,22 +41,16 @@ public function __construct(ContainerBuilder $container, PhpFileLoader $loader, /** * Defines a set of defaults for following service definitions. - * - * @return DefaultsConfigurator */ - final public function defaults() + final public function defaults(): DefaultsConfigurator { return new DefaultsConfigurator($this, $this->defaults = new Definition()); } /** * Defines an instanceof-conditional to be applied to following service definitions. - * - * @param string $fqcn - * - * @return InstanceofConfigurator */ - final protected function setInstanceof($fqcn) + final public function instanceof(string $fqcn): InstanceofConfigurator { $this->instanceof[$fqcn] = $definition = new ChildDefinition(''); @@ -67,13 +59,8 @@ final protected function setInstanceof($fqcn) /** * Registers a service. - * - * @param string $id - * @param string|null $class - * - * @return ServiceConfigurator */ - final public function set($id, $class = null) + final public function set(string $id, string $class = null): ServiceConfigurator { $defaults = $this->defaults; $allowParent = !$defaults->getChanges() && empty($this->instanceof); @@ -92,13 +79,8 @@ final public function set($id, $class = null) /** * Creates an alias. - * - * @param string $id - * @param string $referencedId - * - * @return AliasConfigurator */ - final public function alias($id, $referencedId) + final public function alias(string $id, string $referencedId): AliasConfigurator { $ref = static::processValue($referencedId, true); $alias = new Alias((string) $ref, $this->defaults->isPublic()); @@ -109,13 +91,8 @@ final public function alias($id, $referencedId) /** * Registers a PSR-4 namespace using a glob pattern. - * - * @param string $namespace - * @param string $resource - * - * @return PrototypeConfigurator */ - final public function load($namespace, $resource) + final public function load(string $namespace, string $resource): PrototypeConfigurator { $allowParent = !$this->defaults->getChanges() && empty($this->instanceof); @@ -125,13 +102,9 @@ final public function load($namespace, $resource) /** * Gets an already defined service definition. * - * @param string $id - * - * @return ServiceConfigurator - * * @throws ServiceNotFoundException if the service definition does not exist */ - final public function get($id) + final public function get(string $id): ServiceConfigurator { $allowParent = !$this->defaults->getChanges() && empty($this->instanceof); $definition = $this->container->getDefinition($id); @@ -141,13 +114,8 @@ final public function get($id) /** * Registers a service. - * - * @param string $id - * @param string|null $class - * - * @return ServiceConfigurator */ - final public function __invoke($id, $class = null) + final public function __invoke(string $id, string $class = null): ServiceConfigurator { return $this->set($id, $class); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AbstractTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AbstractTrait.php index f69a7a5be109d..57ddb480facf3 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AbstractTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AbstractTrait.php @@ -11,20 +11,15 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator\Traits; -/** - * @method $this abstract(bool $abstract = true) - */ trait AbstractTrait { /** * Whether this definition is abstract, that means it merely serves as a * template for other definitions. * - * @param bool $abstract - * * @return $this */ - final protected function setAbstract($abstract = true) + final public function abstract(bool $abstract = true) { $this->definition->setAbstract($abstract); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutoconfigureTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutoconfigureTrait.php index 42a692353e9dc..a923b3fe59fd1 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutoconfigureTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutoconfigureTrait.php @@ -19,13 +19,11 @@ trait AutoconfigureTrait /** * Sets whether or not instanceof conditionals should be prepended with a global set. * - * @param bool $autoconfigured - * * @return $this * * @throws InvalidArgumentException when a parent is already set */ - final public function autoconfigure($autoconfigured = true) + final public function autoconfigure(bool $autoconfigured = true) { if ($autoconfigured && $this->definition instanceof ChildDefinition) { throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.', $this->id)); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutowireTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutowireTrait.php index 3d4b2e854b4c7..4c90af849a055 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutowireTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/AutowireTrait.php @@ -16,11 +16,9 @@ trait AutowireTrait /** * Enables/disables autowiring. * - * @param bool $autowired - * * @return $this */ - final public function autowire($autowired = true) + final public function autowire(bool $autowired = true) { $this->definition->setAutowired($autowired); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php index ae5b1c0a3d0c5..ef44afe6c1da7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php @@ -11,19 +11,14 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator\Traits; -/** - * @method $this class(string $class) - */ trait ClassTrait { /** * Sets the service class. * - * @param string $class The service class - * * @return $this */ - final protected function setClass($class) + final public function class($class) { $this->definition->setClass($class); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/LazyTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/LazyTrait.php index d7ea8b27f5ea3..2af867c19bb26 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/LazyTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/LazyTrait.php @@ -16,11 +16,9 @@ trait LazyTrait /** * Sets the lazy flag of this service. * - * @param bool $lazy - * * @return $this */ - final public function lazy($lazy = true) + final public function lazy(bool $lazy = true) { $this->definition->setLazy($lazy); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php index 43f1223e324a6..4eba03d7eebb8 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ParentTrait.php @@ -14,21 +14,16 @@ use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; -/** - * @method $this parent(string $parent) - */ trait ParentTrait { /** * Sets the Definition to inherit from. * - * @param string $parent - * * @return $this * * @throws InvalidArgumentException when parent cannot be set */ - final protected function setParent($parent) + final public function parent(string $parent) { if (!$this->allowParent) { throw new InvalidArgumentException(sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id)); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PropertyTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PropertyTrait.php index d5d938708e0a8..50c2ee863609d 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PropertyTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PropertyTrait.php @@ -16,12 +16,9 @@ trait PropertyTrait /** * Sets a specific property. * - * @param string $name - * @param mixed $value - * * @return $this */ - final public function property($name, $value) + final public function property(string $name, $value) { $this->definition->setProperty($name, static::processValue($value, true)); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PublicTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PublicTrait.php index 8f7f79f1cc218..9886523c95c95 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PublicTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/PublicTrait.php @@ -11,16 +11,12 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator\Traits; -/** - * @method $this public() - * @method $this private() - */ trait PublicTrait { /** * @return $this */ - final protected function setPublic() + final public function public() { $this->definition->setPublic(true); @@ -30,7 +26,7 @@ final protected function setPublic() /** * @return $this */ - final protected function setPrivate() + final public function private() { $this->definition->setPublic(false); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/SyntheticTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/SyntheticTrait.php index 81eceff43d86d..bf124f0a40178 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/SyntheticTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/SyntheticTrait.php @@ -17,11 +17,9 @@ trait SyntheticTrait * Sets whether this definition is synthetic, that is not constructed by the * container, but dynamically injected. * - * @param bool $synthetic - * * @return $this */ - final public function synthetic($synthetic = true) + final public function synthetic(bool $synthetic = true) { $this->definition->setSynthetic($synthetic); diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 9bb1ccb1e0223..346531bc6a952 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -166,13 +166,7 @@ public function supports($resource, $type = null) return in_array($type, array('yaml', 'yml'), true); } - /** - * Parses all imports. - * - * @param array $content - * @param string $file - */ - private function parseImports(array $content, $file) + private function parseImports(array $content, string $file) { if (!isset($content['imports'])) { return; @@ -196,13 +190,7 @@ private function parseImports(array $content, $file) } } - /** - * Parses definitions. - * - * @param array $content - * @param string $file - */ - private function parseDefinitions(array $content, $file) + private function parseDefinitions(array $content, string $file) { if (!isset($content['services'])) { return; @@ -240,14 +228,9 @@ private function parseDefinitions(array $content, $file) } /** - * @param array $content - * @param string $file - * - * @return array - * * @throws InvalidArgumentException */ - private function parseDefaults(array &$content, $file) + private function parseDefaults(array &$content, string $file): array { if (!array_key_exists('_defaults', $content['services'])) { return array(); @@ -304,12 +287,7 @@ private function parseDefaults(array &$content, $file) return $defaults; } - /** - * @param array $service - * - * @return bool - */ - private function isUsingShortSyntax(array $service) + private function isUsingShortSyntax(array $service): bool { foreach ($service as $key => $value) { if (is_string($key) && ('' === $key || '$' !== $key[0])) { diff --git a/src/Symfony/Component/DependencyInjection/Parameter.php b/src/Symfony/Component/DependencyInjection/Parameter.php index cac6f6c4c2264..d484ac0f947eb 100644 --- a/src/Symfony/Component/DependencyInjection/Parameter.php +++ b/src/Symfony/Component/DependencyInjection/Parameter.php @@ -20,10 +20,7 @@ class Parameter { private $id; - /** - * @param string $id The parameter key - */ - public function __construct($id) + public function __construct(string $id) { $this->id = $id; } @@ -33,6 +30,6 @@ public function __construct($id) */ public function __toString() { - return (string) $this->id; + return $this->id; } } diff --git a/src/Symfony/Component/DependencyInjection/Reference.php b/src/Symfony/Component/DependencyInjection/Reference.php index 82906d2b7524c..c13cf6fe4cc86 100644 --- a/src/Symfony/Component/DependencyInjection/Reference.php +++ b/src/Symfony/Component/DependencyInjection/Reference.php @@ -21,15 +21,9 @@ class Reference private $id; private $invalidBehavior; - /** - * @param string $id The service identifier - * @param int $invalidBehavior The behavior when the service does not exist - * - * @see Container - */ - public function __construct($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + public function __construct(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { - $this->id = (string) $id; + $this->id = $id; $this->invalidBehavior = $invalidBehavior; } diff --git a/src/Symfony/Component/DependencyInjection/TypedReference.php b/src/Symfony/Component/DependencyInjection/TypedReference.php index aad78e806b6b6..dc869ec9b101e 100644 --- a/src/Symfony/Component/DependencyInjection/TypedReference.php +++ b/src/Symfony/Component/DependencyInjection/TypedReference.php @@ -27,7 +27,7 @@ class TypedReference extends Reference * @param string $requiringClass The class of the service that requires the referenced type * @param int $invalidBehavior The behavior when the service does not exist */ - public function __construct($id, $type, $requiringClass = '', $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + public function __construct(string $id, string $type, string $requiringClass = '', int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { parent::__construct($id, $invalidBehavior); $this->type = $type; diff --git a/src/Symfony/Component/DependencyInjection/Variable.php b/src/Symfony/Component/DependencyInjection/Variable.php index 9654ee4ddc6d8..95e28d60ed302 100644 --- a/src/Symfony/Component/DependencyInjection/Variable.php +++ b/src/Symfony/Component/DependencyInjection/Variable.php @@ -28,10 +28,7 @@ class Variable { private $name; - /** - * @param string $name - */ - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } diff --git a/src/Symfony/Component/DomCrawler/AbstractUriElement.php b/src/Symfony/Component/DomCrawler/AbstractUriElement.php index d602d6f3316bf..b477c7142269f 100644 --- a/src/Symfony/Component/DomCrawler/AbstractUriElement.php +++ b/src/Symfony/Component/DomCrawler/AbstractUriElement.php @@ -36,11 +36,11 @@ abstract class AbstractUriElement /** * @param \DOMElement $node A \DOMElement instance * @param string $currentUri The URI of the page where the link is embedded (or the base href) - * @param string $method The method to use for the link (get by default) + * @param string $method The method to use for the link (GET by default) * * @throws \InvalidArgumentException if the node is not a link */ - public function __construct(\DOMElement $node, $currentUri, $method = 'GET') + public function __construct(\DOMElement $node, string $currentUri, ?string $method = 'GET') { if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) { throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri)); @@ -168,24 +168,16 @@ abstract protected function setNode(\DOMElement $node); /** * Removes the query string and the anchor from the given uri. - * - * @param string $uri The uri to clean - * - * @return string */ - private function cleanupUri($uri) + private function cleanupUri(string $uri): string { return $this->cleanupQuery($this->cleanupAnchor($uri)); } /** * Remove the query string from the uri. - * - * @param string $uri - * - * @return string */ - private function cleanupQuery($uri) + private function cleanupQuery(string $uri): string { if (false !== $pos = strpos($uri, '?')) { return substr($uri, 0, $pos); @@ -196,12 +188,8 @@ private function cleanupQuery($uri) /** * Remove the anchor from the uri. - * - * @param string $uri - * - * @return string */ - private function cleanupAnchor($uri) + private function cleanupAnchor(string $uri): string { if (false !== $pos = strpos($uri, '#')) { return substr($uri, 0, $pos); diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index ac75ee3d3d1ab..e13b94fb5838b 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -59,7 +59,7 @@ class Crawler implements \Countable, \IteratorAggregate * @param string $uri The current URI * @param string $baseHref The base href value */ - public function __construct($node = null, $uri = null, $baseHref = null) + public function __construct($node = null, string $uri = null, string $baseHref = null) { $this->uri = $uri; $this->baseHref = $baseHref ?: $uri; @@ -958,12 +958,8 @@ private function filterRelativeXPath($xpath) * * The returned XPath will match elements matching the XPath inside the current crawler * when running in the context of a node of the crawler. - * - * @param string $xpath - * - * @return string */ - private function relativize($xpath) + private function relativize(string $xpath): string { $expressions = array(); @@ -1095,14 +1091,9 @@ protected function sibling($node, $siblingDir = 'nextSibling') } /** - * @param \DOMDocument $document - * @param array $prefixes - * - * @return \DOMXPath - * * @throws \InvalidArgumentException */ - private function createDOMXPath(\DOMDocument $document, array $prefixes = array()) + private function createDOMXPath(\DOMDocument $document, array $prefixes = array()): \DOMXPath { $domxpath = new \DOMXPath($document); @@ -1117,14 +1108,9 @@ private function createDOMXPath(\DOMDocument $document, array $prefixes = array( } /** - * @param \DOMXPath $domxpath - * @param string $prefix - * - * @return string - * * @throws \InvalidArgumentException */ - private function discoverNamespace(\DOMXPath $domxpath, $prefix) + private function discoverNamespace(\DOMXPath $domxpath, string $prefix): string { if (isset($this->namespaces[$prefix])) { return $this->namespaces[$prefix]; @@ -1138,12 +1124,7 @@ private function discoverNamespace(\DOMXPath $domxpath, $prefix) } } - /** - * @param string $xpath - * - * @return array - */ - private function findNamespacePrefixes($xpath) + private function findNamespacePrefixes(string $xpath): array { if (preg_match_all('/(?P[a-z_][a-z_0-9\-\.]*+):[^"\/:]/i', $xpath, $matches)) { return array_unique($matches['prefix']); diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index c479daa75ee78..6d321e0282f6c 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -254,12 +254,8 @@ protected function initialize() /** * Returns option value with associated disabled flag. - * - * @param \DOMElement $node - * - * @return array */ - private function buildOptionValue(\DOMElement $node) + private function buildOptionValue(\DOMElement $node): array { $option = array(); diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 8eaae3e3891e5..473e3919d6a29 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -44,7 +44,7 @@ class Form extends Link implements \ArrayAccess * * @throws \LogicException if the node is not a button inside a form tag */ - public function __construct(\DOMElement $node, $currentUri, $method = null, $baseHref = null) + public function __construct(\DOMElement $node, string $currentUri, string $method = null, string $baseHref = null) { parent::__construct($node, $currentUri, $method); $this->baseHref = $baseHref; diff --git a/src/Symfony/Component/DomCrawler/Image.php b/src/Symfony/Component/DomCrawler/Image.php index 4d6403258057c..fb83eaac1989d 100644 --- a/src/Symfony/Component/DomCrawler/Image.php +++ b/src/Symfony/Component/DomCrawler/Image.php @@ -16,7 +16,7 @@ */ class Image extends AbstractUriElement { - public function __construct(\DOMElement $node, $currentUri) + public function __construct(\DOMElement $node, string $currentUri) { parent::__construct($node, $currentUri, 'GET'); } diff --git a/src/Symfony/Component/Dotenv/Exception/FormatException.php b/src/Symfony/Component/Dotenv/Exception/FormatException.php index 26f1442b695a5..f845d7bde1e88 100644 --- a/src/Symfony/Component/Dotenv/Exception/FormatException.php +++ b/src/Symfony/Component/Dotenv/Exception/FormatException.php @@ -20,7 +20,7 @@ final class FormatException extends \LogicException implements ExceptionInterfac { private $context; - public function __construct($message, FormatExceptionContext $context, $code = 0, \Exception $previous = null) + public function __construct(string $message, FormatExceptionContext $context, int $code = 0, \Exception $previous = null) { $this->context = $context; diff --git a/src/Symfony/Component/Dotenv/Exception/FormatExceptionContext.php b/src/Symfony/Component/Dotenv/Exception/FormatExceptionContext.php index 70d2ef11df3fb..995477cf898be 100644 --- a/src/Symfony/Component/Dotenv/Exception/FormatExceptionContext.php +++ b/src/Symfony/Component/Dotenv/Exception/FormatExceptionContext.php @@ -21,7 +21,7 @@ final class FormatExceptionContext private $lineno; private $cursor; - public function __construct($data, $path, $lineno, $cursor) + public function __construct(string $data, string $path, int $lineno, int $cursor) { $this->data = $data; $this->path = $path; diff --git a/src/Symfony/Component/Dotenv/Exception/PathException.php b/src/Symfony/Component/Dotenv/Exception/PathException.php index ac4d540ff4831..6a82e94100ec1 100644 --- a/src/Symfony/Component/Dotenv/Exception/PathException.php +++ b/src/Symfony/Component/Dotenv/Exception/PathException.php @@ -18,7 +18,7 @@ */ final class PathException extends \RuntimeException implements ExceptionInterface { - public function __construct($path, $code = 0, \Exception $previous = null) + public function __construct(string $path, int $code = 0, \Exception $previous = null) { parent::__construct(sprintf('Unable to read the "%s" environment file.', $path), $code, $previous); } diff --git a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php index 0b5f5629971e2..852329052ab7d 100644 --- a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php @@ -28,12 +28,7 @@ class RegisterListenersPass implements CompilerPassInterface protected $listenerTag; protected $subscriberTag; - /** - * @param string $dispatcherService Service name of the event dispatcher in processed container - * @param string $listenerTag Tag name used for listener - * @param string $subscriberTag Tag name used for subscribers - */ - public function __construct($dispatcherService = 'event_dispatcher', $listenerTag = 'kernel.event_listener', $subscriberTag = 'kernel.event_subscriber') + public function __construct(string $dispatcherService = 'event_dispatcher', string $listenerTag = 'kernel.event_listener', string $subscriberTag = 'kernel.event_subscriber') { $this->dispatcherService = $dispatcherService; $this->listenerTag = $listenerTag; diff --git a/src/Symfony/Component/ExpressionLanguage/Expression.php b/src/Symfony/Component/ExpressionLanguage/Expression.php index ac656cce033bf..59d0e2a6a524d 100644 --- a/src/Symfony/Component/ExpressionLanguage/Expression.php +++ b/src/Symfony/Component/ExpressionLanguage/Expression.php @@ -20,12 +20,9 @@ class Expression { protected $expression; - /** - * @param string $expression An expression - */ - public function __construct($expression) + public function __construct(string $expression) { - $this->expression = (string) $expression; + $this->expression = $expression; } /** diff --git a/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php b/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php index ad775dbd9472c..448cd466f095e 100644 --- a/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php +++ b/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php @@ -39,7 +39,7 @@ class ExpressionFunction * @param callable $compiler A callable able to compile the function * @param callable $evaluator A callable able to evaluate the function */ - public function __construct($name, callable $compiler, callable $evaluator) + public function __construct(string $name, callable $compiler, callable $evaluator) { $this->name = $name; $this->compiler = $compiler; diff --git a/src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php b/src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php index 33b4c8f089ade..26b456145c1c3 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php @@ -33,7 +33,7 @@ class BinaryNode extends Node 'not in' => '!in_array', ); - public function __construct($operator, Node $left, Node $right) + public function __construct(string $operator, Node $left, Node $right) { parent::__construct( array('left' => $left, 'right' => $right), diff --git a/src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php b/src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php index 733d481b28183..d1bd7c69e8d4d 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php @@ -22,7 +22,7 @@ class ConstantNode extends Node { private $isIdentifier; - public function __construct($value, $isIdentifier = false) + public function __construct($value, bool $isIdentifier = false) { $this->isIdentifier = $isIdentifier; parent::__construct( diff --git a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php index 13928c8d4f830..e3424b50d4ba2 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php @@ -20,7 +20,7 @@ */ class FunctionNode extends Node { - public function __construct($name, Node $arguments) + public function __construct(string $name, Node $arguments) { parent::__construct( array('arguments' => $arguments), diff --git a/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php b/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php index 2ecba97f7f6ad..bafd227b48eda 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php @@ -24,7 +24,7 @@ class GetAttrNode extends Node const METHOD_CALL = 2; const ARRAY_CALL = 3; - public function __construct(Node $node, Node $attribute, ArrayNode $arguments, $type) + public function __construct(Node $node, Node $attribute, ArrayNode $arguments, int $type) { parent::__construct( array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments), diff --git a/src/Symfony/Component/ExpressionLanguage/Node/NameNode.php b/src/Symfony/Component/ExpressionLanguage/Node/NameNode.php index 9e1462f2c6798..c084bd4793c50 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/NameNode.php +++ b/src/Symfony/Component/ExpressionLanguage/Node/NameNode.php @@ -20,7 +20,7 @@ */ class NameNode extends Node { - public function __construct($name) + public function __construct(string $name) { parent::__construct( array(), diff --git a/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php b/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php index a5603fc3ca96d..2e2bf374e31a2 100644 --- a/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php +++ b/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php @@ -26,7 +26,7 @@ class ParsedExpression extends Expression * @param string $expression An expression * @param Node $nodes A Node representing the expression */ - public function __construct($expression, Node $nodes) + public function __construct(string $expression, Node $nodes) { parent::__construct($expression); diff --git a/src/Symfony/Component/ExpressionLanguage/SerializedParsedExpression.php b/src/Symfony/Component/ExpressionLanguage/SerializedParsedExpression.php index dd763f75b524d..a1f838c030232 100644 --- a/src/Symfony/Component/ExpressionLanguage/SerializedParsedExpression.php +++ b/src/Symfony/Component/ExpressionLanguage/SerializedParsedExpression.php @@ -24,9 +24,9 @@ class SerializedParsedExpression extends ParsedExpression * @param string $expression An expression * @param string $nodes The serialized nodes for the expression */ - public function __construct($expression, $nodes) + public function __construct(string $expression, string $nodes) { - $this->expression = (string) $expression; + $this->expression = $expression; $this->nodes = $nodes; } diff --git a/src/Symfony/Component/ExpressionLanguage/SyntaxError.php b/src/Symfony/Component/ExpressionLanguage/SyntaxError.php index 12348e6830836..d3313b83219fd 100644 --- a/src/Symfony/Component/ExpressionLanguage/SyntaxError.php +++ b/src/Symfony/Component/ExpressionLanguage/SyntaxError.php @@ -13,7 +13,7 @@ class SyntaxError extends \LogicException { - public function __construct($message, $cursor = 0, $expression = '', $subject = null, array $proposals = null) + public function __construct(string $message, int $cursor = 0, string $expression = '', string $subject = null, array $proposals = null) { $message = sprintf('%s around position %d', $message, $cursor); if ($expression) { diff --git a/src/Symfony/Component/ExpressionLanguage/Token.php b/src/Symfony/Component/ExpressionLanguage/Token.php index b231bc25e73f2..3d3c484375bfe 100644 --- a/src/Symfony/Component/ExpressionLanguage/Token.php +++ b/src/Symfony/Component/ExpressionLanguage/Token.php @@ -34,7 +34,7 @@ class Token * @param string $value The token value * @param int $cursor The cursor position in the source */ - public function __construct($type, $value, $cursor) + public function __construct(string $type, ?string $value, ?int $cursor) { $this->type = $type; $this->value = $value; diff --git a/src/Symfony/Component/ExpressionLanguage/TokenStream.php b/src/Symfony/Component/ExpressionLanguage/TokenStream.php index 9426bfeb7e287..8bdafb0793208 100644 --- a/src/Symfony/Component/ExpressionLanguage/TokenStream.php +++ b/src/Symfony/Component/ExpressionLanguage/TokenStream.php @@ -24,11 +24,7 @@ class TokenStream private $position = 0; private $expression; - /** - * @param array $tokens An array of tokens - * @param string $expression - */ - public function __construct(array $tokens, $expression = '') + public function __construct(array $tokens, string $expression = '') { $this->tokens = $tokens; $this->current = $tokens[0]; diff --git a/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php b/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php index bcc8fe81fcef4..f941b536e7a22 100644 --- a/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php +++ b/src/Symfony/Component/Filesystem/Exception/FileNotFoundException.php @@ -19,7 +19,7 @@ */ class FileNotFoundException extends IOException { - public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null) + public function __construct(string $message = null, int $code = 0, \Exception $previous = null, string $path = null) { if (null === $message) { if (null === $path) { diff --git a/src/Symfony/Component/Filesystem/Exception/IOException.php b/src/Symfony/Component/Filesystem/Exception/IOException.php index 144e0e602bdfe..f02cbd885cfca 100644 --- a/src/Symfony/Component/Filesystem/Exception/IOException.php +++ b/src/Symfony/Component/Filesystem/Exception/IOException.php @@ -22,7 +22,7 @@ class IOException extends \RuntimeException implements IOExceptionInterface { private $path; - public function __construct($message, $code = 0, \Exception $previous = null, $path = null) + public function __construct(string $message, int $code = 0, \Exception $previous = null, string $path = null) { $this->path = $path; diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index cacda17f899c5..d8cf9ddba5aba 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -740,12 +740,8 @@ private function toIterator($files) /** * Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> array(file, tmp)). - * - * @param string $filename The filename to be parsed - * - * @return array The filename scheme and hierarchical part */ - private function getSchemeAndHierarchy($filename) + private function getSchemeAndHierarchy(string $filename): array { $components = explode('://', $filename, 2); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index be5b9e30f2c2d..33d2b4b406bab 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1602,12 +1602,8 @@ public function testCopyShouldKeepExecutionPermission() /** * Normalize the given path (transform each blackslash into a real directory separator). - * - * @param string $path - * - * @return string */ - private function normalize($path) + private function normalize(string $path): string { return str_replace('/', DIRECTORY_SEPARATOR, $path); } diff --git a/src/Symfony/Component/Finder/Comparator/DateComparator.php b/src/Symfony/Component/Finder/Comparator/DateComparator.php index 3de43ef4b8ddb..d17c77a9d3fd0 100644 --- a/src/Symfony/Component/Finder/Comparator/DateComparator.php +++ b/src/Symfony/Component/Finder/Comparator/DateComparator.php @@ -23,7 +23,7 @@ class DateComparator extends Comparator * * @throws \InvalidArgumentException If the test is not understood */ - public function __construct($test) + public function __construct(string $test) { if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) { throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test)); diff --git a/src/Symfony/Component/Finder/Comparator/NumberComparator.php b/src/Symfony/Component/Finder/Comparator/NumberComparator.php index f62c0e5740f69..80667c9dddd51 100644 --- a/src/Symfony/Component/Finder/Comparator/NumberComparator.php +++ b/src/Symfony/Component/Finder/Comparator/NumberComparator.php @@ -39,7 +39,7 @@ class NumberComparator extends Comparator * * @throws \InvalidArgumentException If the test is not understood */ - public function __construct($test) + public function __construct(?string $test) { if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) { throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test)); diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 07dce771b4fc9..1dab061f879eb 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -630,12 +630,7 @@ public function count() return iterator_count($this->getIterator()); } - /** - * @param $dir - * - * @return \Iterator - */ - private function searchInDirectory($dir) + private function searchInDirectory(string $dir): \Iterator { if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) { $this->exclude = array_merge($this->exclude, self::$vcsPatterns); diff --git a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php index 9408a278157ab..436a66d84b99b 100644 --- a/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php @@ -25,7 +25,7 @@ class DepthRangeFilterIterator extends \FilterIterator * @param int $minDepth The min depth * @param int $maxDepth The max depth */ - public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX) + public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = PHP_INT_MAX) { $this->minDepth = $minDepth; $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth); diff --git a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php index 0c40a3c729065..a4c4eec72e90d 100644 --- a/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php @@ -27,7 +27,7 @@ class FileTypeFilterIterator extends \FilterIterator * @param \Iterator $iterator The Iterator to filter * @param int $mode The mode (self::ONLY_FILES or self::ONLY_DIRECTORIES) */ - public function __construct(\Iterator $iterator, $mode) + public function __construct(\Iterator $iterator, int $mode) { $this->mode = $mode; diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index 451c3df180c56..acd5a37634abe 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -37,13 +37,9 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator private $directorySeparator = '/'; /** - * @param string $path - * @param int $flags - * @param bool $ignoreUnreadableDirs - * * @throws \RuntimeException */ - public function __construct($path, $flags, $ignoreUnreadableDirs = false) + public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs = false) { if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) { throw new \RuntimeException('This iterator only support returning current as fileinfo.'); diff --git a/src/Symfony/Component/Finder/SplFileInfo.php b/src/Symfony/Component/Finder/SplFileInfo.php index 19f95e26be69a..6516113a3ece4 100644 --- a/src/Symfony/Component/Finder/SplFileInfo.php +++ b/src/Symfony/Component/Finder/SplFileInfo.php @@ -26,7 +26,7 @@ class SplFileInfo extends \SplFileInfo * @param string $relativePath The relative path * @param string $relativePathname The relative path name */ - public function __construct($file, $relativePath, $relativePathname) + public function __construct(string $file, string $relativePath, string $relativePathname) { parent::__construct($file); $this->relativePath = $relativePath; diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 7864116d23dcb..c49a49f8ada9c 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -53,17 +53,11 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface private $options; /** - * Creates a new button builder. - * - * @param string $name The name of the button - * @param array $options The button's options - * * @throws InvalidArgumentException if the name is empty */ - public function __construct($name, array $options = array()) + public function __construct(?string $name, array $options = array()) { - $name = (string) $name; - if ('' === $name) { + if ('' === $name || null === $name) { throw new InvalidArgumentException('Buttons cannot have empty names.'); } diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index 51c43bf07c3ef..8d8b20b0c61a4 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -62,7 +62,7 @@ class ArrayChoiceList implements ChoiceListInterface * incrementing integers are used as * values */ - public function __construct($choices, callable $value = null) + public function __construct(iterable $choices, callable $value = null) { if ($choices instanceof \Traversable) { $choices = iterator_to_array($choices); diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php index 8feed2106e27b..eb27f0891dd33 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php @@ -35,7 +35,7 @@ class ChoiceView * @param string $label The label displayed to humans * @param array $attr Additional attributes for the HTML tag */ - public function __construct($data, $value, $label, array $attr = array()) + public function __construct($data, string $value, $label, array $attr = array()) { $this->data = $data; $this->value = $value; diff --git a/src/Symfony/Component/Form/DependencyInjection/FormPass.php b/src/Symfony/Component/Form/DependencyInjection/FormPass.php index bed74532d1571..b52e03e46f4b2 100644 --- a/src/Symfony/Component/Form/DependencyInjection/FormPass.php +++ b/src/Symfony/Component/Form/DependencyInjection/FormPass.php @@ -36,7 +36,7 @@ class FormPass implements CompilerPassInterface private $formTypeGuesserTag; private $formDebugCommandService; - public function __construct($formExtensionService = 'form.extension', $formTypeTag = 'form.type', $formTypeExtensionTag = 'form.type_extension', $formTypeGuesserTag = 'form.type_guesser', $formDebugCommandService = DebugCommand::class) + public function __construct(string $formExtensionService = 'form.extension', string $formTypeTag = 'form.type', string $formTypeExtensionTag = 'form.type_extension', string $formTypeGuesserTag = 'form.type_guesser', string $formDebugCommandService = DebugCommand::class) { $this->formExtensionService = $formExtensionService; $this->formTypeTag = $formTypeTag; diff --git a/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php index 474e244bd84b8..77a5c79d97f25 100644 --- a/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/Form/Exception/UnexpectedTypeException.php @@ -13,7 +13,7 @@ class UnexpectedTypeException extends InvalidArgumentException { - public function __construct($value, $expectedType) + public function __construct($value, string $expectedType) { parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php index 44fa3d8119878..a442742fff868 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php @@ -36,7 +36,7 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface * @throws UnexpectedTypeException if a timezone is not a string * @throws InvalidArgumentException if a timezone is not valid */ - public function __construct($inputTimezone = null, $outputTimezone = null) + public function __construct(string $inputTimezone = null, string $outputTimezone = null) { if (null !== $inputTimezone && !is_string($inputTimezone)) { throw new UnexpectedTypeException($inputTimezone, 'string'); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php index 592d90862f06d..21435ba5cbaf6 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php @@ -27,7 +27,7 @@ class BooleanToStringTransformer implements DataTransformerInterface /** * @param string $trueValue The value emitted upon transform if the input is true */ - public function __construct($trueValue) + public function __construct(string $trueValue) { $this->trueValue = $trueValue; } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php index f5004241f3a99..e0a4226cab165 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php @@ -46,13 +46,13 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface * @param string[] $fields The date fields * @param bool $pad Whether to use padding */ - public function __construct(array $fields = null, $pad = false) + public function __construct(array $fields = null, bool $pad = false) { if (null === $fields) { $fields = array('years', 'months', 'days', 'hours', 'minutes', 'seconds', 'invert'); } $this->fields = $fields; - $this->pad = (bool) $pad; + $this->pad = $pad; } /** diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php index dffe146623772..0cacac0dc6422 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php @@ -33,7 +33,7 @@ class DateIntervalToStringTransformer implements DataTransformerInterface * @param string $format The date format * @param bool $parseSigned Whether to parse as a signed interval */ - public function __construct($format = 'P%yY%mM%dDT%hH%iM%sS', $parseSigned = false) + public function __construct(string $format = 'P%yY%mM%dDT%hH%iM%sS', bool $parseSigned = false) { $this->format = $format; $this->parseSigned = $parseSigned; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php index 3ddd4675fa7a4..cacedf83c3dae 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php @@ -34,7 +34,7 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer * * @throws UnexpectedTypeException if a timezone is not a string */ - public function __construct($inputTimezone = null, $outputTimezone = null, array $fields = null, $pad = false) + public function __construct(string $inputTimezone = null, string $outputTimezone = null, array $fields = null, bool $pad = false) { parent::__construct($inputTimezone, $outputTimezone); @@ -43,7 +43,7 @@ public function __construct($inputTimezone = null, $outputTimezone = null, array } $this->fields = $fields; - $this->pad = (bool) $pad; + $this->pad = $pad; } /** diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index dda3414b75f2c..12af9dc11a764 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -39,7 +39,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer * * @throws UnexpectedTypeException If a format is not supported or if a timezone is not a string */ - public function __construct($inputTimezone = null, $outputTimezone = null, $dateFormat = null, $timeFormat = null, $calendar = \IntlDateFormatter::GREGORIAN, $pattern = null) + public function __construct(string $inputTimezone = null, string $outputTimezone = null, int $dateFormat = null, int $timeFormat = null, int $calendar = \IntlDateFormatter::GREGORIAN, string $pattern = null) { parent::__construct($inputTimezone, $outputTimezone); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index 82f912041265d..a30fa6728350b 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -51,7 +51,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer * * @throws UnexpectedTypeException if a timezone is not a string */ - public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s') + public function __construct(string $inputTimezone = null, string $outputTimezone = null, string $format = 'Y-m-d H:i:s') { parent::__construct($inputTimezone, $outputTimezone); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeZoneToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeZoneToStringTransformer.php index 7e133c2e9b3b9..978a646907985 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeZoneToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeZoneToStringTransformer.php @@ -23,7 +23,7 @@ class DateTimeZoneToStringTransformer implements DataTransformerInterface { private $multiple; - public function __construct($multiple = false) + public function __construct(bool $multiple = false) { $this->multiple = $multiple; } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php index 999e47391b576..760e8aa664bbc 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php @@ -26,7 +26,7 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo * @param bool $grouping Whether thousands should be grouped * @param int $roundingMode One of the ROUND_ constants in this class */ - public function __construct($scale = 0, $grouping = false, $roundingMode = self::ROUND_DOWN) + public function __construct(?int $scale = 0, ?bool $grouping = false, int $roundingMode = self::ROUND_DOWN) { if (null === $roundingMode) { $roundingMode = self::ROUND_DOWN; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php index 7449fedfc69cc..787805e2abcf2 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php @@ -23,7 +23,7 @@ class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransform { private $divisor; - public function __construct($scale = 2, $grouping = true, $roundingMode = self::ROUND_HALF_UP, $divisor = 1) + public function __construct(?int $scale = 2, ?bool $grouping = true, ?int $roundingMode = self::ROUND_HALF_UP, ?int $divisor = 1) { if (null === $grouping) { $grouping = true; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 9a22169d76d27..d513caffc779a 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -78,7 +78,7 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface private $scale; - public function __construct($scale = null, $grouping = false, $roundingMode = self::ROUND_HALF_UP) + public function __construct(int $scale = null, ?bool $grouping = false, ?int $roundingMode = self::ROUND_HALF_UP) { if (null === $grouping) { $grouping = false; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php index b843aa1823bda..0ac32d5e2f09c 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php @@ -42,7 +42,7 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface * * @throws UnexpectedTypeException if the given value of type is unknown */ - public function __construct($scale = null, $type = null) + public function __construct(int $scale = null, string $type = null) { if (null === $scale) { $scale = 0; diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php index cfaee9f06dc69..aba9da676ae24 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php @@ -27,7 +27,7 @@ class FixUrlProtocolListener implements EventSubscriberInterface /** * @param string|null $defaultProtocol The URL scheme to add when there is none or null to not modify the data */ - public function __construct($defaultProtocol = 'http') + public function __construct(?string $defaultProtocol = 'http') { $this->defaultProtocol = $defaultProtocol; } diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php index 698a95de2d48a..2a99581e7517f 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php @@ -28,7 +28,7 @@ class MergeCollectionListener implements EventSubscriberInterface * @param bool $allowAdd Whether values might be added to the collection * @param bool $allowDelete Whether values might be removed from the collection */ - public function __construct($allowAdd = false, $allowDelete = false) + public function __construct(bool $allowAdd = false, bool $allowDelete = false) { $this->allowAdd = $allowAdd; $this->allowDelete = $allowDelete; diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php index a2f35d0c771b6..d4b36b921e1bf 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php @@ -38,7 +38,7 @@ class ResizeFormListener implements EventSubscriberInterface * @param bool $allowDelete Whether children could be removed from the group * @param bool|callable $deleteEmpty */ - public function __construct($type, array $options = array(), $allowAdd = false, $allowDelete = false, $deleteEmpty = false) + public function __construct(string $type, array $options = array(), bool $allowAdd = false, bool $allowDelete = false, $deleteEmpty = false) { $this->type = $type; $this->allowAdd = $allowAdd; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index fe4183489dc77..d9df942c6af30 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -368,7 +368,7 @@ private function addSubForms(FormBuilderInterface $builder, array $choiceViews, /** * @return mixed */ - private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $choiceView, array $options) + private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceView $choiceView, array $options) { $choiceOpts = array( 'value' => $choiceView->value, diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php index 3f1a223d371ab..3adf18e84fc9c 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php @@ -71,12 +71,8 @@ public function getBlockPrefix() /** * Returns a normalized array of timezone choices. - * - * @param int $regions - * - * @return array The timezone choices */ - private static function getTimezones($regions) + private static function getTimezones(int $regions): array { $timezones = array(); diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfExtension.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfExtension.php index 3331b6b3baad0..865f756e5521a 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfExtension.php +++ b/src/Symfony/Component/Form/Extension/Csrf/CsrfExtension.php @@ -31,7 +31,7 @@ class CsrfExtension extends AbstractExtension * @param TranslatorInterface $translator The translator for translating error messages * @param null|string $translationDomain The translation domain for translating */ - public function __construct(CsrfTokenManagerInterface $tokenManager, TranslatorInterface $translator = null, $translationDomain = null) + public function __construct(CsrfTokenManagerInterface $tokenManager, TranslatorInterface $translator = null, string $translationDomain = null) { $this->tokenManager = $tokenManager; $this->translator = $translator; diff --git a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php index 9eab35ed26b90..9774304a152a9 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php @@ -40,7 +40,7 @@ public static function getSubscribedEvents() ); } - public function __construct($fieldName, CsrfTokenManagerInterface $tokenManager, $tokenId, $errorMessage, TranslatorInterface $translator = null, $translationDomain = null, ServerParams $serverParams = null) + public function __construct(string $fieldName, CsrfTokenManagerInterface $tokenManager, string $tokenId, string $errorMessage, TranslatorInterface $translator = null, string $translationDomain = null, ServerParams $serverParams = null) { $this->fieldName = $fieldName; $this->tokenManager = $tokenManager; diff --git a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php index f7f9bc0d9152d..5a24d6574ace4 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php +++ b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php @@ -33,15 +33,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension private $translationDomain; private $serverParams; - /** - * @param CsrfTokenManagerInterface $defaultTokenManager - * @param bool $defaultEnabled - * @param string $defaultFieldName - * @param TranslatorInterface $translator - * @param null|string $translationDomain - * @param ServerParams $serverParams - */ - public function __construct(CsrfTokenManagerInterface $defaultTokenManager, $defaultEnabled = true, $defaultFieldName = '_token', TranslatorInterface $translator = null, $translationDomain = null, ServerParams $serverParams = null) + public function __construct(CsrfTokenManagerInterface $defaultTokenManager, bool $defaultEnabled = true, string $defaultFieldName = '_token', TranslatorInterface $translator = null, string $translationDomain = null, ServerParams $serverParams = null) { $this->defaultTokenManager = $defaultTokenManager; $this->defaultEnabled = $defaultEnabled; diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index 77cba8c3ae91a..e261fa4f7b830 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -29,7 +29,7 @@ class DependencyInjectionExtension implements FormExtensionInterface * @param iterable[] $typeExtensionServices * @param iterable $guesserServices */ - public function __construct(ContainerInterface $typeContainer, array $typeExtensionServices, $guesserServices) + public function __construct(ContainerInterface $typeContainer, array $typeExtensionServices, iterable $guesserServices) { $this->typeContainer = $typeContainer; $this->typeExtensionServices = $typeExtensionServices; diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php index 6f1f632118c81..25bc229fa3e25 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php @@ -25,11 +25,7 @@ class UploadValidatorExtension extends AbstractTypeExtension private $translator; private $translationDomain; - /** - * @param TranslatorInterface $translator The translator for translating error messages - * @param null|string $translationDomain The translation domain for translating - */ - public function __construct(TranslatorInterface $translator, $translationDomain = null) + public function __construct(TranslatorInterface $translator, string $translationDomain = null) { $this->translator = $translator; $this->translationDomain = $translationDomain; diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php index 1fac736e8c9eb..4f31227408ff4 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php @@ -23,12 +23,7 @@ class MappingRule private $propertyPath; private $targetPath; - /** - * @param FormInterface $origin - * @param string $propertyPath - * @param string $targetPath - */ - public function __construct(FormInterface $origin, $propertyPath, $targetPath) + public function __construct(FormInterface $origin, string $propertyPath, string $targetPath) { $this->origin = $origin; $this->propertyPath = $propertyPath; diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/RelativePath.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/RelativePath.php index 658bad5a48f50..0efd168e3dc99 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/RelativePath.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/RelativePath.php @@ -21,11 +21,7 @@ class RelativePath extends PropertyPath { private $root; - /** - * @param FormInterface $root - * @param string $propertyPath - */ - public function __construct(FormInterface $root, $propertyPath) + public function __construct(FormInterface $root, string $propertyPath) { parent::__construct($propertyPath); diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php index 007968ab4c24b..72c4cacfec7fe 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php @@ -50,7 +50,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface * * @param string $violationPath The property path of a {@link \Symfony\Component\Validator\ConstraintViolation} object */ - public function __construct($violationPath) + public function __construct(string $violationPath) { $path = new PropertyPath($violationPath); $elements = $path->getElements(); diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index e8648ac41b171..ce0bbaa9c21a6 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -37,16 +37,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB */ private $unresolvedChildren = array(); - /** - * Creates a new form builder. - * - * @param string $name - * @param string $dataClass - * @param EventDispatcherInterface $dispatcher - * @param FormFactoryInterface $factory - * @param array $options - */ - public function __construct($name, $dataClass, EventDispatcherInterface $dispatcher, FormFactoryInterface $factory, array $options = array()) + public function __construct(?string $name, ?string $dataClass, EventDispatcherInterface $dispatcher, FormFactoryInterface $factory, array $options = array()) { parent::__construct($name, $dataClass, $dispatcher, $options); @@ -245,12 +236,8 @@ public function getIterator() /** * Converts an unresolved child into a {@link FormBuilder} instance. - * - * @param string $name The name of the unresolved child - * - * @return self The created instance */ - private function resolveChild($name) + private function resolveChild(string $name): self { $info = $this->unresolvedChildren[$name]; $child = $this->create($name, $info['type'], $info['options']); diff --git a/src/Symfony/Component/Form/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index 801393b6cf9ca..2c49288cca79e 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -188,7 +188,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface * @throws InvalidArgumentException if the data class is not a valid class or if * the name contains invalid characters */ - public function __construct($name, $dataClass, EventDispatcherInterface $dispatcher, array $options = array()) + public function __construct($name, ?string $dataClass, EventDispatcherInterface $dispatcher, array $options = array()) { self::validateName($name); diff --git a/src/Symfony/Component/Form/FormError.php b/src/Symfony/Component/Form/FormError.php index e05ee5bc84b6d..e8921ce10b022 100644 --- a/src/Symfony/Component/Form/FormError.php +++ b/src/Symfony/Component/Form/FormError.php @@ -47,7 +47,7 @@ class FormError implements \Serializable * * @see \Symfony\Component\Translation\Translator */ - public function __construct($message, $messageTemplate = null, array $messageParameters = array(), $messagePluralization = null, $cause = null) + public function __construct(?string $message, string $messageTemplate = null, array $messageParameters = array(), int $messagePluralization = null, $cause = null) { $this->message = $message; $this->messageTemplate = $messageTemplate ?: $message; diff --git a/src/Symfony/Component/Form/FormTypeGuesserChain.php b/src/Symfony/Component/Form/FormTypeGuesserChain.php index 104403fa02390..ea6ba66149e73 100644 --- a/src/Symfony/Component/Form/FormTypeGuesserChain.php +++ b/src/Symfony/Component/Form/FormTypeGuesserChain.php @@ -23,12 +23,8 @@ class FormTypeGuesserChain implements FormTypeGuesserInterface * * @throws UnexpectedTypeException if any guesser does not implement FormTypeGuesserInterface */ - public function __construct($guessers) + public function __construct(iterable $guessers) { - if (!is_array($guessers) && !$guessers instanceof \Traversable) { - throw new UnexpectedTypeException($guessers, 'array or Traversable'); - } - foreach ($guessers as $guesser) { if (!$guesser instanceof FormTypeGuesserInterface) { throw new UnexpectedTypeException($guesser, 'Symfony\Component\Form\FormTypeGuesserInterface'); diff --git a/src/Symfony/Component/Form/Guess/Guess.php b/src/Symfony/Component/Form/Guess/Guess.php index b216af5d55dc6..5007528631e8f 100644 --- a/src/Symfony/Component/Form/Guess/Guess.php +++ b/src/Symfony/Component/Form/Guess/Guess.php @@ -84,7 +84,7 @@ public static function getBestGuess(array $guesses) * * @throws InvalidArgumentException if the given value of confidence is unknown */ - public function __construct($confidence) + public function __construct(int $confidence) { if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence && self::MEDIUM_CONFIDENCE !== $confidence && self::LOW_CONFIDENCE !== $confidence) { diff --git a/src/Symfony/Component/Form/Guess/TypeGuess.php b/src/Symfony/Component/Form/Guess/TypeGuess.php index 1431b5e400569..ff0c6a7498215 100644 --- a/src/Symfony/Component/Form/Guess/TypeGuess.php +++ b/src/Symfony/Component/Form/Guess/TypeGuess.php @@ -29,7 +29,7 @@ class TypeGuess extends Guess * @param int $confidence The confidence that the guessed class name * is correct */ - public function __construct($type, array $options, $confidence) + public function __construct(string $type, array $options, int $confidence) { parent::__construct($confidence); diff --git a/src/Symfony/Component/Form/Guess/ValueGuess.php b/src/Symfony/Component/Form/Guess/ValueGuess.php index 251e9cd428375..fe19dfeb04e4a 100644 --- a/src/Symfony/Component/Form/Guess/ValueGuess.php +++ b/src/Symfony/Component/Form/Guess/ValueGuess.php @@ -25,7 +25,7 @@ class ValueGuess extends Guess * @param int $confidence The confidence that the guessed class name * is correct */ - public function __construct($value, $confidence) + public function __construct($value, int $confidence) { parent::__construct($confidence); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php index 43112a4960eb0..e99b7e2715b95 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php @@ -52,13 +52,9 @@ private function getPropertyPath($path) } /** - * @param FormConfigInterface $config - * @param bool $synchronized - * @param bool $submitted - * * @return \PHPUnit_Framework_MockObject_MockObject */ - private function getForm(FormConfigInterface $config, $synchronized = true, $submitted = true) + private function getForm(FormConfigInterface $config, bool $synchronized = true, bool $submitted = true) { $form = $this->getMockBuilder('Symfony\Component\Form\Form') ->setConstructorArgs(array($config)) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index d95a31443865a..47f831b537cb9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -307,7 +307,7 @@ public function testReverseTransformWrapsIntlErrors() } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \TypeError */ public function testValidateDateFormatOption() { @@ -315,7 +315,7 @@ public function testValidateDateFormatOption() } /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException + * @expectedException \TypeError */ public function testValidateTimeFormatOption() { diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index 50fdfd8aa985b..0693b28c135ac 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -410,13 +410,7 @@ public function testExtractViewVariables() ), $this->dataExtractor->extractViewVariables($view)); } - /** - * @param string $name - * @param array $options - * - * @return FormBuilder - */ - private function createBuilder($name, array $options = array()) + private function createBuilder(string $name, array $options = array()): FormBuilder { return new FormBuilder($name, null, $this->dispatcher, $this->factory, $options); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index 5ce2f0956a00b..55b4ac278cd3a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -644,14 +644,7 @@ private function getMockExecutionContext() return $context; } - /** - * @param string $name - * @param string $dataClass - * @param array $options - * - * @return FormBuilder - */ - private function getBuilder($name = 'name', $dataClass = null, array $options = array()) + private function getBuilder(string $name = 'name', string $dataClass = null, array $options = array()): FormBuilder { $options = array_replace(array( 'constraints' => array(), diff --git a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php index c69dbbba35663..367531496e23f 100644 --- a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php +++ b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php @@ -23,11 +23,7 @@ class AcceptHeaderItem private $index = 0; private $attributes = array(); - /** - * @param string $value - * @param array $attributes - */ - public function __construct($value, array $attributes = array()) + public function __construct(string $value, array $attributes = array()) { $this->value = $value; foreach ($attributes as $name => $value) { diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 1010223042ef5..d5a08ea8fa89a 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -44,7 +44,7 @@ class BinaryFileResponse extends Response * @param bool $autoEtag Whether the ETag header should be automatically set * @param bool $autoLastModified Whether the Last-Modified header should be automatically set */ - public function __construct($file, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) + public function __construct($file, int $status = 200, array $headers = array(), bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true) { parent::__construct(null, $status, $headers); diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index 4519a6adaeda5..78b67bb3d5d44 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -93,7 +93,7 @@ public static function fromString($cookie, $decode = false) * * @throws \InvalidArgumentException */ - public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true, $raw = false, $sameSite = null) + public function __construct(string $name, string $value = null, $expire = 0, ?string $path = '/', string $domain = null, bool $secure = false, bool $httpOnly = true, bool $raw = false, string $sameSite = null) { // from PHP source code if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { @@ -120,9 +120,9 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom $this->domain = $domain; $this->expire = 0 < $expire ? (int) $expire : 0; $this->path = empty($path) ? '/' : $path; - $this->secure = (bool) $secure; - $this->httpOnly = (bool) $httpOnly; - $this->raw = (bool) $raw; + $this->secure = $secure; + $this->httpOnly = $httpOnly; + $this->raw = $raw; if (null !== $sameSite) { $sameSite = strtolower($sameSite); diff --git a/src/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php b/src/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php index 3b8e41d4a2cf9..c25c3629bb617 100644 --- a/src/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php +++ b/src/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php @@ -21,7 +21,7 @@ class AccessDeniedException extends FileException /** * @param string $path The path to the accessed file */ - public function __construct($path) + public function __construct(string $path) { parent::__construct(sprintf('The file %s could not be accessed', $path)); } diff --git a/src/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php b/src/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php index bfcc37ec66ea0..0f1f3f951d806 100644 --- a/src/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php +++ b/src/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php @@ -21,7 +21,7 @@ class FileNotFoundException extends FileException /** * @param string $path The path to the file that was not found */ - public function __construct($path) + public function __construct(string $path) { parent::__construct(sprintf('The file "%s" does not exist', $path)); } diff --git a/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php b/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php index 0444b8778218f..82e6691fff899 100644 --- a/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php @@ -13,7 +13,7 @@ class UnexpectedTypeException extends FileException { - public function __construct($value, $expectedType) + public function __construct($value, string $expectedType) { parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); } diff --git a/src/Symfony/Component/HttpFoundation/File/File.php b/src/Symfony/Component/HttpFoundation/File/File.php index e2a67684fcda6..4e6887a52ad48 100644 --- a/src/Symfony/Component/HttpFoundation/File/File.php +++ b/src/Symfony/Component/HttpFoundation/File/File.php @@ -31,7 +31,7 @@ class File extends \SplFileInfo * * @throws FileNotFoundException If the given path is not a file */ - public function __construct($path, $checkPath = true) + public function __construct(string $path, bool $checkPath = true) { if ($checkPath && !is_file($path)) { throw new FileNotFoundException($path); diff --git a/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php b/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php index c2ac6768c3013..b00f58c4e8a27 100644 --- a/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ b/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php @@ -31,7 +31,7 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface * * @param string $cmd The command to run to get the mime type of a file */ - public function __construct($cmd = 'file -b --mime %s 2>/dev/null') + public function __construct(string $cmd = 'file -b --mime %s 2>/dev/null') { $this->cmd = $cmd; } diff --git a/src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php b/src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php index 9b42835e43044..d3ba8b31b5eba 100644 --- a/src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php +++ b/src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php @@ -28,7 +28,7 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface * * @see http://www.php.net/manual/en/function.finfo-open.php */ - public function __construct($magicFile = null) + public function __construct(string $magicFile = null) { $this->magicFile = $magicFile; } diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 082d8d534e17a..678c4f0afc6ef 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -55,13 +55,13 @@ class UploadedFile extends File * @throws FileException If file_uploads is disabled * @throws FileNotFoundException If the file does not exist */ - public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false) + public function __construct(string $path, string $originalName, string $mimeType = null, int $size = null, int $error = null, bool $test = false) { $this->originalName = $this->getName($originalName); $this->mimeType = $mimeType ?: 'application/octet-stream'; $this->size = $size; $this->error = $error ?: UPLOAD_ERR_OK; - $this->test = (bool) $test; + $this->test = $test; parent::__construct($path, UPLOAD_ERR_OK === $this->error); } diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 22051aad54a08..729264029097e 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -39,7 +39,7 @@ class JsonResponse extends Response * @param array $headers An array of response headers * @param bool $json If the data is already a JSON string */ - public function __construct($data = null, $status = 200, $headers = array(), $json = false) + public function __construct($data = null, int $status = 200, array $headers = array(), bool $json = false) { parent::__construct('', $status, $headers); diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index 01681dcdf787a..11f71a03426c6 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -32,7 +32,7 @@ class RedirectResponse extends Response * * @see http://tools.ietf.org/html/rfc2616#section-10.3 */ - public function __construct($url, $status = 302, $headers = array()) + public function __construct(?string $url, int $status = 302, array $headers = array()) { parent::__construct('', $status, $headers); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 722566d746f1f..1792c9fd52923 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1860,12 +1860,7 @@ protected static function initializeFormats() ); } - /** - * Sets the default PHP locale. - * - * @param string $locale - */ - private function setPhpDefaultLocale($locale) + private function setPhpDefaultLocale(string $locale) { // if either the class Locale doesn't exist, or an exception is thrown when // setting the default locale, the intl module is not installed, and @@ -1882,12 +1877,9 @@ private function setPhpDefaultLocale($locale) * Returns the prefix as encoded in the string when the string starts with * the given prefix, false otherwise. * - * @param string $string The urlencoded string - * @param string $prefix The prefix not encoded - * * @return string|false The prefix as it is encoded in $string, or false */ - private function getUrlencodedPrefix($string, $prefix) + private function getUrlencodedPrefix(string $string, string $prefix) { if (0 !== strpos(rawurldecode($string), $prefix)) { return false; diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index 076d077c7d072..cc13f71af28ac 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -56,7 +56,7 @@ class RequestMatcher implements RequestMatcherInterface * @param array $attributes * @param string|string[]|null $schemes */ - public function __construct($path = null, $host = null, $methods = null, $ips = null, array $attributes = array(), $schemes = null) + public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = array(), $schemes = null) { $this->matchPath($path); $this->matchHost($host); diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index c570b1c15a3cb..057498829636b 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -188,13 +188,9 @@ class Response ); /** - * @param mixed $content The response content, see setContent() - * @param int $status The response status code - * @param array $headers An array of response headers - * * @throws \InvalidArgumentException When the HTTP status code is not valid */ - public function __construct($content = '', $status = 200, $headers = array()) + public function __construct($content = '', int $status = 200, array $headers = array()) { $this->headers = new ResponseHeaderBag($headers); $this->setContent($content); @@ -414,13 +410,11 @@ public function getContent() /** * Sets the HTTP protocol version (1.0 or 1.1). * - * @param string $version The HTTP protocol version - * * @return $this * * @final since version 3.2 */ - public function setProtocolVersion($version) + public function setProtocolVersion(string $version) { $this->version = $version; @@ -430,11 +424,9 @@ public function setProtocolVersion($version) /** * Gets the HTTP protocol version. * - * @return string The HTTP protocol version - * * @final since version 3.2 */ - public function getProtocolVersion() + public function getProtocolVersion(): string { return $this->version; } @@ -445,18 +437,15 @@ public function getProtocolVersion() * If the status text is null it will be automatically populated for the known * status codes and left empty otherwise. * - * @param int $code HTTP status code - * @param mixed $text HTTP status text - * * @return $this * * @throws \InvalidArgumentException When the HTTP status code is not valid * * @final since version 3.2 */ - public function setStatusCode($code, $text = null) + public function setStatusCode(int $code, $text = null) { - $this->statusCode = $code = (int) $code; + $this->statusCode = $code; if ($this->isInvalid()) { throw new \InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code)); } @@ -481,11 +470,9 @@ public function setStatusCode($code, $text = null) /** * Retrieves the status code for the current web response. * - * @return int Status code - * * @final since version 3.2 */ - public function getStatusCode() + public function getStatusCode(): int { return $this->statusCode; } @@ -493,13 +480,11 @@ public function getStatusCode() /** * Sets the response charset. * - * @param string $charset Character set - * * @return $this * * @final since version 3.2 */ - public function setCharset($charset) + public function setCharset(string $charset) { $this->charset = $charset; @@ -509,11 +494,9 @@ public function setCharset($charset) /** * Retrieves the response charset. * - * @return string Character set - * * @final since version 3.2 */ - public function getCharset() + public function getCharset(): ?string { return $this->charset; } @@ -527,11 +510,9 @@ public function getCharset() * Responses with neither a freshness lifetime (Expires, max-age) nor cache * validator (Last-Modified, ETag) are considered uncacheable. * - * @return bool true if the response is worth caching, false otherwise - * * @final since version 3.3 */ - public function isCacheable() + public function isCacheable(): bool { if (!in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) { return false; @@ -551,11 +532,9 @@ public function isCacheable() * origin. A response is considered fresh when it includes a Cache-Control/max-age * indicator or Expires header and the calculated age is less than the freshness lifetime. * - * @return bool true if the response is fresh, false otherwise - * * @final since version 3.3 */ - public function isFresh() + public function isFresh(): bool { return $this->getTtl() > 0; } @@ -564,11 +543,9 @@ public function isFresh() * Returns true if the response includes headers that can be used to validate * the response with the origin server using a conditional GET request. * - * @return bool true if the response is validateable, false otherwise - * * @final since version 3.3 */ - public function isValidateable() + public function isValidateable(): bool { return $this->headers->has('Last-Modified') || $this->headers->has('ETag'); } @@ -610,13 +587,11 @@ public function setPublic() /** * Marks the response as "immutable". * - * @param bool $immutable enables or disables the immutable directive - * * @return $this * * @final */ - public function setImmutable($immutable = true) + public function setImmutable(bool $immutable = true) { if ($immutable) { $this->headers->addCacheControlDirective('immutable'); @@ -630,11 +605,9 @@ public function setImmutable($immutable = true) /** * Returns true if the response is marked as "immutable". * - * @return bool returns true if the response is marked as "immutable"; otherwise false - * * @final */ - public function isImmutable() + public function isImmutable(): bool { return $this->headers->hasCacheControlDirective('immutable'); } @@ -647,11 +620,9 @@ public function isImmutable() * When present, the TTL of the response should not be overridden to be * greater than the value provided by the origin. * - * @return bool true if the response must be revalidated by a cache, false otherwise - * * @final since version 3.3 */ - public function mustRevalidate() + public function mustRevalidate(): bool { return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->hasCacheControlDirective('proxy-revalidate'); } @@ -659,13 +630,11 @@ public function mustRevalidate() /** * Returns the Date header as a DateTime instance. * - * @return \DateTime A \DateTime instance - * * @throws \RuntimeException When the header is not parseable * * @final since version 3.2 */ - public function getDate() + public function getDate(): ?\DateTimeInterface { return $this->headers->getDate('Date'); } @@ -690,13 +659,11 @@ public function setDate(\DateTimeInterface $date) } /** - * Returns the age of the response. - * - * @return int The age of the response in seconds + * Returns the age of the response in seconds. * * @final since version 3.2 */ - public function getAge() + public function getAge(): int { if (null !== $age = $this->headers->get('Age')) { return (int) $age; @@ -722,17 +689,15 @@ public function expire() /** * Returns the value of the Expires header as a DateTime instance. * - * @return \DateTime|null A DateTime instance or null if the header does not exist - * * @final since version 3.2 */ - public function getExpires() + public function getExpires(): ?\DateTimeInterface { try { return $this->headers->getDate('Expires'); } catch (\RuntimeException $e) { // according to RFC 2616 invalid date formats (e.g. "0" and "-1") must be treated as in the past - return \DateTime::createFromFormat(DATE_RFC2822, 'Sat, 01 Jan 00 00:00:00 +0000'); + return \DateTime::createFromFormat('U', time() - 172800); } } @@ -741,8 +706,6 @@ public function getExpires() * * Passing null as value will remove the header. * - * @param \DateTimeInterface|null $date A \DateTime instance or null to remove the header - * * @return $this * * @final since version 3.2 @@ -772,11 +735,9 @@ public function setExpires(\DateTimeInterface $date = null) * First, it checks for a s-maxage directive, then a max-age directive, and then it falls * back on an expires header. It returns null when no maximum age can be established. * - * @return int|null Number of seconds - * * @final since version 3.2 */ - public function getMaxAge() + public function getMaxAge(): ?int { if ($this->headers->hasCacheControlDirective('s-maxage')) { return (int) $this->headers->getCacheControlDirective('s-maxage'); @@ -787,8 +748,10 @@ public function getMaxAge() } if (null !== $this->getExpires()) { - return $this->getExpires()->format('U') - $this->getDate()->format('U'); + return (int) ($this->getExpires()->format('U') - $this->getDate()->format('U')); } + + return null; } /** @@ -796,13 +759,11 @@ public function getMaxAge() * * This methods sets the Cache-Control max-age directive. * - * @param int $value Number of seconds - * * @return $this * * @final since version 3.2 */ - public function setMaxAge($value) + public function setMaxAge(int $value) { $this->headers->addCacheControlDirective('max-age', $value); @@ -814,13 +775,11 @@ public function setMaxAge($value) * * This methods sets the Cache-Control s-maxage directive. * - * @param int $value Number of seconds - * * @return $this * * @final since version 3.2 */ - public function setSharedMaxAge($value) + public function setSharedMaxAge(int $value) { $this->setPublic(); $this->headers->addCacheControlDirective('s-maxage', $value); @@ -836,29 +795,25 @@ public function setSharedMaxAge($value) * When the responses TTL is <= 0, the response may not be served from cache without first * revalidating with the origin. * - * @return int|null The TTL in seconds - * * @final since version 3.2 */ - public function getTtl() + public function getTtl(): ?int { - if (null !== $maxAge = $this->getMaxAge()) { - return $maxAge - $this->getAge(); - } + $maxAge = $this->getMaxAge(); + + return null !== $maxAge ? $maxAge - $this->getAge() : null; } /** - * Sets the response's time-to-live for shared caches. + * Sets the response's time-to-live for shared caches in seconds. * * This method adjusts the Cache-Control/s-maxage directive. * - * @param int $seconds Number of seconds - * * @return $this * * @final since version 3.2 */ - public function setTtl($seconds) + public function setTtl(int $seconds) { $this->setSharedMaxAge($this->getAge() + $seconds); @@ -866,17 +821,15 @@ public function setTtl($seconds) } /** - * Sets the response's time-to-live for private/client caches. + * Sets the response's time-to-live for private/client caches in seconds. * * This method adjusts the Cache-Control/max-age directive. * - * @param int $seconds Number of seconds - * * @return $this * * @final since version 3.2 */ - public function setClientTtl($seconds) + public function setClientTtl(int $seconds) { $this->setMaxAge($this->getAge() + $seconds); @@ -886,13 +839,11 @@ public function setClientTtl($seconds) /** * Returns the Last-Modified HTTP header as a DateTime instance. * - * @return \DateTime|null A DateTime instance or null if the header does not exist - * * @throws \RuntimeException When the HTTP header is not parseable * * @final since version 3.2 */ - public function getLastModified() + public function getLastModified(): ?\DateTimeInterface { return $this->headers->getDate('Last-Modified'); } @@ -902,8 +853,6 @@ public function getLastModified() * * Passing null as value will remove the header. * - * @param \DateTimeInterface|null $date A \DateTime instance or null to remove the header - * * @return $this * * @final since version 3.2 @@ -929,11 +878,9 @@ public function setLastModified(\DateTimeInterface $date = null) /** * Returns the literal value of the ETag HTTP header. * - * @return string|null The ETag HTTP header or null if it does not exist - * * @final since version 3.2 */ - public function getEtag() + public function getEtag(): ?string { return $this->headers->get('ETag'); } @@ -948,7 +895,7 @@ public function getEtag() * * @final since version 3.2 */ - public function setEtag($etag = null, $weak = false) + public function setEtag(string $etag = null, bool $weak = false) { if (null === $etag) { $this->headers->remove('Etag'); @@ -968,8 +915,6 @@ public function setEtag($etag = null, $weak = false) * * Available options are: etag, last_modified, max_age, s_maxage, private, and public. * - * @param array $options An array of cache options - * * @return $this * * @throws \InvalidArgumentException @@ -1049,11 +994,9 @@ public function setNotModified() /** * Returns true if the response includes a Vary header. * - * @return bool true if the response includes a Vary header, false otherwise - * * @final since version 3.2 */ - public function hasVary() + public function hasVary(): bool { return null !== $this->headers->get('Vary'); } @@ -1061,11 +1004,9 @@ public function hasVary() /** * Returns an array of header names given in the Vary header. * - * @return array An array of Vary names - * * @final since version 3.2 */ - public function getVary() + public function getVary(): array { if (!$vary = $this->headers->get('Vary', null, false)) { return array(); @@ -1089,7 +1030,7 @@ public function getVary() * * @final since version 3.2 */ - public function setVary($headers, $replace = true) + public function setVary($headers, bool $replace = true) { $this->headers->set('Vary', $headers, $replace); @@ -1107,7 +1048,7 @@ public function setVary($headers, $replace = true) * * @final since version 3.3 */ - public function isNotModified(Request $request) + public function isNotModified(Request $request): bool { if (!$request->isMethodCacheable()) { return false; @@ -1135,13 +1076,11 @@ public function isNotModified(Request $request) /** * Is response invalid? * - * @return bool - * * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html * * @final since version 3.2 */ - public function isInvalid() + public function isInvalid(): bool { return $this->statusCode < 100 || $this->statusCode >= 600; } @@ -1149,11 +1088,9 @@ public function isInvalid() /** * Is response informative? * - * @return bool - * * @final since version 3.3 */ - public function isInformational() + public function isInformational(): bool { return $this->statusCode >= 100 && $this->statusCode < 200; } @@ -1161,11 +1098,9 @@ public function isInformational() /** * Is response successful? * - * @return bool - * * @final since version 3.2 */ - public function isSuccessful() + public function isSuccessful(): bool { return $this->statusCode >= 200 && $this->statusCode < 300; } @@ -1173,11 +1108,9 @@ public function isSuccessful() /** * Is the response a redirect? * - * @return bool - * * @final since version 3.2 */ - public function isRedirection() + public function isRedirection(): bool { return $this->statusCode >= 300 && $this->statusCode < 400; } @@ -1185,11 +1118,9 @@ public function isRedirection() /** * Is there a client error? * - * @return bool - * * @final since version 3.2 */ - public function isClientError() + public function isClientError(): bool { return $this->statusCode >= 400 && $this->statusCode < 500; } @@ -1197,11 +1128,9 @@ public function isClientError() /** * Was there a server side error? * - * @return bool - * * @final since version 3.3 */ - public function isServerError() + public function isServerError(): bool { return $this->statusCode >= 500 && $this->statusCode < 600; } @@ -1209,11 +1138,9 @@ public function isServerError() /** * Is the response OK? * - * @return bool - * * @final since version 3.2 */ - public function isOk() + public function isOk(): bool { return 200 === $this->statusCode; } @@ -1221,11 +1148,9 @@ public function isOk() /** * Is the response forbidden? * - * @return bool - * * @final since version 3.2 */ - public function isForbidden() + public function isForbidden(): bool { return 403 === $this->statusCode; } @@ -1233,11 +1158,9 @@ public function isForbidden() /** * Is the response a not found error? * - * @return bool - * * @final since version 3.2 */ - public function isNotFound() + public function isNotFound(): bool { return 404 === $this->statusCode; } @@ -1245,13 +1168,9 @@ public function isNotFound() /** * Is the response a redirect of some form? * - * @param string $location - * - * @return bool - * * @final since version 3.2 */ - public function isRedirect($location = null) + public function isRedirect(string $location = null): bool { return in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location')); } @@ -1259,11 +1178,9 @@ public function isRedirect($location = null) /** * Is the response empty? * - * @return bool - * * @final since version 3.2 */ - public function isEmpty() + public function isEmpty(): bool { return in_array($this->statusCode, array(204, 304)); } @@ -1273,12 +1190,9 @@ public function isEmpty() * * Resulting level can be greater than target level if a non-removable buffer has been encountered. * - * @param int $targetLevel The target output buffering level - * @param bool $flush Whether to flush or clean the buffers - * * @final since version 3.3 */ - public static function closeOutputBuffers($targetLevel, $flush) + public static function closeOutputBuffers(int $targetLevel, bool $flush) { $status = ob_get_status(true); $level = count($status); diff --git a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php index ea1fda290fdfe..286534b8f2eda 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php @@ -24,7 +24,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta /** * @param string $storageKey The key used to store attributes in the session */ - public function __construct($storageKey = '_sf2_attributes') + public function __construct(string $storageKey = '_sf2_attributes') { $this->storageKey = $storageKey; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php b/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php index abbf37ee7c33c..19b57762a69fd 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php @@ -25,7 +25,7 @@ class NamespacedAttributeBag extends AttributeBag * @param string $storageKey Session storage key * @param string $namespaceCharacter Namespace character to use in keys */ - public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter = '/') + public function __construct(string $storageKey = '_sf2_attributes', string $namespaceCharacter = '/') { $this->namespaceCharacter = $namespaceCharacter; parent::__construct($storageKey); diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php index 811908b2fdf08..08784fcda19d4 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php @@ -25,7 +25,7 @@ class AutoExpireFlashBag implements FlashBagInterface /** * @param string $storageKey The key used to store flashes in the session */ - public function __construct($storageKey = '_symfony_flashes') + public function __construct(string $storageKey = '_symfony_flashes') { $this->storageKey = $storageKey; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php index 12fb740c5220c..44ddb96330d55 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -25,7 +25,7 @@ class FlashBag implements FlashBagInterface /** * @param string $storageKey The key used to store flashes in the session */ - public function __construct($storageKey = '_symfony_flashes') + public function __construct(string $storageKey = '_symfony_flashes') { $this->storageKey = $storageKey; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php index b052b32dab6cf..f962965a82a6d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php @@ -28,7 +28,7 @@ class NativeFileSessionHandler extends \SessionHandler * @throws \InvalidArgumentException On invalid $savePath * @throws \RuntimeException When failing to create the save directory */ - public function __construct($savePath = null) + public function __construct(string $savePath = null) { if (null === $savePath) { $savePath = ini_get('session.save_path'); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index bccfbf611f0db..90c2307913a50 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -578,8 +578,6 @@ protected function doRead($sessionId) /** * Executes an application-level lock on the database. * - * @param string $sessionId Session ID - * * @return \PDOStatement The statement that needs to be executed later to release the lock * * @throws \DomainException When an unsupported PDO driver is used @@ -588,7 +586,7 @@ protected function doRead($sessionId) * - for oci using DBMS_LOCK.REQUEST * - for sqlsrv using sp_getapplock with LockOwner = Session */ - private function doAdvisoryLock($sessionId) + private function doAdvisoryLock(string $sessionId) { switch ($this->driver) { case 'mysql': @@ -641,12 +639,8 @@ private function doAdvisoryLock($sessionId) * Encodes the first 4 (when PHP_INT_SIZE == 4) or 8 characters of the string as an integer. * * Keep in mind, PHP integers are signed. - * - * @param string $string - * - * @return int */ - private function convertStringToInt($string) + private function convertStringToInt(string $string): int { if (4 === \PHP_INT_SIZE) { return (ord($string[3]) << 24) + (ord($string[2]) << 16) + (ord($string[1]) << 8) + ord($string[0]); @@ -661,11 +655,9 @@ private function convertStringToInt($string) /** * Return a locking or nonlocking SQL query to read session information. * - * @return string The SQL string - * * @throws \DomainException When an unsupported PDO driver is used */ - private function getSelectSql() + private function getSelectSql(): string { if (self::LOCK_TRANSACTIONAL === $this->lockMode) { $this->beginTransaction(); @@ -690,14 +682,8 @@ private function getSelectSql() /** * Returns a merge/upsert (i.e. insert or update) statement when supported by the database for writing session data. - * - * @param string $sessionId Session ID - * @param string $data Encoded session data - * @param int $maxlifetime session.gc_maxlifetime - * - * @return \PDOStatement|null The merge statement or null when not supported */ - private function getMergeStatement($sessionId, $data, $maxlifetime) + private function getMergeStatement(string $sessionId, string $data, int$maxlifetime): ?\PDOStatement { $mergeSql = null; switch (true) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php index 6f59af486981e..ea0d5ecb51826 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php @@ -57,7 +57,7 @@ class MetadataBag implements SessionBagInterface * @param string $storageKey The key used to store bag in the session * @param int $updateThreshold The time to wait between two UPDATED updates */ - public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0) + public function __construct(string $storageKey = '_sf2_meta', int $updateThreshold = 0) { $this->storageKey = $storageKey; $this->updateThreshold = $updateThreshold; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php index 027f4efffce51..47cac39854a5d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php @@ -62,11 +62,7 @@ class MockArraySessionStorage implements SessionStorageInterface */ protected $bags = array(); - /** - * @param string $name Session name - * @param MetadataBag $metaBag MetadataBag instance - */ - public function __construct($name = 'MOCKSESSID', MetadataBag $metaBag = null) + public function __construct(string $name = 'MOCKSESSID', MetadataBag $metaBag = null) { $this->name = $name; $this->setMetadataBag($metaBag); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php index 0a580d6027c4f..23a05492166fa 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php @@ -31,7 +31,7 @@ class MockFileSessionStorage extends MockArraySessionStorage * @param string $name Session name * @param MetadataBag $metaBag MetadataBag instance */ - public function __construct($savePath = null, $name = 'MOCKSESSID', MetadataBag $metaBag = null) + public function __construct(string $savePath = null, string $name = 'MOCKSESSID', MetadataBag $metaBag = null) { if (null === $savePath) { $savePath = sys_get_temp_dir(); diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index 92868d33e4814..a7c2150252eb6 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -35,7 +35,7 @@ class StreamedResponse extends Response * @param int $status The response status code * @param array $headers An array of response headers */ - public function __construct(callable $callback = null, $status = 200, $headers = array()) + public function __construct(callable $callback = null, int $status = 200, array $headers = array()) { parent::__construct(null, $status, $headers); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 4f7dc2817a1b9..e3318822bd4df 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -300,7 +300,7 @@ public function testGetMaxAge() $response = new Response(); $response->headers->set('Cache-Control', 'must-revalidate'); $response->headers->set('Expires', -1); - $this->assertEquals('Sat, 01 Jan 00 00:00:00 +0000', $response->getExpires()->format(DATE_RFC822)); + $this->assertLessThanOrEqual(time() - 2*86400, $response->getExpires()->format('U')); $response = new Response(); $this->assertNull($response->getMaxAge(), '->getMaxAge() returns null if no freshness information available'); diff --git a/src/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php b/src/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php index e028c3ea43f51..6aabdc0917efa 100644 --- a/src/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php +++ b/src/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php @@ -22,9 +22,6 @@ class ChainCacheClearer implements CacheClearerInterface { private $clearers; - /** - * @param array $clearers The initial clearers - */ public function __construct(iterable $clearers = array()) { $this->clearers = $clearers; diff --git a/src/Symfony/Component/HttpKernel/Config/FileLocator.php b/src/Symfony/Component/HttpKernel/Config/FileLocator.php index fb1f913bdff5d..926f0d1a28e14 100644 --- a/src/Symfony/Component/HttpKernel/Config/FileLocator.php +++ b/src/Symfony/Component/HttpKernel/Config/FileLocator.php @@ -29,7 +29,7 @@ class FileLocator extends BaseFileLocator * @param null|string $path The path the global resource directory * @param array $paths An array of paths where to look for resources */ - public function __construct(KernelInterface $kernel, $path = null, array $paths = array()) + public function __construct(KernelInterface $kernel, string $path = null, array $paths = array()) { $this->kernel = $kernel; if (null !== $path) { diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerReference.php b/src/Symfony/Component/HttpKernel/Controller/ControllerReference.php index fae4e7fa449bc..f424fdc833ab7 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerReference.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerReference.php @@ -35,7 +35,7 @@ class ControllerReference * @param array $attributes An array of parameters to add to the Request attributes * @param array $query An array of parameters to add to the Request query string */ - public function __construct($controller, array $attributes = array(), array $query = array()) + public function __construct(string $controller, array $attributes = array(), array $query = array()) { $this->controller = $controller; $this->attributes = $attributes; diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php index 32316a8d519e7..4ea8ea643feb1 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php @@ -25,15 +25,7 @@ class ArgumentMetadata private $defaultValue; private $isNullable; - /** - * @param string $name - * @param string $type - * @param bool $isVariadic - * @param bool $hasDefaultValue - * @param mixed $defaultValue - * @param bool $isNullable - */ - public function __construct($name, $type, $isVariadic, $hasDefaultValue, $defaultValue, $isNullable = false) + public function __construct(string $name, ?string $type, bool $isVariadic, bool $hasDefaultValue, $defaultValue, bool $isNullable = false) { $this->name = $name; $this->type = $type; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 5675f073639a6..14abce761f889 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -34,7 +34,7 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte * @param string $name The name of the application using the web profiler * @param string $version The version of the application using the web profiler */ - public function __construct($name = null, $version = null) + public function __construct(string $name = null, string $version = null) { $this->name = $name; $this->version = $version; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index f9730b1485045..5ec4e5f23f9e0 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -39,7 +39,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface private $dumper; private $dumperIsInjected; - public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $charset = null, RequestStack $requestStack = null, DataDumperInterface $dumper = null) + public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, DataDumperInterface $dumper = null) { $this->stopwatch = $stopwatch; $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index acea046d60cc1..3f6fc32e04be9 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -26,7 +26,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte private $logger; private $containerPathPrefix; - public function __construct($logger = null, $containerPathPrefix = null) + public function __construct($logger = null, string $containerPathPrefix = null) { if (null !== $logger && $logger instanceof DebugLoggerInterface) { $this->logger = $logger; diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 6f70f0d5072b0..2f1806689a24c 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -26,7 +26,7 @@ class FileLinkFormatter implements \Serializable private $baseDir; private $urlFormat; - public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) + public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string $urlFormat = null) { $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if ($fileLinkFormat && !is_array($fileLinkFormat)) { diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/ControllerArgumentValueResolverPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/ControllerArgumentValueResolverPass.php index 343e217b9687b..b3a25068fa345 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/ControllerArgumentValueResolverPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/ControllerArgumentValueResolverPass.php @@ -28,7 +28,7 @@ class ControllerArgumentValueResolverPass implements CompilerPassInterface private $argumentResolverService; private $argumentValueResolverTag; - public function __construct($argumentResolverService = 'argument_resolver', $argumentValueResolverTag = 'controller.argument_value_resolver') + public function __construct(string $argumentResolverService = 'argument_resolver', string $argumentValueResolverTag = 'controller.argument_value_resolver') { $this->argumentResolverService = $argumentResolverService; $this->argumentValueResolverTag = $argumentValueResolverTag; diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php index ac52c8732bc4a..825038b695e99 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php @@ -28,11 +28,7 @@ class FragmentRendererPass implements CompilerPassInterface private $handlerService; private $rendererTag; - /** - * @param string $handlerService Service name of the fragment handler in the container - * @param string $rendererTag Tag name used for fragments - */ - public function __construct($handlerService = 'fragment.handler', $rendererTag = 'kernel.fragment_renderer') + public function __construct(string $handlerService = 'fragment.handler', string $rendererTag = 'kernel.fragment_renderer') { $this->handlerService = $handlerService; $this->rendererTag = $rendererTag; diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php b/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php index 4e5521bc7e3e5..4bb47902b5050 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/LazyLoadingFragmentHandler.php @@ -25,12 +25,7 @@ class LazyLoadingFragmentHandler extends FragmentHandler private $container; private $initialized = array(); - /** - * @param ContainerInterface $container A container - * @param RequestStack $requestStack The Request stack that controls the lifecycle of requests - * @param bool $debug Whether the debug mode is enabled or not - */ - public function __construct(ContainerInterface $container, RequestStack $requestStack, $debug = false) + public function __construct(ContainerInterface $container, RequestStack $requestStack, bool $debug = false) { $this->container = $container; diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 985dfb71d7064..9cd910ad18cfe 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -33,7 +33,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface private $resolverServiceId; private $controllerTag; - public function __construct($resolverServiceId = 'argument_resolver.service', $controllerTag = 'controller.service_arguments') + public function __construct(string $resolverServiceId = 'argument_resolver.service', string $controllerTag = 'controller.service_arguments') { $this->resolverServiceId = $resolverServiceId; $this->controllerTag = $controllerTag; diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php index 440b0d0025e65..6ae10d3f29833 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php @@ -23,7 +23,7 @@ class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface { private $resolverServiceId; - public function __construct($resolverServiceId = 'argument_resolver.service') + public function __construct(string $resolverServiceId = 'argument_resolver.service') { $this->resolverServiceId = $resolverServiceId; } diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/ResettableServicePass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/ResettableServicePass.php index 52cc3a4a8383f..135ed608a7320 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/ResettableServicePass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/ResettableServicePass.php @@ -25,7 +25,7 @@ class ResettableServicePass implements CompilerPassInterface { private $tagName; - public function __construct($tagName = 'kernel.reset') + public function __construct(string $tagName = 'kernel.reset') { $this->tagName = $tagName; } diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerArgumentsEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerArgumentsEvent.php index 2b08f2d770020..9912f6ec91dbd 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerArgumentsEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterControllerArgumentsEvent.php @@ -30,7 +30,7 @@ class FilterControllerArgumentsEvent extends FilterControllerEvent { private $arguments; - public function __construct(HttpKernelInterface $kernel, callable $controller, array $arguments, Request $request, $requestType) + public function __construct(HttpKernelInterface $kernel, callable $controller, array $arguments, Request $request, int $requestType) { parent::__construct($kernel, $controller, $request, $requestType); diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php index 84cbc2eaf8365..3f8ba1c4c4ef0 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php @@ -29,7 +29,7 @@ class FilterControllerEvent extends KernelEvent { private $controller; - public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, $requestType) + public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, int $requestType) { parent::__construct($kernel, $request, $requestType); diff --git a/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php index 53a7efce76cae..4cdc207f56b46 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php @@ -28,7 +28,7 @@ class FilterResponseEvent extends KernelEvent { private $response; - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, Response $response) + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, Response $response) { parent::__construct($kernel, $request, $requestType); diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php b/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php index f70ce09e0a40a..592653d77fa0c 100644 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php @@ -32,7 +32,7 @@ class GetResponseForControllerResultEvent extends GetResponseEvent */ private $controllerResult; - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, $controllerResult) + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, $controllerResult) { parent::__construct($kernel, $request, $requestType); diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php b/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php index 751b74515b48b..cf0fcd16233ef 100644 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php @@ -41,7 +41,7 @@ class GetResponseForExceptionEvent extends GetResponseEvent */ private $allowCustomResponseCode = false; - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType, \Exception $e) + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Exception $e) { parent::__construct($kernel, $request, $requestType); diff --git a/src/Symfony/Component/HttpKernel/Event/KernelEvent.php b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php index 992f6b4dc033e..a76cd3e6f0eee 100644 --- a/src/Symfony/Component/HttpKernel/Event/KernelEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php @@ -32,7 +32,7 @@ class KernelEvent extends Event * @param int $requestType The request type the kernel is currently processing; one of * HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST */ - public function __construct(HttpKernelInterface $kernel, Request $request, $requestType) + public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType) { $this->kernel = $kernel; $this->request = $request; diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index ea17cf9d9110c..bc2a823fad719 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -47,15 +47,15 @@ class DebugHandlersListener implements EventSubscriberInterface * @param string|array $fileLinkFormat The format for links to source files * @param bool $scope Enables/disables scoping mode */ - public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, $throwAt = E_ALL, $scream = true, $fileLinkFormat = null, $scope = true) + public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true) { $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; $this->levels = null === $levels ? E_ALL : $levels; - $this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null)); - $this->scream = (bool) $scream; + $this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null)); + $this->scream = $scream; $this->fileLinkFormat = $fileLinkFormat; - $this->scope = (bool) $scope; + $this->scope = $scope; } /** diff --git a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index da518fcc8e374..f6bfd6cc6d802 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -38,7 +38,7 @@ class FragmentListener implements EventSubscriberInterface * @param UriSigner $signer A UriSigner instance * @param string $fragmentPath The path that triggers this listener */ - public function __construct(UriSigner $signer, $fragmentPath = '/_fragment') + public function __construct(UriSigner $signer, string $fragmentPath = '/_fragment') { $this->signer = $signer; $this->fragmentPath = $fragmentPath; diff --git a/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php b/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php index 427ea82fc8bf7..6c2b5098dcf4e 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/LocaleListener.php @@ -35,7 +35,7 @@ class LocaleListener implements EventSubscriberInterface * @param string $defaultLocale The default locale * @param RequestContextAwareInterface|null $router The router */ - public function __construct(RequestStack $requestStack, $defaultLocale = 'en', RequestContextAwareInterface $router = null) + public function __construct(RequestStack $requestStack, string $defaultLocale = 'en', RequestContextAwareInterface $router = null) { $this->defaultLocale = $defaultLocale; $this->requestStack = $requestStack; diff --git a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index e3e4e7620e4ee..52e06e1b35513 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php @@ -43,12 +43,12 @@ class ProfilerListener implements EventSubscriberInterface * @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise * @param bool $onlyMasterRequests True if the profiler only collects data when the request is a master request, false otherwise */ - public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, $onlyException = false, $onlyMasterRequests = false) + public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, bool $onlyException = false, bool $onlyMasterRequests = false) { $this->profiler = $profiler; $this->matcher = $matcher; - $this->onlyException = (bool) $onlyException; - $this->onlyMasterRequests = (bool) $onlyMasterRequests; + $this->onlyException = $onlyException; + $this->onlyMasterRequests = $onlyMasterRequests; $this->profiles = new \SplObjectStorage(); $this->parents = new \SplObjectStorage(); $this->requestStack = $requestStack; diff --git a/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php b/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php index 6d56197a737e7..01475c2a77d3d 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ResponseListener.php @@ -24,7 +24,7 @@ class ResponseListener implements EventSubscriberInterface { private $charset; - public function __construct($charset) + public function __construct(string $charset) { $this->charset = $charset; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php index a8f7dd7e7ed97..b8eea1c6393e2 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php @@ -55,7 +55,7 @@ class RouterListener implements EventSubscriberInterface * * @throws \InvalidArgumentException */ - public function __construct($matcher, RequestStack $requestStack, RequestContext $context = null, LoggerInterface $logger = null, $projectDir = null, $debug = true) + public function __construct($matcher, RequestStack $requestStack, RequestContext $context = null, LoggerInterface $logger = null, string $projectDir = null, bool $debug = true) { if (!$matcher instanceof UrlMatcherInterface && !$matcher instanceof RequestMatcherInterface) { throw new \InvalidArgumentException('Matcher must either implement UrlMatcherInterface or RequestMatcherInterface.'); diff --git a/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php index 3c5074820a269..3aedbf97fec3e 100644 --- a/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php @@ -23,7 +23,7 @@ class AccessDeniedHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(403, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php b/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php index e73e30b576128..ff215db45f7d1 100644 --- a/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php @@ -22,7 +22,7 @@ class BadRequestHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(400, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php b/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php index b61340b3df99f..60195daf7b09c 100644 --- a/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php @@ -22,7 +22,7 @@ class ConflictHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(409, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php b/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php index 401b49c3033ca..f2f3515f77ab0 100644 --- a/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php @@ -22,7 +22,7 @@ class GoneHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(410, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/HttpException.php b/src/Symfony/Component/HttpKernel/Exception/HttpException.php index e8e37605838cc..dab73120d096d 100644 --- a/src/Symfony/Component/HttpKernel/Exception/HttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/HttpException.php @@ -21,7 +21,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface private $statusCode; private $headers; - public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = array(), $code = 0) + public function __construct(int $statusCode, string $message = null, \Exception $previous = null, array $headers = array(), ?int $code = 0) { $this->statusCode = $statusCode; $this->headers = $headers; diff --git a/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php b/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php index dd94a18557abb..46b76ba6a3197 100644 --- a/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php @@ -22,7 +22,7 @@ class LengthRequiredHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(411, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php index 2ec9e0a4f8f87..b0085c16fa0e2 100644 --- a/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php @@ -23,7 +23,7 @@ class MethodNotAllowedHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct(array $allow, $message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(array $allow, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = array()) { $headers['Allow'] = strtoupper(implode(', ', $allow)); diff --git a/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php b/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php index d4088066b12e5..32c3089374bca 100644 --- a/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php @@ -22,7 +22,7 @@ class NotAcceptableHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(406, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php b/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php index 5310cb97017be..433ff9b9e0d64 100644 --- a/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php @@ -22,7 +22,7 @@ class NotFoundHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(404, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php index b53876f54aece..108178889cb05 100644 --- a/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php @@ -22,7 +22,7 @@ class PreconditionFailedHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(412, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php b/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php index f340eae1c51b2..30783282410fc 100644 --- a/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php @@ -24,7 +24,7 @@ class PreconditionRequiredHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(428, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php b/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php index d53b21eb4ab38..667764779f8e7 100644 --- a/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php @@ -23,7 +23,7 @@ class ServiceUnavailableHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct($retryAfter = null, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = array()) { if ($retryAfter) { $headers['Retry-After'] = $retryAfter; diff --git a/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php b/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php index 4ab4535f14e84..60b024c330171 100644 --- a/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php @@ -25,7 +25,7 @@ class TooManyRequestsHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($retryAfter = null, $message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct($retryAfter = null, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = array()) { if ($retryAfter) { $headers['Retry-After'] = $retryAfter; diff --git a/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php index c0f2b65393944..17ebb254640b8 100644 --- a/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php @@ -23,7 +23,7 @@ class UnauthorizedHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($challenge, $message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $challenge, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = array()) { $headers['WWW-Authenticate'] = $challenge; diff --git a/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php b/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php index e3aea7f8d3430..3a4b40c98457d 100644 --- a/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php @@ -22,7 +22,7 @@ class UnprocessableEntityHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(422, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php b/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php index 97eea385faf5c..ed6861154adab 100644 --- a/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php @@ -22,7 +22,7 @@ class UnsupportedMediaTypeHttpException extends HttpException * @param int $code The internal exception code * @param array $headers */ - public function __construct($message = null, \Exception $previous = null, $code = 0, array $headers = array()) + public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = array()) { parent::__construct(415, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php b/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php index c9d952ffbe044..aa61bd1f7dd67 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php +++ b/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php @@ -37,7 +37,7 @@ class FragmentHandler * @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances * @param bool $debug Whether the debug mode is enabled or not */ - public function __construct(RequestStack $requestStack, array $renderers = array(), $debug = false) + public function __construct(RequestStack $requestStack, array $renderers = array(), bool $debug = false) { $this->requestStack = $requestStack; foreach ($renderers as $renderer) { diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 6f6f9a35e6bb2..e737a141e93b7 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -38,7 +38,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer * @param string $globalDefaultTemplate The global default content (it can be a template name or the content) * @param string $charset */ - public function __construct($templating = null, UriSigner $signer = null, $globalDefaultTemplate = null, $charset = 'utf-8') + public function __construct($templating = null, UriSigner $signer = null, string $globalDefaultTemplate = null, string $charset = 'utf-8') { $this->setTemplating($templating); $this->globalDefaultTemplate = $globalDefaultTemplate; diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 52fa291e90175..cd63869413f47 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -647,23 +647,16 @@ private function isPrivateRequest(Request $request) /** * Records that an event took place. - * - * @param Request $request A Request instance - * @param string $event The event name */ - private function record(Request $request, $event) + private function record(Request $request, string $event) { $this->traces[$this->getTraceKey($request)][] = $event; } /** * Calculates the key we use in the "trace" array for a given request. - * - * @param Request $request - * - * @return string */ - private function getTraceKey(Request $request) + private function getTraceKey(Request $request): string { $path = $request->getPathInfo(); if ($qs = $request->getQueryString()) { @@ -676,12 +669,8 @@ private function getTraceKey(Request $request) /** * Checks whether the given (cached) response may be served as "stale" when a revalidation * is currently in progress. - * - * @param Response $entry - * - * @return bool true when the stale response may be served, false otherwise */ - private function mayServeStaleWhileRevalidate(Response $entry) + private function mayServeStaleWhileRevalidate(Response $entry): bool { $timeout = $entry->headers->getCacheControlDirective('stale-while-revalidate'); @@ -694,12 +683,8 @@ private function mayServeStaleWhileRevalidate(Response $entry) /** * Waits for the store to release a locked entry. - * - * @param Request $request The request to wait for - * - * @return bool true if the lock was released before the internal timeout was hit; false if the wait timeout was exceeded */ - private function waitForLock(Request $request) + private function waitForLock(Request $request): bool { $wait = 0; while ($this->store->isLocked($request) && $wait < 5000000) { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Store.php b/src/Symfony/Component/HttpKernel/HttpCache/Store.php index 8eeb93192cc8f..32cda17d4f781 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Store.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Store.php @@ -29,11 +29,9 @@ class Store implements StoreInterface private $locks; /** - * @param string $root The path to the cache directory - * * @throws \RuntimeException */ - public function __construct($root) + public function __construct(string $root) { $this->root = $root; if (!file_exists($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) { diff --git a/src/Symfony/Component/HttpKernel/HttpKernel.php b/src/Symfony/Component/HttpKernel/HttpKernel.php index 0ea5bf376c4d2..3f4ba9497a798 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpKernel.php @@ -199,9 +199,6 @@ private function filterResponse(Response $response, Request $request, int $type) * Note that the order of the operations is important here, otherwise * operations such as {@link RequestStack::getParentRequest()} can lead to * weird results. - * - * @param Request $request - * @param int $type */ private function finishRequest(Request $request, int $type) { @@ -214,13 +211,11 @@ private function finishRequest(Request $request, int $type) * * @param \Exception $e An \Exception instance * @param Request $request A Request instance - * @param int $type The type of the request - * - * @return Response A Response instance + * @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST) * * @throws \Exception */ - private function handleException(\Exception $e, Request $request, int $type) + private function handleException(\Exception $e, Request $request, int $type): Response { $event = new GetResponseForExceptionEvent($this, $request, $type, $e); $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event); diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index ef2a1bfdf0509..175626c456bfc 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -73,14 +73,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl const END_OF_MAINTENANCE = '07/2018'; const END_OF_LIFE = '01/2019'; - /** - * @param string $environment The environment - * @param bool $debug Whether to enable debugging or not - */ - public function __construct($environment, $debug) + public function __construct(string $environment, bool $debug) { $this->environment = $environment; - $this->debug = (bool) $debug; + $this->debug = $debug; $this->rootDir = $this->getRootDir(); $this->name = $this->getName(); @@ -259,7 +255,7 @@ public function locateResource($name, $dir = null, $first = true) throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', $file, $resourceBundle, - $dir.'/'.$bundles[0]->getName().$overridePath + $dir.'/'.$bundle->getName().$overridePath )); } diff --git a/src/Symfony/Component/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index 8facb03c5a29d..e26767f55d5e8 100644 --- a/src/Symfony/Component/HttpKernel/Log/Logger.php +++ b/src/Symfony/Component/HttpKernel/Log/Logger.php @@ -37,7 +37,7 @@ class Logger extends AbstractLogger private $formatter; private $handle; - public function __construct($minLevel = null, $output = 'php://stderr', callable $formatter = null) + public function __construct(string $minLevel = null, $output = 'php://stderr', callable $formatter = null) { if (null === $minLevel) { $minLevel = LogLevel::WARNING; @@ -80,14 +80,7 @@ public function log($level, $message, array $context = array()) fwrite($this->handle, $formatter($level, $message, $context)); } - /** - * @param string $level - * @param string $message - * @param array $context - * - * @return string - */ - private function format($level, $message, array $context) + private function format(string $level, string $message, array $context): string { if (false !== strpos($message, '{')) { $replacements = array(); diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index e24b2e0183684..d78411d3f6b71 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -30,11 +30,9 @@ class FileProfilerStorage implements ProfilerStorageInterface * * Example : "file:/path/to/the/storage/folder" * - * @param string $dsn The DSN - * * @throws \RuntimeException */ - public function __construct($dsn) + public function __construct(string $dsn) { if (0 !== strpos($dsn, 'file:')) { throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".', $dsn)); diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profile.php b/src/Symfony/Component/HttpKernel/Profiler/Profile.php index c21c9d38a343d..e91a0b0c70e49 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profile.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profile.php @@ -43,10 +43,7 @@ class Profile */ private $children = array(); - /** - * @param string $token The token - */ - public function __construct($token) + public function __construct(string $token) { $this->token = $token; } diff --git a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php index a25321897d46f..9152e99277676 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/Profiler.php +++ b/src/Symfony/Component/HttpKernel/Profiler/Profiler.php @@ -36,14 +36,11 @@ class Profiler private $initiallyEnabled = true; private $enabled = true; - /** - * @param bool $enable The initial enabled state - */ - public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, $enable = true) + public function __construct(ProfilerStorageInterface $storage, LoggerInterface $logger = null, bool $enable = true) { $this->storage = $storage; $this->logger = $logger; - $this->initiallyEnabled = $this->enabled = (bool) $enable; + $this->initiallyEnabled = $this->enabled = $enable; } /** diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php index 8ef2dc29f7a25..8dd9b28b15773 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php @@ -70,12 +70,7 @@ public function getPortData() ); } - /** - * @param string $uri - * - * @return GetResponseEvent - */ - private function createGetResponseEventForUri($uri) + private function createGetResponseEventForUri(string $uri): GetResponseEvent { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = Request::create($uri); diff --git a/src/Symfony/Component/HttpKernel/UriSigner.php b/src/Symfony/Component/HttpKernel/UriSigner.php index 28459b4ecd394..de73039b342c4 100644 --- a/src/Symfony/Component/HttpKernel/UriSigner.php +++ b/src/Symfony/Component/HttpKernel/UriSigner.php @@ -25,7 +25,7 @@ class UriSigner * @param string $secret A secret * @param string $parameter Query string parameter to use */ - public function __construct($secret, $parameter = '_hash') + public function __construct(string $secret, string $parameter = '_hash') { $this->secret = $secret; $this->parameter = $parameter; diff --git a/src/Symfony/Component/Intl/Collator/Collator.php b/src/Symfony/Component/Intl/Collator/Collator.php index 4b19dd31ec440..3caf48a2de196 100644 --- a/src/Symfony/Component/Intl/Collator/Collator.php +++ b/src/Symfony/Component/Intl/Collator/Collator.php @@ -74,7 +74,7 @@ class Collator * * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed */ - public function __construct($locale) + public function __construct(?string $locale) { if ('en' !== $locale && null !== $locale) { throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported'); diff --git a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php index ef54e402e9294..13f423342b1ea 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php @@ -32,7 +32,7 @@ class GenrbCompiler implements BundleCompilerInterface * * @throws RuntimeException if the "genrb" cannot be found */ - public function __construct($genrb = 'genrb', $envVars = '') + public function __construct(string $genrb = 'genrb', string $envVars = '') { exec('which '.$genrb, $output, $status); diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/BufferedBundleReader.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/BufferedBundleReader.php index 5fee153259281..ae5a74a0ca526 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/BufferedBundleReader.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/BufferedBundleReader.php @@ -29,7 +29,7 @@ class BufferedBundleReader implements BundleReaderInterface * @param BundleReaderInterface $reader The reader to buffer * @param int $bufferSize The number of entries to store in the buffer */ - public function __construct(BundleReaderInterface $reader, $bufferSize) + public function __construct(BundleReaderInterface $reader, int $bufferSize) { $this->reader = $reader; $this->buffer = new RingBuffer($bufferSize); diff --git a/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php index 68a27c432389e..d13596bc1783d 100644 --- a/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/AbstractDataGenerator.php @@ -29,10 +29,10 @@ abstract class AbstractDataGenerator private $compiler; private $dirName; - public function __construct(GenrbCompiler $compiler, $dirName) + public function __construct(GenrbCompiler $compiler, string $dirName) { $this->compiler = $compiler; - $this->dirName = (string) $dirName; + $this->dirName = $dirName; } public function generateData(GeneratorConfig $config) diff --git a/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php b/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php index 9bb9304db0159..5b9e2b2ea95f8 100644 --- a/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php +++ b/src/Symfony/Component/Intl/Data/Generator/GeneratorConfig.php @@ -30,11 +30,7 @@ class GeneratorConfig */ private $bundleWriters = array(); - /** - * @param string $sourceDir - * @param string $icuVersion - */ - public function __construct($sourceDir, $icuVersion) + public function __construct(string $sourceDir, string $icuVersion) { $this->sourceDir = $sourceDir; $this->icuVersion = $icuVersion; diff --git a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php index 5951a77043eeb..c89ac337c4478 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php @@ -34,9 +34,9 @@ class LocaleDataGenerator private $scriptDataProvider; private $regionDataProvider; - public function __construct($dirName, LanguageDataProvider $languageDataProvider, ScriptDataProvider $scriptDataProvider, RegionDataProvider $regionDataProvider) + public function __construct(string $dirName, LanguageDataProvider $languageDataProvider, ScriptDataProvider $scriptDataProvider, RegionDataProvider $regionDataProvider) { - $this->dirName = (string) $dirName; + $this->dirName = $dirName; $this->languageDataProvider = $languageDataProvider; $this->scriptDataProvider = $scriptDataProvider; $this->regionDataProvider = $regionDataProvider; diff --git a/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php index 6818a7948d579..61bc4fa9175f0 100644 --- a/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php @@ -39,7 +39,7 @@ class CurrencyDataProvider * @param string $path The path to the resource bundle * @param BundleEntryReaderInterface $reader The reader for reading the resource bundle */ - public function __construct($path, BundleEntryReaderInterface $reader) + public function __construct(string $path, BundleEntryReaderInterface $reader) { $this->path = $path; $this->reader = $reader; diff --git a/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php index 0eb82f621e155..cdd73716ceb7f 100644 --- a/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php @@ -32,7 +32,7 @@ class LocaleDataProvider * @param string $path The path to the directory containing the .res files * @param BundleEntryReaderInterface $reader The reader for reading the .res files */ - public function __construct($path, BundleEntryReaderInterface $reader) + public function __construct(string $path, BundleEntryReaderInterface $reader) { $this->path = $path; $this->reader = $reader; diff --git a/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php index d3c8164158a97..80880989a7b9e 100644 --- a/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php @@ -32,7 +32,7 @@ class RegionDataProvider * @param string $path The path to the directory containing the .res files * @param BundleEntryReaderInterface $reader The reader for reading the .res files */ - public function __construct($path, BundleEntryReaderInterface $reader) + public function __construct(string $path, BundleEntryReaderInterface $reader) { $this->path = $path; $this->reader = $reader; diff --git a/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php index 29ff1d63ae9b1..a4c5ce3a17472 100644 --- a/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php +++ b/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php @@ -32,7 +32,7 @@ class ScriptDataProvider * @param string $path The path to the directory containing the .res files * @param BundleEntryReaderInterface $reader The reader for reading the .res files */ - public function __construct($path, BundleEntryReaderInterface $reader) + public function __construct(string $path, BundleEntryReaderInterface $reader) { $this->path = $path; $this->reader = $reader; diff --git a/src/Symfony/Component/Intl/Data/Util/RingBuffer.php b/src/Symfony/Component/Intl/Data/Util/RingBuffer.php index b63c31e91970f..d7facfd249ba3 100644 --- a/src/Symfony/Component/Intl/Data/Util/RingBuffer.php +++ b/src/Symfony/Component/Intl/Data/Util/RingBuffer.php @@ -34,7 +34,7 @@ class RingBuffer implements \ArrayAccess private $size; - public function __construct($size) + public function __construct(int $size) { $this->size = $size; } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php index fa312d7f11d98..c66699a95e2ae 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php @@ -40,7 +40,7 @@ class FullTransformer * @param string $pattern The pattern to be used to format and/or parse values * @param string $timezone The timezone to perform the date/time calculations */ - public function __construct($pattern, $timezone) + public function __construct(string $pattern, string $timezone) { $this->pattern = $pattern; $this->timezone = $timezone; diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 7b3dfdfc22195..90db708294825 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -132,7 +132,7 @@ class IntlDateFormatter * @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed * @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed */ - public function __construct($locale, $datetype, $timetype, $timezone = null, $calendar = self::GREGORIAN, $pattern = null) + public function __construct(?string $locale, int $datetype, int $timetype, $timezone = null, ?int $calendar = self::GREGORIAN, string $pattern = null) { if ('en' !== $locale && null !== $locale) { throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported'); diff --git a/src/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php b/src/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php index f3ed0fa928594..bd6e4791debb1 100644 --- a/src/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php +++ b/src/Symfony/Component/Intl/Exception/MethodArgumentNotImplementedException.php @@ -20,7 +20,7 @@ class MethodArgumentNotImplementedException extends NotImplementedException * @param string $methodName The method name that raised the exception * @param string $argName The argument name that is not implemented */ - public function __construct($methodName, $argName) + public function __construct(string $methodName, string $argName) { $message = sprintf('The %s() method\'s argument $%s behavior is not implemented.', $methodName, $argName); parent::__construct($message); diff --git a/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php b/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php index 52228218ff33a..ee9ebe5e2fb55 100644 --- a/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php +++ b/src/Symfony/Component/Intl/Exception/MethodArgumentValueNotImplementedException.php @@ -19,10 +19,10 @@ class MethodArgumentValueNotImplementedException extends NotImplementedException /** * @param string $methodName The method name that raised the exception * @param string $argName The argument name - * @param string $argValue The argument value that is not implemented + * @param mixed $argValue The argument value that is not implemented * @param string $additionalMessage An optional additional message to append to the exception message */ - public function __construct($methodName, $argName, $argValue, $additionalMessage = '') + public function __construct(string $methodName, string $argName, $argValue, string $additionalMessage = '') { $message = sprintf( 'The %s() method\'s argument $%s value %s behavior is not implemented.%s', diff --git a/src/Symfony/Component/Intl/Exception/MethodNotImplementedException.php b/src/Symfony/Component/Intl/Exception/MethodNotImplementedException.php index 544e0e40a4821..6a45d71a483b2 100644 --- a/src/Symfony/Component/Intl/Exception/MethodNotImplementedException.php +++ b/src/Symfony/Component/Intl/Exception/MethodNotImplementedException.php @@ -19,7 +19,7 @@ class MethodNotImplementedException extends NotImplementedException /** * @param string $methodName The name of the method */ - public function __construct($methodName) + public function __construct(string $methodName) { parent::__construct(sprintf('The %s() is not implemented.', $methodName)); } diff --git a/src/Symfony/Component/Intl/Exception/NotImplementedException.php b/src/Symfony/Component/Intl/Exception/NotImplementedException.php index 47ac32b3201e9..1413886b3e86d 100644 --- a/src/Symfony/Component/Intl/Exception/NotImplementedException.php +++ b/src/Symfony/Component/Intl/Exception/NotImplementedException.php @@ -23,7 +23,7 @@ class NotImplementedException extends RuntimeException /** * @param string $message The exception message. A note to install the intl extension is appended to this string */ - public function __construct($message) + public function __construct(string $message) { parent::__construct($message.' '.self::INTL_INSTALL_MESSAGE); } diff --git a/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php index 645d4926dad15..739152346cc29 100644 --- a/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php @@ -18,7 +18,7 @@ */ class UnexpectedTypeException extends InvalidArgumentException { - public function __construct($value, $expectedType) + public function __construct($value, string $expectedType) { parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); } diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 844d61cecbc75..888f68a72b635 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -257,7 +257,7 @@ class NumberFormatter * @throws MethodArgumentValueNotImplementedException When the $style is not supported * @throws MethodArgumentNotImplementedException When the pattern value is different than null */ - public function __construct($locale = 'en', $style = null, $pattern = null) + public function __construct(?string $locale = 'en', string $style = null, $pattern = null) { if ('en' !== $locale && null !== $locale) { throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported'); diff --git a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php index b528b3b0a7fe3..11ae995630912 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php @@ -27,14 +27,7 @@ class CurrencyBundle extends CurrencyDataProvider implements CurrencyBundleInter { private $localeProvider; - /** - * Creates a new currency bundle. - * - * @param string $path - * @param BundleEntryReaderInterface $reader - * @param LocaleDataProvider $localeProvider - */ - public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider) + public function __construct(string $path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider) { parent::__construct($path, $reader); diff --git a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php b/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php index d709ba55626f6..436d211cad354 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php @@ -27,14 +27,7 @@ class RegionBundle extends RegionDataProvider implements RegionBundleInterface { private $localeProvider; - /** - * Creates a new region bundle. - * - * @param string $path - * @param BundleEntryReaderInterface $reader - * @param LocaleDataProvider $localeProvider - */ - public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider) + public function __construct(string $path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider) { parent::__construct($path, $reader); diff --git a/src/Symfony/Component/Intl/Util/SvnRepository.php b/src/Symfony/Component/Intl/Util/SvnRepository.php index 9716a5425ead7..00049791d9f84 100644 --- a/src/Symfony/Component/Intl/Util/SvnRepository.php +++ b/src/Symfony/Component/Intl/Util/SvnRepository.php @@ -75,7 +75,7 @@ public static function download($url, $targetDir) * * @param string $path The path to the repository */ - public function __construct($path) + public function __construct(string $path) { $this->path = $path; } diff --git a/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php b/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php index 5cacad79b249e..660e52dcb75fa 100644 --- a/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php +++ b/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php @@ -24,7 +24,7 @@ abstract class AbstractQuery implements QueryInterface protected $query; protected $options; - public function __construct(ConnectionInterface $connection, $dn, $query, array $options = array()) + public function __construct(ConnectionInterface $connection, string $dn, string $query, array $options = array()) { $resolver = new OptionsResolver(); $resolver->setDefaults(array( diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index 472ccf631b282..d238ebad920e1 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -27,7 +27,7 @@ class Query extends AbstractQuery /** @var resource */ private $search; - public function __construct(Connection $connection, $dn, $query, array $options = array()) + public function __construct(Connection $connection, string $dn, string $query, array $options = array()) { parent::__construct($connection, $dn, $query, $options); } diff --git a/src/Symfony/Component/Ldap/Entry.php b/src/Symfony/Component/Ldap/Entry.php index 42745c2b8928c..aac189624af9a 100644 --- a/src/Symfony/Component/Ldap/Entry.php +++ b/src/Symfony/Component/Ldap/Entry.php @@ -19,7 +19,7 @@ class Entry private $dn; private $attributes; - public function __construct($dn, array $attributes = array()) + public function __construct(string $dn, array $attributes = array()) { $this->dn = $dn; $this->attributes = $attributes; diff --git a/src/Symfony/Component/Lock/Key.php b/src/Symfony/Component/Lock/Key.php index dfb45f0c914a2..7fddafe9e2a1e 100644 --- a/src/Symfony/Component/Lock/Key.php +++ b/src/Symfony/Component/Lock/Key.php @@ -22,9 +22,6 @@ final class Key private $expiringTime; private $state = array(); - /** - * @param string $resource - */ public function __construct(string $resource) { $this->resource = $resource; diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php index 4d2c08d6fa583..e906554f31386 100644 --- a/src/Symfony/Component/Lock/Lock.php +++ b/src/Symfony/Component/Lock/Lock.php @@ -41,12 +41,12 @@ final class Lock implements LockInterface, LoggerAwareInterface * @param float|null $ttl Maximum expected lock duration in seconds * @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed */ - public function __construct(Key $key, StoreInterface $store, $ttl = null, $autoRelease = true) + public function __construct(Key $key, StoreInterface $store, float $ttl = null, bool $autoRelease = true) { $this->store = $store; $this->key = $key; $this->ttl = $ttl; - $this->autoRelease = (bool) $autoRelease; + $this->autoRelease = $autoRelease; $this->logger = new NullLogger(); } diff --git a/src/Symfony/Component/Lock/Store/FlockStore.php b/src/Symfony/Component/Lock/Store/FlockStore.php index 5babc7f610bce..bc03b859d00f3 100644 --- a/src/Symfony/Component/Lock/Store/FlockStore.php +++ b/src/Symfony/Component/Lock/Store/FlockStore.php @@ -36,7 +36,7 @@ class FlockStore implements StoreInterface * * @throws LockStorageException If the lock directory could not be created or is not writable */ - public function __construct($lockPath = null) + public function __construct(string $lockPath = null) { if (null === $lockPath) { $lockPath = sys_get_temp_dir(); diff --git a/src/Symfony/Component/Lock/Store/MemcachedStore.php b/src/Symfony/Component/Lock/Store/MemcachedStore.php index beaad69962084..c71e958e69d9a 100644 --- a/src/Symfony/Component/Lock/Store/MemcachedStore.php +++ b/src/Symfony/Component/Lock/Store/MemcachedStore.php @@ -44,7 +44,7 @@ public static function isSupported() * @param \Memcached $memcached * @param int $initialTtl the expiration delay of locks in seconds */ - public function __construct(\Memcached $memcached, $initialTtl = 300) + public function __construct(\Memcached $memcached, int $initialTtl = 300) { if (!static::isSupported()) { throw new InvalidArgumentException('Memcached extension is required'); @@ -155,12 +155,8 @@ public function exists(Key $key) /** * Retrieve an unique token for the given key. - * - * @param Key $key - * - * @return string */ - private function getToken(Key $key) + private function getToken(Key $key): string { if (!$key->hasState(__CLASS__)) { $token = base64_encode(random_bytes(32)); diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 9f17e49b78668..79dbd71df47b8 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -39,7 +39,7 @@ class RedisStore implements StoreInterface * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient * @param float $initialTtl the expiration delay of locks in seconds */ - public function __construct($redisClient, $initialTtl = 300.0) + public function __construct($redisClient, float $initialTtl = 300.0) { if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\Client) { throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, is_object($redisClient) ? get_class($redisClient) : gettype($redisClient))); @@ -131,13 +131,9 @@ public function exists(Key $key) /** * Evaluates a script in the corresponding redis client. * - * @param string $script - * @param string $resource - * @param array $args - * * @return mixed */ - private function evaluate($script, $resource, array $args) + private function evaluate(string $script, string $resource, array $args) { if ($this->redis instanceof \Redis || $this->redis instanceof \RedisCluster) { return $this->redis->eval($script, array_merge(array($resource), $args), 1); @@ -156,12 +152,8 @@ private function evaluate($script, $resource, array $args) /** * Retrieves an unique token for the given key. - * - * @param Key $key - * - * @return string */ - private function getToken(Key $key) + private function getToken(Key $key): string { if (!$key->hasState(__CLASS__)) { $token = base64_encode(random_bytes(32)); diff --git a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php index dfc3b266687d9..bf69a75f97fbe 100644 --- a/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php +++ b/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php @@ -37,7 +37,7 @@ class RetryTillSaveStore implements StoreInterface, LoggerAwareInterface * @param int $retrySleep Duration in ms between 2 retry * @param int $retryCount Maximum amount of retry */ - public function __construct(StoreInterface $decorated, $retrySleep = 100, $retryCount = PHP_INT_MAX) + public function __construct(StoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX) { $this->decorated = $decorated; $this->retrySleep = $retrySleep; diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index f5b84f05b4d5c..c81f73b0e0aa3 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -976,15 +976,12 @@ public function count() * non-technical people. * * @param mixed $value The value to return the type of - * @param string $type - * - * @return string The type of the value */ - private function formatTypeOf($value, $type) + private function formatTypeOf($value, ?string $type): string { $suffix = ''; - if ('[]' === substr($type, -2)) { + if (null !== $type && '[]' === substr($type, -2)) { $suffix = '[]'; $type = substr($type, 0, -2); while ('[]' === substr($type, -2)) { @@ -1017,10 +1014,8 @@ private function formatTypeOf($value, $type) * in double quotes ("). * * @param mixed $value The value to format as string - * - * @return string The string representation of the passed value */ - private function formatValue($value) + private function formatValue($value): string { if (is_object($value)) { return get_class($value); @@ -1059,13 +1054,9 @@ private function formatValue($value) * Each of the values is converted to a string using * {@link formatValue()}. The values are then concatenated with commas. * - * @param array $values A list of values - * - * @return string The string representation of the value list - * * @see formatValue() */ - private function formatValues(array $values) + private function formatValues(array $values): string { foreach ($values as $key => $value) { $values[$key] = $this->formatValue($value); diff --git a/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php b/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php index fef4a8ae867b8..e1f6445a4b3cb 100644 --- a/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php +++ b/src/Symfony/Component/Process/Exception/ProcessTimedOutException.php @@ -26,7 +26,7 @@ class ProcessTimedOutException extends RuntimeException private $process; private $timeoutType; - public function __construct(Process $process, $timeoutType) + public function __construct(Process $process, int $timeoutType) { $this->process = $process; $this->timeoutType = $timeoutType; diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index fad8e11267078..4c560ef9b2227 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -30,7 +30,7 @@ class PhpProcess extends Process * @param array|null $env The environment variables or null to use the same environment as the current PHP process * @param int $timeout The timeout in seconds */ - public function __construct($script, $cwd = null, array $env = null, $timeout = 60) + public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60) { $executableFinder = new PhpExecutableFinder(); if (false === $php = $executableFinder->find(false)) { diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index 4e0e452b4a044..d761c806bae18 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -26,11 +26,11 @@ class UnixPipes extends AbstractPipes private $ptyMode; private $haveReadSupport; - public function __construct($ttyMode, $ptyMode, $input, $haveReadSupport) + public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport) { - $this->ttyMode = (bool) $ttyMode; - $this->ptyMode = (bool) $ptyMode; - $this->haveReadSupport = (bool) $haveReadSupport; + $this->ttyMode = $ttyMode; + $this->ptyMode = $ptyMode; + $this->haveReadSupport = $haveReadSupport; parent::__construct($input); } diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index d5fa2fdeef67c..845d2bf70ebf1 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -34,9 +34,9 @@ class WindowsPipes extends AbstractPipes ); private $haveReadSupport; - public function __construct($input, $haveReadSupport) + public function __construct($input, bool $haveReadSupport) { - $this->haveReadSupport = (bool) $haveReadSupport; + $this->haveReadSupport = $haveReadSupport; if ($this->haveReadSupport) { // Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big. diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index fd9803c5592d9..d498cb56bd627 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -136,7 +136,7 @@ class Process implements \IteratorAggregate * * @throws RuntimeException When proc_open is not installed */ - public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60) + public function __construct($commandline, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) { if (!function_exists('proc_open')) { throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.'); @@ -194,7 +194,7 @@ public function __clone() * * @final since version 3.3 */ - public function run(callable $callback = null, array $env = array()) + public function run(callable $callback = null, array $env = array()): int { $this->start($callback, $env); @@ -402,7 +402,7 @@ public function wait(callable $callback = null) * * @return int|null The process id if running, null otherwise */ - public function getPid() + public function getPid() { return $this->isRunning() ? $this->processInformation['pid'] : null; } @@ -853,10 +853,8 @@ public function stop($timeout = 10, $signal = null) * Adds a line to the STDOUT stream. * * @internal - * - * @param string $line The line to append */ - public function addOutput($line) + public function addOutput(string $line) { $this->lastOutputTime = microtime(true); @@ -869,10 +867,8 @@ public function addOutput($line) * Adds a line to the STDERR stream. * * @internal - * - * @param string $line The line to append */ - public function addErrorOutput($line) + public function addErrorOutput(string $line) { $this->lastOutputTime = microtime(true); @@ -1195,10 +1191,8 @@ public static function isPtySupported() /** * Creates the descriptors needed by the proc_open. - * - * @return array */ - private function getDescriptors() + private function getDescriptors(): array { if ($this->input instanceof \Iterator) { $this->input->rewind(); @@ -1301,7 +1295,7 @@ protected function isSigchildEnabled() * * @throws LogicException in case output has been disabled or process is not started */ - private function readPipesForOutput($caller, $blocking = false) + private function readPipesForOutput(string $caller, bool $blocking = false) { if ($this->outputDisabled) { throw new LogicException('Output has been disabled.'); @@ -1315,13 +1309,9 @@ private function readPipesForOutput($caller, $blocking = false) /** * Validates and returns the filtered timeout. * - * @param int|float|null $timeout - * - * @return float|null - * * @throws InvalidArgumentException if the given timeout is a negative number */ - private function validateTimeout($timeout) + private function validateTimeout(?float $timeout): ?float { $timeout = (float) $timeout; @@ -1340,7 +1330,7 @@ private function validateTimeout($timeout) * @param bool $blocking Whether to use blocking calls or not * @param bool $close Whether to close file handles or not */ - private function readPipes($blocking, $close) + private function readPipes(bool $blocking, bool $close) { $result = $this->processPipes->readAndWrite($blocking, $close); @@ -1359,7 +1349,7 @@ private function readPipes($blocking, $close) * * @return int The exitcode */ - private function close() + private function close(): int { $this->processPipes->close(); if (is_resource($this->process)) { @@ -1417,7 +1407,7 @@ private function resetProcessData() * @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed * @throws RuntimeException In case of failure */ - private function doSignal($signal, $throwException) + private function doSignal(int $signal, bool $throwException): bool { if (null === $pid = $this->getPid()) { if ($throwException) { @@ -1512,11 +1502,9 @@ function ($m) use (&$envBackup, &$varCache, &$varCount, $uid) { /** * Ensures the process is running or terminated, throws a LogicException if the process has a not started. * - * @param string $functionName The function name that was called - * * @throws LogicException if the process has not run */ - private function requireProcessIsStarted($functionName) + private function requireProcessIsStarted(string $functionName) { if (!$this->isStarted()) { throw new LogicException(sprintf('Process must be started before calling %s.', $functionName)); @@ -1526,11 +1514,9 @@ private function requireProcessIsStarted($functionName) /** * Ensures the process is terminated, throws a LogicException if the process has a status different than `terminated`. * - * @param string $functionName The function name that was called - * * @throws LogicException if the process is not yet terminated */ - private function requireProcessIsTerminated($functionName) + private function requireProcessIsTerminated(string $functionName) { if (!$this->isTerminated()) { throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName)); @@ -1539,12 +1525,8 @@ private function requireProcessIsTerminated($functionName) /** * Escapes a string to be used as a shell argument. - * - * @param string $argument The argument that will be escaped - * - * @return string The escaped argument */ - private function escapeArgument($argument) + private function escapeArgument(string $argument): string { if ('\\' !== DIRECTORY_SEPARATOR) { return "'".str_replace("'", "'\\''", $argument)."'"; diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index f640a5c3bd73c..437728615b8d3 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -993,10 +993,9 @@ public function provideMethodsThatNeedATerminatedProcess() } /** - * @dataProvider provideWrongSignal * @expectedException \Symfony\Component\Process\Exception\RuntimeException */ - public function testWrongSignal($signal) + public function testWrongSignal() { if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('POSIX signals do not work on Windows'); @@ -1005,7 +1004,7 @@ public function testWrongSignal($signal) $process = $this->getProcessForCode('sleep(38);'); $process->start(); try { - $process->signal($signal); + $process->signal(-4); $this->fail('A RuntimeException must have been thrown'); } catch (RuntimeException $e) { $process->stop(0); @@ -1014,14 +1013,6 @@ public function testWrongSignal($signal) throw $e; } - public function provideWrongSignal() - { - return array( - array(-4), - array('Céphalopodes'), - ); - } - public function testDisableOutputDisablesTheOutput() { $p = $this->getProcess('foo'); diff --git a/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php b/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php index d238d3276d17a..c2b0492130cc8 100644 --- a/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/PropertyAccess/Exception/UnexpectedTypeException.php @@ -25,7 +25,7 @@ class UnexpectedTypeException extends RuntimeException * @param PropertyPathInterface $path The property path * @param int $pathIndex The property path index when the unexpected value was found */ - public function __construct($value, PropertyPathInterface $path, $pathIndex) + public function __construct($value, PropertyPathInterface $path, int $pathIndex) { $message = sprintf( 'PropertyAccessor requires a graph of objects or arrays to operate on, '. diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index d07d07fd835d8..a3a4ab053d53c 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -1,4 +1,5 @@ magicCall = $magicCall; $this->ignoreInvalidIndices = !$throwExceptionOnInvalidIndex; @@ -592,13 +589,9 @@ private function writeCollection($zval, $property, $collection, $addMethod, $rem /** * Guesses how to write the property value. * - * @param string $class - * @param string $property * @param mixed $value - * - * @return array */ - private function getWriteAccessInfo($class, $property, $value) + private function getWriteAccessInfo(string $class, string $property, $value): array { $key = (false !== strpos($class, '@') ? rawurlencode($class) : $class).'..'.$property; @@ -687,12 +680,9 @@ private function getWriteAccessInfo($class, $property, $value) /** * Returns whether a property is writable in the given object. * - * @param object $object The object to write to - * @param string $property The property to write - * - * @return bool Whether the property is writable + * @param object $object The object to write to */ - private function isPropertyWritable($object, $property) + private function isPropertyWritable($object, string $property): bool { if (!is_object($object)) { return false; @@ -709,12 +699,8 @@ private function isPropertyWritable($object, $property) /** * Camelizes a given string. - * - * @param string $string Some string - * - * @return string The camelized version of the string */ - private function camelize($string) + private function camelize(string $string): string { return str_replace(' ', '', ucwords(str_replace('_', ' ', $string))); } @@ -744,14 +730,8 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, array $singula /** * Returns whether a method is public and has the number of required parameters. - * - * @param \ReflectionClass $class The class of the method - * @param string $methodName The method name - * @param int $parameters The number of parameters - * - * @return bool Whether the method is public and has $parameters required parameters */ - private function isMethodAccessible(\ReflectionClass $class, $methodName, $parameters) + private function isMethodAccessible(\ReflectionClass $class, string $methodName, int $parameters): bool { if ($class->hasMethod($methodName)) { $method = $class->getMethod($methodName); @@ -770,10 +750,8 @@ private function isMethodAccessible(\ReflectionClass $class, $methodName, $param * Gets a PropertyPath instance and caches it. * * @param string|PropertyPath $propertyPath - * - * @return PropertyPath */ - private function getPropertyPath($propertyPath) + private function getPropertyPath($propertyPath): PropertyPath { if ($propertyPath instanceof PropertyPathInterface) { // Don't call the copy constructor has it is not needed here diff --git a/src/Symfony/Component/PropertyInfo/DependencyInjection/PropertyInfoPass.php b/src/Symfony/Component/PropertyInfo/DependencyInjection/PropertyInfoPass.php index c4bc893f72e9b..dd547f562be0f 100644 --- a/src/Symfony/Component/PropertyInfo/DependencyInjection/PropertyInfoPass.php +++ b/src/Symfony/Component/PropertyInfo/DependencyInjection/PropertyInfoPass.php @@ -31,7 +31,7 @@ class PropertyInfoPass implements CompilerPassInterface private $descriptionExtractorTag; private $accessExtractorTag; - public function __construct($propertyInfoService = 'property_info', $listExtractorTag = 'property_info.list_extractor', $typeExtractorTag = 'property_info.type_extractor', $descriptionExtractorTag = 'property_info.description_extractor', $accessExtractorTag = 'property_info.access_extractor') + public function __construct(string $propertyInfoService = 'property_info', string $listExtractorTag = 'property_info.list_extractor', string $typeExtractorTag = 'property_info.type_extractor', string $descriptionExtractorTag = 'property_info.description_extractor', string $accessExtractorTag = 'property_info.access_extractor') { $this->propertyInfoService = $propertyInfoService; $this->listExtractorTag = $listExtractorTag; diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php index c1010832df471..71edb47e5b4eb 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php @@ -83,12 +83,9 @@ public function getTypes($class, $property, array $context = array()) /** * Retrieves the cached data if applicable or delegates to the decorated extractor. * - * @param string $method - * @param array $arguments - * * @return mixed */ - private function extract($method, array $arguments) + private function extract(string $method, array $arguments) { try { $serializedArguments = serialize($arguments); diff --git a/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php b/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php index 9c8fc8d3f676f..939fb7c195932 100644 --- a/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php +++ b/src/Symfony/Component/PropertyInfo/Util/PhpDocTypeHelper.php @@ -73,11 +73,6 @@ public function getTypes(DocType $varType): array /** * Creates a {@see Type} from a PHPDoc type. - * - * @param string $docType - * @param bool $nullable - * - * @return Type|null */ private function createType(string $docType, bool $nullable): ?Type { diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index 03718052cb56f..44484c0e6ebd5 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -37,9 +37,9 @@ class CompiledRoute implements \Serializable * @param array $hostVariables An array of host variables * @param array $variables An array of variables (variables defined in the path and in the host patterns) */ - public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) + public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) { - $this->staticPrefix = (string) $staticPrefix; + $this->staticPrefix = $staticPrefix; $this->regex = $regex; $this->tokens = $tokens; $this->pathVariables = $pathVariables; diff --git a/src/Symfony/Component/Routing/DependencyInjection/RoutingResolverPass.php b/src/Symfony/Component/Routing/DependencyInjection/RoutingResolverPass.php index 4af0a5a28668b..a5116c99f23af 100644 --- a/src/Symfony/Component/Routing/DependencyInjection/RoutingResolverPass.php +++ b/src/Symfony/Component/Routing/DependencyInjection/RoutingResolverPass.php @@ -28,7 +28,7 @@ class RoutingResolverPass implements CompilerPassInterface private $resolverServiceId; private $loaderTag; - public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader') + public function __construct(string $resolverServiceId = 'routing.resolver', string $loaderTag = 'routing.loader') { $this->resolverServiceId = $resolverServiceId; $this->loaderTag = $loaderTag; diff --git a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php index 712412fecec58..22ca6c393cc85 100644 --- a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php +++ b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php @@ -22,7 +22,7 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn { protected $allowedMethods = array(); - public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null) + public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Exception $previous = null) { $this->allowedMethods = array_map('strtoupper', $allowedMethods); diff --git a/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php index 38d86cb895cb4..4166fce62694b 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php @@ -24,7 +24,7 @@ class CollectionConfigurator private $parent; - public function __construct(RouteCollection $parent, $name) + public function __construct(RouteCollection $parent, string $name) { $this->parent = $parent; $this->name = $name; @@ -40,13 +40,8 @@ public function __destruct() /** * Adds a route. - * - * @param string $name - * @param string $path - * - * @return RouteConfigurator */ - final public function add($name, $path) + final public function add(string $name, string $path): RouteConfigurator { $this->collection->add($this->name.$name, $route = clone $this->route); @@ -66,11 +61,9 @@ final public function collection($name = '') /** * Sets the prefix to add to the path of all child routes. * - * @param string $prefix - * * @return $this */ - final public function prefix($prefix) + final public function prefix(string $prefix) { $this->route->setPath($prefix); diff --git a/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php index d0a3c373ff23a..f978497dd20d9 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php @@ -36,11 +36,9 @@ public function __destruct() /** * Sets the prefix to add to the path of all child routes. * - * @param string $prefix - * * @return $this */ - final public function prefix($prefix) + final public function prefix(string $prefix) { $this->route->addPrefix($prefix); diff --git a/src/Symfony/Component/Routing/Loader/Configurator/RouteConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/RouteConfigurator.php index b8d87025435e0..df54a489e6fad 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/RouteConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/RouteConfigurator.php @@ -22,7 +22,7 @@ class RouteConfigurator use Traits\AddTrait; use Traits\RouteTrait; - public function __construct(RouteCollection $collection, Route $route, $name = '') + public function __construct(RouteCollection $collection, Route $route, string $name = '') { $this->collection = $collection; $this->route = $route; diff --git a/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php b/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php index 4591a86ba5cf9..713fcd2e05190 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php @@ -25,7 +25,7 @@ class RoutingConfigurator private $path; private $file; - public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file) + public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file) { $this->collection = $collection; $this->loader = $loader; diff --git a/src/Symfony/Component/Routing/Loader/Configurator/Traits/AddTrait.php b/src/Symfony/Component/Routing/Loader/Configurator/Traits/AddTrait.php index 7171fd241f6d0..779bacfa0eb45 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/Traits/AddTrait.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/Traits/AddTrait.php @@ -26,13 +26,8 @@ trait AddTrait /** * Adds a route. - * - * @param string $name - * @param string $path - * - * @return RouteConfigurator */ - final public function add($name, $path) + final public function add(string $name, string $path): RouteConfigurator { $this->collection->add($this->name.$name, $route = new Route($path)); @@ -41,13 +36,8 @@ final public function add($name, $path) /** * Adds a route. - * - * @param string $name - * @param string $path - * - * @return RouteConfigurator */ - final public function __invoke($name, $path) + final public function __invoke(string $name, string $path): RouteConfigurator { return $this->add($name, $path); } diff --git a/src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php b/src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php index 4d2e255b14076..3613f2522285f 100644 --- a/src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php +++ b/src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php @@ -60,11 +60,9 @@ final public function options(array $options) /** * Sets the condition. * - * @param string $condition - * * @return $this */ - final public function condition($condition) + final public function condition(string $condition) { $this->route->setCondition($condition); @@ -74,11 +72,9 @@ final public function condition($condition) /** * Sets the pattern for the host. * - * @param string $pattern - * * @return $this */ - final public function host($pattern) + final public function host(string $pattern) { $this->route->setHost($pattern); diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php index de9f39731238c..e0117890cdf2b 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php @@ -132,10 +132,6 @@ private function groupWithItem($item, string $prefix, $route) /** * Checks whether a prefix can be contained within the group. - * - * @param string $prefix - * - * @return bool Whether a prefix could belong in a given group */ private function accepts(string $prefix): bool { @@ -145,9 +141,6 @@ private function accepts(string $prefix): bool /** * Detects whether there's a common prefix relative to the group prefix and returns it. * - * @param string $prefix - * @param string $anotherPrefix - * * @return false|string A common prefix, longer than the base/group prefix, or false when none available */ private function detectCommonPrefix(string $prefix, string $anotherPrefix) @@ -223,8 +216,6 @@ private function shouldBeInlined(): bool /** * Guards against adding incompatible prefixes in a group. * - * @param string $prefix - * * @throws \LogicException when a prefix does not belong in a group */ private function guardAgainstAddingNotAcceptedRoutes(string $prefix) diff --git a/src/Symfony/Component/Routing/RequestContext.php b/src/Symfony/Component/Routing/RequestContext.php index d62a7766ef859..0a68fe08f6805 100644 --- a/src/Symfony/Component/Routing/RequestContext.php +++ b/src/Symfony/Component/Routing/RequestContext.php @@ -33,17 +33,7 @@ class RequestContext private $queryString; private $parameters = array(); - /** - * @param string $baseUrl The base URL - * @param string $method The HTTP method - * @param string $host The HTTP host name - * @param string $scheme The HTTP scheme - * @param int $httpPort The HTTP port - * @param int $httpsPort The HTTPS port - * @param string $path The path - * @param string $queryString The query string - */ - public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '') + public function __construct(string $baseUrl = '', string $method = 'GET', string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443, string $path = '/', string $queryString = '') { $this->setBaseUrl($baseUrl); $this->setMethod($method); diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index 4f84c41ca3887..19594d057c988 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -48,7 +48,7 @@ class Route implements \Serializable * @param string|string[] $methods A required HTTP method or an array of restricted methods * @param string $condition A condition that should evaluate to true for the route to match */ - public function __construct($path, array $defaults = array(), array $requirements = array(), array $options = array(), $host = '', $schemes = array(), $methods = array(), $condition = '') + public function __construct(string $path, array $defaults = array(), array $requirements = array(), array $options = array(), ?string $host = '', $schemes = array(), $methods = array(), ?string $condition = '') { $this->setPath($path); $this->setDefaults($defaults); diff --git a/src/Symfony/Component/Routing/RouteCollectionBuilder.php b/src/Symfony/Component/Routing/RouteCollectionBuilder.php index 78474cc5d2f97..d6bcfdbf02a79 100644 --- a/src/Symfony/Component/Routing/RouteCollectionBuilder.php +++ b/src/Symfony/Component/Routing/RouteCollectionBuilder.php @@ -326,10 +326,8 @@ public function build() /** * Generates a route name based on details of this route. - * - * @return string */ - private function generateRouteName(Route $route) + private function generateRouteName(Route $route): string { $methods = implode('_', $route->getMethods()).'_'; diff --git a/src/Symfony/Component/Routing/RouteCompiler.php b/src/Symfony/Component/Routing/RouteCompiler.php index 26beabc2ae3a3..b89efafcf8182 100644 --- a/src/Symfony/Component/Routing/RouteCompiler.php +++ b/src/Symfony/Component/Routing/RouteCompiler.php @@ -230,10 +230,8 @@ private static function compilePattern(Route $route, $pattern, $isHost) /** * Determines the longest static prefix possible for a route. - * - * @return string The leading static part of a route's path */ - private static function determineStaticPrefix(Route $route, array $tokens) + private static function determineStaticPrefix(Route $route, array $tokens): string { if ('text' !== $tokens[0][0]) { return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1]; @@ -249,14 +247,9 @@ private static function determineStaticPrefix(Route $route, array $tokens) } /** - * Returns the next static character in the Route pattern that will serve as a separator. - * - * @param string $pattern The route pattern - * @param bool $useUtf8 Whether the character is encoded in UTF-8 or not - * - * @return string The next static character that functions as separator (or empty string when none available) + * Returns the next static character in the Route pattern that will serve as a separator (or the empty string when none available) */ - private static function findNextSeparator($pattern, $useUtf8) + private static function findNextSeparator(string $pattern, bool $useUtf8): string { if ('' == $pattern) { // return empty string if pattern is empty or false (false which can be returned by substr) @@ -282,7 +275,7 @@ private static function findNextSeparator($pattern, $useUtf8) * * @return string The regexp pattern for a single token */ - private static function computeRegexp(array $tokens, $index, $firstOptional) + private static function computeRegexp(array $tokens, int $index, int $firstOptional): string { $token = $tokens[$index]; if ('text' === $token[0]) { diff --git a/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php b/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php index c57e575e46662..3a86aecd09aad 100644 --- a/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php +++ b/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php @@ -40,14 +40,14 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface * * @throws \InvalidArgumentException */ - public function __construct($providers, $eraseCredentials = true) + public function __construct(iterable $providers, bool $eraseCredentials = true) { if (!$providers) { throw new \InvalidArgumentException('You must at least add one authentication provider.'); } $this->providers = $providers; - $this->eraseCredentials = (bool) $eraseCredentials; + $this->eraseCredentials = $eraseCredentials; } public function setEventDispatcher(EventDispatcherInterface $dispatcher) diff --git a/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php b/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php index d191d6d532366..da7c34e58625b 100644 --- a/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php +++ b/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php @@ -23,11 +23,7 @@ class AuthenticationTrustResolver implements AuthenticationTrustResolverInterfac private $anonymousClass; private $rememberMeClass; - /** - * @param string $anonymousClass - * @param string $rememberMeClass - */ - public function __construct($anonymousClass, $rememberMeClass) + public function __construct(string $anonymousClass, string $rememberMeClass) { $this->anonymousClass = $anonymousClass; $this->rememberMeClass = $rememberMeClass; diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php index 8c4ee9a47562c..4472db1ad58cb 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php @@ -34,7 +34,7 @@ class AnonymousAuthenticationProvider implements AuthenticationProviderInterface /** * @param string $secret The secret shared with the AnonymousToken */ - public function __construct($secret) + public function __construct(string $secret) { $this->secret = $secret; } diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php index b7b7f51d209fe..9b3757ef5750a 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php @@ -31,14 +31,7 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider private $encoderFactory; private $userProvider; - /** - * @param UserProviderInterface $userProvider An UserProviderInterface instance - * @param UserCheckerInterface $userChecker An UserCheckerInterface instance - * @param string $providerKey The provider key - * @param EncoderFactoryInterface $encoderFactory An EncoderFactoryInterface instance - * @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not - */ - public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey, EncoderFactoryInterface $encoderFactory, $hideUserNotFoundExceptions = true) + public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, string $providerKey, EncoderFactoryInterface $encoderFactory, bool $hideUserNotFoundExceptions = true) { parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php index 6865c1d464047..e8a1baa8f0a9e 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php @@ -35,15 +35,7 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider private $dnString; private $queryString; - /** - * @param UserProviderInterface $userProvider A UserProvider - * @param UserCheckerInterface $userChecker A UserChecker - * @param string $providerKey The provider key - * @param LdapInterface $ldap A Ldap client - * @param string $dnString A string used to create the bind DN - * @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not - */ - public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey, LdapInterface $ldap, $dnString = '{username}', $hideUserNotFoundExceptions = true) + public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, string $providerKey, LdapInterface $ldap, string $dnString = '{username}', bool $hideUserNotFoundExceptions = true) { parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php index 2ed4d8fc9504c..0f923d92ce991 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php @@ -34,7 +34,7 @@ class PreAuthenticatedAuthenticationProvider implements AuthenticationProviderIn private $userChecker; private $providerKey; - public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, $providerKey) + public function __construct(UserProviderInterface $userProvider, UserCheckerInterface $userChecker, string $providerKey) { $this->userProvider = $userProvider; $this->userChecker = $userChecker; diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php index f8ba7476ba278..145cb3a0382c7 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php @@ -28,7 +28,7 @@ class RememberMeAuthenticationProvider implements AuthenticationProviderInterfac * @param string $secret A secret * @param string $providerKey A provider secret */ - public function __construct(UserCheckerInterface $userChecker, $secret, $providerKey) + public function __construct(UserCheckerInterface $userChecker, string $secret, string $providerKey) { $this->userChecker = $userChecker; $this->secret = $secret; diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php index ffbc72c055a0f..d3f5ad62913e0 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php @@ -25,7 +25,7 @@ class SimpleAuthenticationProvider implements AuthenticationProviderInterface private $userProvider; private $providerKey; - public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, $providerKey) + public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, string $providerKey) { $this->simpleAuthenticator = $simpleAuthenticator; $this->userProvider = $userProvider; diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php index 9244a2eacf1d8..f57503c7691b3 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php @@ -33,13 +33,9 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter private $providerKey; /** - * @param UserCheckerInterface $userChecker An UserCheckerInterface interface - * @param string $providerKey A provider key - * @param bool $hideUserNotFoundExceptions Whether to hide user not found exception or not - * * @throws \InvalidArgumentException */ - public function __construct(UserCheckerInterface $userChecker, $providerKey, $hideUserNotFoundExceptions = true) + public function __construct(UserCheckerInterface $userChecker, string $providerKey, bool $hideUserNotFoundExceptions = true) { if (empty($providerKey)) { throw new \InvalidArgumentException('$providerKey must not be empty.'); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php index 3c93664efcc70..fdeba46f97e6d 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php @@ -27,7 +27,7 @@ class AnonymousToken extends AbstractToken * @param string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string * @param Role[] $roles An array of roles */ - public function __construct($secret, $user, array $roles = array()) + public function __construct(string $secret, $user, array $roles = array()) { parent::__construct($roles); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php index 79275a29630e1..01ddc08a59b24 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php @@ -27,7 +27,7 @@ class PreAuthenticatedToken extends AbstractToken * @param string $providerKey The provider key * @param (Role|string)[] $roles An array of roles */ - public function __construct($user, $credentials, $providerKey, array $roles = array()) + public function __construct($user, $credentials, string $providerKey, array $roles = array()) { parent::__construct($roles); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php index 4130a437da4cc..6579668f50714 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php @@ -30,7 +30,7 @@ class RememberMeToken extends AbstractToken * * @throws \InvalidArgumentException */ - public function __construct(UserInterface $user, $providerKey, $secret) + public function __construct(UserInterface $user, string $providerKey, string $secret) { parent::__construct($user->getRoles()); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php index e85095a0edf35..1270cc2b4ce8f 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php @@ -29,7 +29,7 @@ class UsernamePasswordToken extends AbstractToken * * @throws \InvalidArgumentException */ - public function __construct($user, $credentials, $providerKey, array $roles = array()) + public function __construct($user, $credentials, string $providerKey, array $roles = array()) { parent::__construct($roles); diff --git a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php index a86c6c8a3e6ad..3259bdd9160d0 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php @@ -39,7 +39,7 @@ class AccessDecisionManager implements AccessDecisionManagerInterface * * @throws \InvalidArgumentException */ - public function __construct($voters = array(), $strategy = self::STRATEGY_AFFIRMATIVE, $allowIfAllAbstainDecisions = false, $allowIfEqualGrantedDeniedDecisions = true) + public function __construct(iterable $voters = array(), string $strategy = self::STRATEGY_AFFIRMATIVE, bool $allowIfAllAbstainDecisions = false, bool $allowIfEqualGrantedDeniedDecisions = true) { $strategyMethod = 'decide'.ucfirst($strategy); if (!is_callable(array($this, $strategyMethod))) { @@ -48,8 +48,8 @@ public function __construct($voters = array(), $strategy = self::STRATEGY_AFFIRM $this->voters = $voters; $this->strategy = $strategyMethod; - $this->allowIfAllAbstainDecisions = (bool) $allowIfAllAbstainDecisions; - $this->allowIfEqualGrantedDeniedDecisions = (bool) $allowIfEqualGrantedDeniedDecisions; + $this->allowIfAllAbstainDecisions = $allowIfAllAbstainDecisions; + $this->allowIfEqualGrantedDeniedDecisions = $allowIfEqualGrantedDeniedDecisions; } /** diff --git a/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php b/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php index 98934ff141a9d..67d5f833aff85 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php +++ b/src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php @@ -30,13 +30,7 @@ class AuthorizationChecker implements AuthorizationCheckerInterface private $authenticationManager; private $alwaysAuthenticate; - /** - * @param TokenStorageInterface $tokenStorage - * @param AuthenticationManagerInterface $authenticationManager An AuthenticationManager instance - * @param AccessDecisionManagerInterface $accessDecisionManager An AccessDecisionManager instance - * @param bool $alwaysAuthenticate - */ - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, $alwaysAuthenticate = false) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, bool $alwaysAuthenticate = false) { $this->tokenStorage = $tokenStorage; $this->authenticationManager = $authenticationManager; diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php index c8f9b7ec8e8a9..06dfb4228ea89 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php @@ -24,7 +24,7 @@ class RoleHierarchyVoter extends RoleVoter { private $roleHierarchy; - public function __construct(RoleHierarchyInterface $roleHierarchy, $prefix = 'ROLE_') + public function __construct(RoleHierarchyInterface $roleHierarchy, string $prefix = 'ROLE_') { $this->roleHierarchy = $roleHierarchy; diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php index 8fc7523119b93..3742b9912fa4e 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php @@ -23,10 +23,7 @@ class RoleVoter implements VoterInterface { private $prefix; - /** - * @param string $prefix The role prefix - */ - public function __construct($prefix = 'ROLE_') + public function __construct(string $prefix = 'ROLE_') { $this->prefix = $prefix; } diff --git a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php index d85afccd805b0..67e0ce7a07913 100644 --- a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php @@ -29,9 +29,8 @@ class BCryptPasswordEncoder extends BasePasswordEncoder implements SelfSaltingEn * @throws \RuntimeException When no BCrypt encoder is available * @throws \InvalidArgumentException if cost is out of range */ - public function __construct($cost) + public function __construct(int $cost) { - $cost = (int) $cost; if ($cost < 4 || $cost > 31) { throw new \InvalidArgumentException('Cost must be in the range of 4-31.'); } diff --git a/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php index e1e430d172888..b960580f203aa 100644 --- a/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php @@ -29,7 +29,7 @@ class MessageDigestPasswordEncoder extends BasePasswordEncoder * @param bool $encodeHashAsBase64 Whether to base64 encode the password hash * @param int $iterations The number of iterations to use to stretch the password hash */ - public function __construct($algorithm = 'sha512', $encodeHashAsBase64 = true, $iterations = 5000) + public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase64 = true, int $iterations = 5000) { $this->algorithm = $algorithm; $this->encodeHashAsBase64 = $encodeHashAsBase64; diff --git a/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php index ae83ec35872cc..186ee698bf8bd 100644 --- a/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php @@ -39,7 +39,7 @@ class Pbkdf2PasswordEncoder extends BasePasswordEncoder * @param int $iterations The number of iterations to use to stretch the password hash * @param int $length Length of derived key to create */ - public function __construct($algorithm = 'sha512', $encodeHashAsBase64 = true, $iterations = 1000, $length = 40) + public function __construct(string $algorithm = 'sha512', bool $encodeHashAsBase64 = true, int $iterations = 1000, int $length = 40) { $this->algorithm = $algorithm; $this->encodeHashAsBase64 = $encodeHashAsBase64; diff --git a/src/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php index bda6269a52012..a9347f7257fa9 100644 --- a/src/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php @@ -25,7 +25,7 @@ class PlaintextPasswordEncoder extends BasePasswordEncoder /** * @param bool $ignorePasswordCase Compare password case-insensitive */ - public function __construct($ignorePasswordCase = false) + public function __construct(bool $ignorePasswordCase = false) { $this->ignorePasswordCase = $ignorePasswordCase; } diff --git a/src/Symfony/Component/Security/Core/Exception/AccessDeniedException.php b/src/Symfony/Component/Security/Core/Exception/AccessDeniedException.php index a16044ff000a7..15d8a73aebcc8 100644 --- a/src/Symfony/Component/Security/Core/Exception/AccessDeniedException.php +++ b/src/Symfony/Component/Security/Core/Exception/AccessDeniedException.php @@ -21,7 +21,7 @@ class AccessDeniedException extends \RuntimeException private $attributes = array(); private $subject; - public function __construct($message = 'Access Denied.', \Exception $previous = null) + public function __construct(string $message = 'Access Denied.', \Exception $previous = null) { parent::__construct($message, 403, $previous); } diff --git a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php index 9f5071f4307db..2b9a00ebe30ce 100644 --- a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php @@ -26,7 +26,7 @@ class CustomUserMessageAuthenticationException extends AuthenticationException private $messageData = array(); - public function __construct($message = '', array $messageData = array(), $code = 0, \Exception $previous = null) + public function __construct(string $message = '', array $messageData = array(), int $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); diff --git a/src/Symfony/Component/Security/Core/Exception/LogoutException.php b/src/Symfony/Component/Security/Core/Exception/LogoutException.php index 2bb954fa7875d..947b19e7ad7fe 100644 --- a/src/Symfony/Component/Security/Core/Exception/LogoutException.php +++ b/src/Symfony/Component/Security/Core/Exception/LogoutException.php @@ -18,7 +18,7 @@ */ class LogoutException extends \RuntimeException { - public function __construct($message = 'Logout Exception', \Exception $previous = null) + public function __construct(string $message = 'Logout Exception', \Exception $previous = null) { parent::__construct($message, 403, $previous); } diff --git a/src/Symfony/Component/Security/Core/Role/Role.php b/src/Symfony/Component/Security/Core/Role/Role.php index 48f1cc5e8aec8..208fe2f6b7e06 100644 --- a/src/Symfony/Component/Security/Core/Role/Role.php +++ b/src/Symfony/Component/Security/Core/Role/Role.php @@ -20,12 +20,9 @@ class Role { private $role; - /** - * @param string $role The role name - */ - public function __construct($role) + public function __construct(string $role) { - $this->role = (string) $role; + $this->role = $role; } /** diff --git a/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php b/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php index f68f40750d03b..d26c7067a2d90 100644 --- a/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php +++ b/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php @@ -27,7 +27,7 @@ class SwitchUserRole extends Role * @param string $role The role as a string * @param TokenInterface $source The original token */ - public function __construct($role, TokenInterface $source) + public function __construct(string $role, TokenInterface $source) { parent::__construct($role); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php index 1b233cd9daa43..32131b001b248 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/RememberMeTokenTest.php @@ -30,7 +30,7 @@ public function testConstructor() } /** - * @expectedException \InvalidArgumentException + * @expectedException \TypeError */ public function testConstructorSecretCannotBeNull() { @@ -57,7 +57,7 @@ protected function getUser($roles = array('ROLE_FOO')) { $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); $user - ->expects($this->once()) + ->expects($this->any()) ->method('getRoles') ->will($this->returnValue($roles)) ; diff --git a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php index c585371253d7d..fcc3bcdb4236d 100644 --- a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php @@ -35,17 +35,7 @@ class LdapUserProvider implements UserProviderInterface private $defaultSearch; private $passwordAttribute; - /** - * @param LdapInterface $ldap - * @param string $baseDn - * @param string $searchDn - * @param string $searchPassword - * @param array $defaultRoles - * @param string $uidKey - * @param string $filter - * @param string $passwordAttribute - */ - public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = array(), $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null) + public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = array(), string $uidKey = 'sAMAccountName', string $filter = '({uid_key}={username})', string $passwordAttribute = null) { if (null === $uidKey) { $uidKey = 'sAMAccountName'; diff --git a/src/Symfony/Component/Security/Core/User/User.php b/src/Symfony/Component/Security/Core/User/User.php index bc81f7ffa795a..1f13b6630baff 100644 --- a/src/Symfony/Component/Security/Core/User/User.php +++ b/src/Symfony/Component/Security/Core/User/User.php @@ -28,7 +28,7 @@ final class User implements AdvancedUserInterface private $accountNonLocked; private $roles; - public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true) + public function __construct(?string $username, ?string $password, array $roles = array(), bool $enabled = true, bool $userNonExpired = true, bool $credentialsNonExpired = true, bool $userNonLocked = true) { if ('' === $username || null === $username) { throw new \InvalidArgumentException('The username cannot be empty.'); diff --git a/src/Symfony/Component/Security/Csrf/CsrfToken.php b/src/Symfony/Component/Security/Csrf/CsrfToken.php index 208fac3dba437..60340fb9501fd 100644 --- a/src/Symfony/Component/Security/Csrf/CsrfToken.php +++ b/src/Symfony/Component/Security/Csrf/CsrfToken.php @@ -21,14 +21,10 @@ class CsrfToken private $id; private $value; - /** - * @param string $id The token ID - * @param string $value The actual token value - */ - public function __construct($id, $value) + public function __construct(string $id, string $value) { - $this->id = (string) $id; - $this->value = (string) $value; + $this->id = $id; + $this->value = $value; } /** diff --git a/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php b/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php index f1e9122219478..59638518f5c42 100644 --- a/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php +++ b/src/Symfony/Component/Security/Csrf/TokenGenerator/UriSafeTokenGenerator.php @@ -25,7 +25,7 @@ class UriSafeTokenGenerator implements TokenGeneratorInterface * * @param int $entropy The amount of entropy collected for each token (in bits) */ - public function __construct($entropy = 256) + public function __construct(int $entropy = 256) { $this->entropy = $entropy; } diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php index d4866fd955917..d79e98d212c5d 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php @@ -33,7 +33,7 @@ class NativeSessionTokenStorage implements TokenStorageInterface * * @param string $namespace The namespace under which the token is stored in the session */ - public function __construct($namespace = self::SESSION_NAMESPACE) + public function __construct(string $namespace = self::SESSION_NAMESPACE) { $this->namespace = $namespace; } diff --git a/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php b/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php index 7b00e3231b45a..a13f367b0ec30 100644 --- a/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php +++ b/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php @@ -35,7 +35,7 @@ class SessionTokenStorage implements TokenStorageInterface * @param SessionInterface $session The user session from which the session ID is returned * @param string $namespace The namespace under which the token is stored in the session */ - public function __construct(SessionInterface $session, $namespace = self::SESSION_NAMESPACE) + public function __construct(SessionInterface $session, string $namespace = self::SESSION_NAMESPACE) { $this->session = $session; $this->namespace = $namespace; diff --git a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php index 768a0705fb6d0..80ae75caa2b85 100644 --- a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php +++ b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php @@ -47,7 +47,7 @@ class GuardAuthenticationListener implements ListenerInterface * @param iterable|AuthenticatorInterface[] $guardAuthenticators The authenticators, with keys that match what's passed to GuardAuthenticationProvider * @param LoggerInterface $logger A LoggerInterface instance */ - public function __construct(GuardAuthenticatorHandler $guardHandler, AuthenticationManagerInterface $authenticationManager, $providerKey, $guardAuthenticators, LoggerInterface $logger = null) + public function __construct(GuardAuthenticatorHandler $guardHandler, AuthenticationManagerInterface $authenticationManager, string $providerKey, $guardAuthenticators, LoggerInterface $logger = null) { if (empty($providerKey)) { throw new \InvalidArgumentException('$providerKey must not be empty.'); diff --git a/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php b/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php index 2f2678035fbcf..9ca26a74c2343 100644 --- a/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php @@ -45,7 +45,7 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface * @param string $providerKey The provider (i.e. firewall) key * @param UserCheckerInterface $userChecker */ - public function __construct($guardAuthenticators, UserProviderInterface $userProvider, $providerKey, UserCheckerInterface $userChecker) + public function __construct($guardAuthenticators, UserProviderInterface $userProvider, string $providerKey, UserCheckerInterface $userChecker) { $this->guardAuthenticators = $guardAuthenticators; $this->userProvider = $userProvider; diff --git a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php index f566b71242353..ad479ac24e5af 100644 --- a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php +++ b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php @@ -34,7 +34,7 @@ class PostAuthenticationGuardToken extends AbstractToken implements GuardTokenIn * * @throws \InvalidArgumentException */ - public function __construct(UserInterface $user, $providerKey, array $roles) + public function __construct(UserInterface $user, string $providerKey, array $roles) { parent::__construct($roles); diff --git a/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php b/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php index e1b39417d78e2..9f1c046e4cc1e 100644 --- a/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php +++ b/src/Symfony/Component/Security/Guard/Token/PreAuthenticationGuardToken.php @@ -31,7 +31,7 @@ class PreAuthenticationGuardToken extends AbstractToken implements GuardTokenInt * @param mixed $credentials * @param string $guardProviderKey Unique key that bind this token to a specific AuthenticatorInterface */ - public function __construct($credentials, $guardProviderKey) + public function __construct($credentials, string $guardProviderKey) { $this->credentials = $credentials; $this->guardProviderKey = $guardProviderKey; diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php index 32ea2b1c304bd..ba886373e969c 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php @@ -71,11 +71,9 @@ public function getLastUsername() } /** - * @return Request - * * @throws \LogicException */ - private function getRequest() + private function getRequest(): Request { $request = $this->requestStack->getCurrentRequest(); diff --git a/src/Symfony/Component/Security/Http/Authentication/CustomAuthenticationSuccessHandler.php b/src/Symfony/Component/Security/Http/Authentication/CustomAuthenticationSuccessHandler.php index 369e2d14c7893..64c6d32a91cd0 100644 --- a/src/Symfony/Component/Security/Http/Authentication/CustomAuthenticationSuccessHandler.php +++ b/src/Symfony/Component/Security/Http/Authentication/CustomAuthenticationSuccessHandler.php @@ -26,7 +26,7 @@ class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler * @param array $options Options for processing a successful authentication attempt * @param string $providerKey The provider key */ - public function __construct(AuthenticationSuccessHandlerInterface $handler, array $options, $providerKey) + public function __construct(AuthenticationSuccessHandlerInterface $handler, array $options, string $providerKey) { $this->handler = $handler; if (method_exists($handler, 'setOptions')) { diff --git a/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php index 2dc3d1196d154..4e60428df749a 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php @@ -24,7 +24,7 @@ class BasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface { private $realmName; - public function __construct($realmName) + public function __construct(string $realmName) { $this->realmName = $realmName; } diff --git a/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php index fbef67ea542a4..3ebdeffec8998 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php @@ -34,12 +34,12 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface * @param string $loginPath The path to the login form * @param bool $useForward Whether to forward or redirect to the login form */ - public function __construct(HttpKernelInterface $kernel, HttpUtils $httpUtils, $loginPath, $useForward = false) + public function __construct(HttpKernelInterface $kernel, HttpUtils $httpUtils, string $loginPath, bool $useForward = false) { $this->httpKernel = $kernel; $this->httpUtils = $httpUtils; $this->loginPath = $loginPath; - $this->useForward = (bool) $useForward; + $this->useForward = $useForward; } /** diff --git a/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php index d1a0a2880652f..bad771872ec5c 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php @@ -27,7 +27,7 @@ class RetryAuthenticationEntryPoint implements AuthenticationEntryPointInterface private $httpPort; private $httpsPort; - public function __construct($httpPort = 80, $httpsPort = 443) + public function __construct(int $httpPort = 80, int $httpsPort = 443) { $this->httpPort = $httpPort; $this->httpsPort = $httpsPort; diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php index 71a9311a93e3f..7002810ed76af 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php @@ -64,21 +64,9 @@ abstract class AbstractAuthenticationListener implements ListenerInterface private $rememberMeServices; /** - * @param TokenStorageInterface $tokenStorage A TokenStorageInterface instance - * @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance - * @param SessionAuthenticationStrategyInterface $sessionStrategy - * @param HttpUtils $httpUtils An HttpUtils instance - * @param string $providerKey - * @param AuthenticationSuccessHandlerInterface $successHandler - * @param AuthenticationFailureHandlerInterface $failureHandler - * @param array $options An array of options for the processing of a - * successful, or failed authentication attempt - * @param LoggerInterface|null $logger A LoggerInterface instance - * @param EventDispatcherInterface|null $dispatcher An EventDispatcherInterface instance - * * @throws \InvalidArgumentException */ - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) { if (empty($providerKey)) { throw new \InvalidArgumentException('$providerKey must not be empty.'); diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php index 0065fe8237c3e..1057868ddb337 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php @@ -38,7 +38,7 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface private $providerKey; private $dispatcher; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, string $providerKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) { $this->tokenStorage = $tokenStorage; $this->authenticationManager = $authenticationManager; diff --git a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php index 3f4de13df54b9..106b99f840258 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php @@ -31,7 +31,7 @@ class AnonymousAuthenticationListener implements ListenerInterface private $authenticationManager; private $logger; - public function __construct(TokenStorageInterface $tokenStorage, $secret, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null) + public function __construct(TokenStorageInterface $tokenStorage, string $secret, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null) { $this->tokenStorage = $tokenStorage; $this->secret = $secret; diff --git a/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php index 1ddc41643448e..f8a01ad405ab0 100644 --- a/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php @@ -33,7 +33,7 @@ class BasicAuthenticationListener implements ListenerInterface private $logger; private $ignoreFailure; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, string $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null) { if (empty($providerKey)) { throw new \InvalidArgumentException('$providerKey must not be empty.'); diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 79218f7a43dcc..67ce5cefaa123 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -48,12 +48,8 @@ class ContextListener implements ListenerInterface /** * @param TokenStorageInterface $tokenStorage * @param iterable|UserProviderInterface[] $userProviders - * @param string $contextKey - * @param LoggerInterface|null $logger - * @param EventDispatcherInterface|null $dispatcher - * @param AuthenticationTrustResolverInterface|null $trustResolver */ - public function __construct(TokenStorageInterface $tokenStorage, iterable $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, AuthenticationTrustResolverInterface $trustResolver = null) + public function __construct(TokenStorageInterface $tokenStorage, iterable $userProviders, string $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, AuthenticationTrustResolverInterface $trustResolver = null) { if (empty($contextKey)) { throw new \InvalidArgumentException('$contextKey must not be empty.'); diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index 756d1851d12f1..76ae56bd68684 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -52,7 +52,7 @@ class ExceptionListener private $httpUtils; private $stateless; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null, $stateless = false) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, string $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, string $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null, bool $stateless = false) { $this->tokenStorage = $tokenStorage; $this->accessDeniedHandler = $accessDeniedHandler; diff --git a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php index 13cb8755dfacd..ee69a793b6757 100644 --- a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php @@ -38,16 +38,7 @@ class RememberMeListener implements ListenerInterface private $catchExceptions = true; private $sessionStrategy; - /** - * @param TokenStorageInterface $tokenStorage - * @param RememberMeServicesInterface $rememberMeServices - * @param AuthenticationManagerInterface $authenticationManager - * @param LoggerInterface|null $logger - * @param EventDispatcherInterface|null $dispatcher - * @param bool $catchExceptions - * @param SessionAuthenticationStrategyInterface|null $sessionStrategy - */ - public function __construct(TokenStorageInterface $tokenStorage, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $catchExceptions = true, SessionAuthenticationStrategyInterface $sessionStrategy = null) + public function __construct(TokenStorageInterface $tokenStorage, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, bool $catchExceptions = true, SessionAuthenticationStrategyInterface $sessionStrategy = null) { $this->tokenStorage = $tokenStorage; $this->rememberMeServices = $rememberMeServices; diff --git a/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php index c42badff26a7d..69dcd4d6f16d3 100644 --- a/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php @@ -28,7 +28,7 @@ class RemoteUserAuthenticationListener extends AbstractPreAuthenticatedListener { private $userKey; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'REMOTE_USER', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, string $providerKey, string $userKey = 'REMOTE_USER', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) { parent::__construct($tokenStorage, $authenticationManager, $providerKey, $logger, $dispatcher); diff --git a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php index 4d060ab627f7c..bb52ce98e0750 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php @@ -37,23 +37,9 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener private $csrfTokenManager; /** - * @param TokenStorageInterface $tokenStorage A TokenStorageInterface instance - * @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance - * @param SessionAuthenticationStrategyInterface $sessionStrategy - * @param HttpUtils $httpUtils An HttpUtils instance - * @param string $providerKey - * @param AuthenticationSuccessHandlerInterface $successHandler - * @param AuthenticationFailureHandlerInterface $failureHandler - * @param array $options An array of options for the processing of a - * successful, or failed authentication attempt - * @param LoggerInterface|null $logger A LoggerInterface instance - * @param EventDispatcherInterface|null $dispatcher An EventDispatcherInterface instance - * @param CsrfTokenManagerInterface|null $csrfTokenManager A CsrfTokenManagerInterface instance - * @param SimpleFormAuthenticatorInterface|null $simpleAuthenticator A SimpleFormAuthenticatorInterface instance - * * @throws \InvalidArgumentException In case no simple authenticator is provided */ - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null) { if (!$simpleAuthenticator) { throw new \InvalidArgumentException('Missing simple authenticator'); diff --git a/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php index dd90712408615..ec607bb4574be 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php @@ -39,15 +39,7 @@ class SimplePreAuthenticationListener implements ListenerInterface private $logger; private $dispatcher; - /** - * @param TokenStorageInterface $tokenStorage A TokenStorageInterface instance - * @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance - * @param string $providerKey - * @param SimplePreAuthenticatorInterface $simpleAuthenticator A SimplePreAuthenticatorInterface instance - * @param LoggerInterface|null $logger A LoggerInterface instance - * @param EventDispatcherInterface|null $dispatcher An EventDispatcherInterface instance - */ - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, string $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) { if (empty($providerKey)) { throw new \InvalidArgumentException('$providerKey must not be empty.'); diff --git a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php index 0a0f33441398d..548ce7ce91900 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php @@ -51,7 +51,7 @@ class SwitchUserListener implements ListenerInterface private $dispatcher; private $stateless; - public function __construct(TokenStorageInterface $tokenStorage, UserProviderInterface $provider, UserCheckerInterface $userChecker, $providerKey, AccessDecisionManagerInterface $accessDecisionManager, LoggerInterface $logger = null, $usernameParameter = '_switch_user', $role = 'ROLE_ALLOWED_TO_SWITCH', EventDispatcherInterface $dispatcher = null, $stateless = false) + public function __construct(TokenStorageInterface $tokenStorage, UserProviderInterface $provider, UserCheckerInterface $userChecker, string $providerKey, AccessDecisionManagerInterface $accessDecisionManager, LoggerInterface $logger = null, string $usernameParameter = '_switch_user', string $role = 'ROLE_ALLOWED_TO_SWITCH', EventDispatcherInterface $dispatcher = null, bool $stateless = false) { if (empty($providerKey)) { throw new \InvalidArgumentException('$providerKey must not be empty.'); diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php index 426457d18267a..da689c9fcda0a 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php @@ -38,7 +38,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL { private $csrfTokenManager; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null) { parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, array_merge(array( 'username_parameter' => '_username', diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php index 955288c23c375..5a977b855ff2e 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordJsonAuthenticationListener.php @@ -53,7 +53,7 @@ class UsernamePasswordJsonAuthenticationListener implements ListenerInterface private $eventDispatcher; private $propertyAccessor; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $eventDispatcher = null, PropertyAccessorInterface $propertyAccessor = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $eventDispatcher = null, PropertyAccessorInterface $propertyAccessor = null) { $this->tokenStorage = $tokenStorage; $this->authenticationManager = $authenticationManager; diff --git a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php index 326c9af3ba962..f4957bbf65f11 100644 --- a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php @@ -28,7 +28,7 @@ class X509AuthenticationListener extends AbstractPreAuthenticatedListener private $userKey; private $credentialKey; - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'SSL_CLIENT_S_DN_Email', $credentialKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) + public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, string $providerKey, string $userKey = 'SSL_CLIENT_S_DN_Email', string $credentialKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null) { parent::__construct($tokenStorage, $authenticationManager, $providerKey, $logger, $dispatcher); diff --git a/src/Symfony/Component/Security/Http/Logout/DefaultLogoutSuccessHandler.php b/src/Symfony/Component/Security/Http/Logout/DefaultLogoutSuccessHandler.php index 48626b0690356..9f5c959cd23c8 100644 --- a/src/Symfony/Component/Security/Http/Logout/DefaultLogoutSuccessHandler.php +++ b/src/Symfony/Component/Security/Http/Logout/DefaultLogoutSuccessHandler.php @@ -25,14 +25,9 @@ class DefaultLogoutSuccessHandler implements LogoutSuccessHandlerInterface protected $httpUtils; protected $targetUrl; - /** - * @param HttpUtils $httpUtils - * @param string $targetUrl - */ - public function __construct(HttpUtils $httpUtils, $targetUrl = '/') + public function __construct(HttpUtils $httpUtils, string $targetUrl = '/') { $this->httpUtils = $httpUtils; - $this->targetUrl = $targetUrl; } diff --git a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php index afff015ed47b9..64ea8352ac3bd 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php @@ -44,15 +44,9 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface private $userProviders; /** - * @param array $userProviders - * @param string $secret - * @param string $providerKey - * @param array $options - * @param LoggerInterface $logger - * * @throws \InvalidArgumentException */ - public function __construct(array $userProviders, $secret, $providerKey, array $options = array(), LoggerInterface $logger = null) + public function __construct(array $userProviders, string $secret, string $providerKey, array $options = array(), LoggerInterface $logger = null) { if (empty($secret)) { throw new \InvalidArgumentException('$secret must not be empty.'); @@ -94,12 +88,10 @@ public function getSecret() * Implementation of RememberMeServicesInterface. Detects whether a remember-me * cookie was set, decodes it, and hands it to subclasses for further processing. * - * @return TokenInterface|null - * * @throws CookieTheftException * @throws \RuntimeException */ - final public function autoLogin(Request $request) + final public function autoLogin(Request $request): ?TokenInterface { if (null === $cookie = $request->cookies->get($this->options['name'])) { return null; @@ -150,6 +142,8 @@ final public function autoLogin(Request $request) throw $e; } + + return null; } /** diff --git a/src/Symfony/Component/Security/Http/Session/SessionAuthenticationStrategy.php b/src/Symfony/Component/Security/Http/Session/SessionAuthenticationStrategy.php index dd258a086f1f0..ed055f20949fc 100644 --- a/src/Symfony/Component/Security/Http/Session/SessionAuthenticationStrategy.php +++ b/src/Symfony/Component/Security/Http/Session/SessionAuthenticationStrategy.php @@ -32,7 +32,7 @@ class SessionAuthenticationStrategy implements SessionAuthenticationStrategyInte private $strategy; - public function __construct($strategy) + public function __construct(string $strategy) { $this->strategy = $strategy; } diff --git a/src/Symfony/Component/Serializer/DependencyInjection/SerializerPass.php b/src/Symfony/Component/Serializer/DependencyInjection/SerializerPass.php index e6202b8bf9d32..b43d54c291baf 100644 --- a/src/Symfony/Component/Serializer/DependencyInjection/SerializerPass.php +++ b/src/Symfony/Component/Serializer/DependencyInjection/SerializerPass.php @@ -31,7 +31,7 @@ class SerializerPass implements CompilerPassInterface private $normalizerTag; private $encoderTag; - public function __construct($serializerService = 'serializer', $normalizerTag = 'serializer.normalizer', $encoderTag = 'serializer.encoder') + public function __construct(string $serializerService = 'serializer', string $normalizerTag = 'serializer.normalizer', string $encoderTag = 'serializer.encoder') { $this->serializerService = $serializerService; $this->normalizerTag = $normalizerTag; diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php index df0207ccf30fb..55ae69bd938e1 100644 --- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php @@ -33,13 +33,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface private $escapeChar; private $keySeparator; - /** - * @param string $delimiter - * @param string $enclosure - * @param string $escapeChar - * @param string $keySeparator - */ - public function __construct($delimiter = ',', $enclosure = '"', $escapeChar = '\\', $keySeparator = '.') + public function __construct(string $delimiter = ',', string $enclosure = '"', string $escapeChar = '\\', string $keySeparator = '.') { $this->delimiter = $delimiter; $this->enclosure = $enclosure; @@ -174,13 +168,8 @@ public function supportsDecoding($format) /** * Flattens an array and generates keys including the path. - * - * @param array $array - * @param array $result - * @param string $keySeparator - * @param string $parentKey */ - private function flatten(array $array, array &$result, $keySeparator, $parentKey = '') + private function flatten(array $array, array &$result, string $keySeparator, string $parentKey = '') { foreach ($array as $key => $value) { if (is_array($value)) { diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index e2df2ea1c163d..4050ace3564c0 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -32,10 +32,10 @@ class JsonDecode implements DecoderInterface * @param bool $associative True to return the result associative array, false for a nested stdClass hierarchy * @param int $depth Specifies the recursion depth */ - public function __construct($associative = false, $depth = 512) + public function __construct(bool $associative = false, int $depth = 512) { $this->associative = $associative; - $this->recursionDepth = (int) $depth; + $this->recursionDepth = $depth; } /** diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index ca42abc5a465d..57ae29075972e 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -23,7 +23,7 @@ class JsonEncode implements EncoderInterface private $options; private $lastError = JSON_ERROR_NONE; - public function __construct($bitmask = 0) + public function __construct(int $bitmask = 0) { $this->options = $bitmask; } diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 8ff22562debc0..b15b1946d7a5e 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -44,7 +44,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa * @param string $rootNodeName * @param int|null $loadOptions A bit field of LIBXML_* constants */ - public function __construct($rootNodeName = 'response', $loadOptions = null) + public function __construct(string $rootNodeName = 'response', int $loadOptions = null) { $this->rootNodeName = $rootNodeName; $this->loadOptions = null !== $loadOptions ? $loadOptions : LIBXML_NONET | LIBXML_NOBLANKS; @@ -180,15 +180,9 @@ public function getRootNodeName() return $this->rootNodeName; } - /** - * @param \DOMNode $node - * @param string $val - * - * @return bool - */ - final protected function appendXMLString(\DOMNode $node, $val) + final protected function appendXMLString(\DOMNode $node, string $val): bool { - if (strlen($val) > 0) { + if ('' !== $val) { $frag = $this->dom->createDocumentFragment(); $frag->appendXML($val); $node->appendChild($frag); @@ -199,13 +193,7 @@ final protected function appendXMLString(\DOMNode $node, $val) return false; } - /** - * @param \DOMNode $node - * @param string $val - * - * @return bool - */ - final protected function appendText(\DOMNode $node, $val) + final protected function appendText(\DOMNode $node, string $val): bool { $nodeText = $this->dom->createTextNode($val); $node->appendChild($nodeText); @@ -213,13 +201,7 @@ final protected function appendText(\DOMNode $node, $val) return true; } - /** - * @param \DOMNode $node - * @param string $val - * - * @return bool - */ - final protected function appendCData(\DOMNode $node, $val) + final protected function appendCData(\DOMNode $node, string $val): bool { $nodeText = $this->dom->createCDATASection($val); $node->appendChild($nodeText); @@ -230,10 +212,8 @@ final protected function appendCData(\DOMNode $node, $val) /** * @param \DOMNode $node * @param \DOMDocumentFragment $fragment - * - * @return bool */ - final protected function appendDocumentFragment(\DOMNode $node, $fragment) + final protected function appendDocumentFragment(\DOMNode $node, $fragment): bool { if ($fragment instanceof \DOMDocumentFragment) { $node->appendChild($fragment); @@ -246,12 +226,8 @@ final protected function appendDocumentFragment(\DOMNode $node, $fragment) /** * Checks the name is a valid xml element name. - * - * @param string $name - * - * @return bool */ - final protected function isElementNameValid($name) + final protected function isElementNameValid(string $name): bool { return $name && false === strpos($name, ' ') && @@ -294,10 +270,8 @@ private function parseXml(\DOMNode $node, array $context = array()) /** * Parse the input DOMNode attributes into an array. - * - * @return array */ - private function parseXmlAttributes(\DOMNode $node, array $context = array()) + private function parseXmlAttributes(\DOMNode $node, array $context = array()): array { if (!$node->hasAttributes()) { return array(); @@ -374,13 +348,10 @@ private function parseXmlValue(\DOMNode $node, array $context = array()) * * @param \DOMNode $parentNode * @param array|object $data - * @param string|null $xmlRootNodeName - * - * @return bool * * @throws NotEncodableValueException */ - private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null) + private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName = null): bool { $append = true; @@ -443,12 +414,8 @@ private function buildXml(\DOMNode $parentNode, $data, $xmlRootNodeName = null) * * @param \DOMNode $parentNode * @param array|object $data - * @param string $nodeName - * @param string $key - * - * @return bool */ - private function appendNode(\DOMNode $parentNode, $data, $nodeName, $key = null) + private function appendNode(\DOMNode $parentNode, $data, string $nodeName, string $key = null): bool { $node = $this->dom->createElement($nodeName); if (null !== $key) { @@ -465,12 +432,8 @@ private function appendNode(\DOMNode $parentNode, $data, $nodeName, $key = null) /** * Checks if a value contains any characters which would require CDATA wrapping. - * - * @param string $val - * - * @return bool */ - private function needsCdataWrapping($val) + private function needsCdataWrapping(string $val): bool { return 0 < preg_match('/[<>&]/', $val); } @@ -481,11 +444,9 @@ private function needsCdataWrapping($val) * @param \DOMNode $node * @param mixed $val * - * @return bool - * * @throws NotEncodableValueException */ - private function selectNodeType(\DOMNode $node, $val) + private function selectNodeType(\DOMNode $node, $val): bool { if (is_array($val)) { return $this->buildXml($node, $val); @@ -514,10 +475,8 @@ private function selectNodeType(\DOMNode $node, $val) /** * Get real XML root node name, taking serializer options into account. - * - * @return string */ - private function resolveXmlRootName(array $context = array()) + private function resolveXmlRootName(array $context = array()): string { return isset($context['xml_root_node_name']) ? $context['xml_root_node_name'] @@ -526,12 +485,8 @@ private function resolveXmlRootName(array $context = array()) /** * Get XML option for type casting attributes Defaults to true. - * - * @param array $context - * - * @return bool */ - private function resolveXmlTypeCastAttributes(array $context = array()) + private function resolveXmlTypeCastAttributes(array $context = array()): bool { return isset($context['xml_type_cast_attributes']) ? (bool) $context['xml_type_cast_attributes'] @@ -540,12 +495,8 @@ private function resolveXmlTypeCastAttributes(array $context = array()) /** * Create a DOM document, taking serializer options into account. - * - * @param array $context Options that the encoder has access to - * - * @return \DOMDocument */ - private function createDomDocument(array $context) + private function createDomDocument(array $context): \DOMDocument { $document = new \DOMDocument(); diff --git a/src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php b/src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php index 5888234a4c285..64e3812465459 100644 --- a/src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php +++ b/src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php @@ -41,12 +41,7 @@ class AttributeMetadata implements AttributeMetadataInterface */ public $maxDepth; - /** - * Constructs a metadata for the given attribute. - * - * @param string $name - */ - public function __construct($name) + public function __construct(string $name) { $this->name = $name; } diff --git a/src/Symfony/Component/Serializer/Mapping/ClassMetadata.php b/src/Symfony/Component/Serializer/Mapping/ClassMetadata.php index 7858f74dbbe29..75401fc14d05d 100644 --- a/src/Symfony/Component/Serializer/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Serializer/Mapping/ClassMetadata.php @@ -39,12 +39,7 @@ class ClassMetadata implements ClassMetadataInterface */ private $reflClass; - /** - * Constructs a metadata for the given class. - * - * @param string $class - */ - public function __construct($class) + public function __construct(string $class) { $this->name = $class; } diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php index ce376010e5584..11000b9c294e4 100644 --- a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php +++ b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php @@ -31,9 +31,6 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface */ private $loadedClasses; - /** - * @param LoaderInterface $loader - */ public function __construct(LoaderInterface $loader) { $this->loader = $loader; diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php index d1b0dee93e9c0..80544427dccf0 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php @@ -27,7 +27,7 @@ abstract class FileLoader implements LoaderInterface * * @throws MappingException if the mapping file does not exist or is not readable */ - public function __construct($file) + public function __construct(string $file) { if (!is_file($file)) { throw new MappingException(sprintf('The mapping file %s does not exist', $file)); diff --git a/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php b/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php index 8a974865b4b61..c433e098c7312 100644 --- a/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php +++ b/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php @@ -25,7 +25,7 @@ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface * @param null|array $attributes The list of attributes to rename or null for all attributes * @param bool $lowerCamelCase Use lowerCamelCase style */ - public function __construct(array $attributes = null, $lowerCamelCase = true) + public function __construct(array $attributes = null, bool $lowerCamelCase = true) { $this->attributes = $attributes; $this->lowerCamelCase = $lowerCamelCase; diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 93e5f9bc5e126..f547b4984ffd4 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -225,18 +225,14 @@ abstract protected function setAttributeValue($object, $attribute, $value, $form /** * Validates the submitted data and denormalizes it. * - * @param string $currentClass - * @param string $attribute * @param mixed $data - * @param string|null $format - * @param array $context * * @return mixed * * @throws NotNormalizableValueException * @throws LogicException */ - private function validateAndDenormalize($currentClass, $attribute, $data, $format, array $context) + private function validateAndDenormalize(string $currentClass, string $attribute, $data, ?string $format, array $context) { if (null === $this->propertyTypeExtractor || null === $types = $this->propertyTypeExtractor->getTypes($currentClass, $attribute)) { return $data; @@ -298,13 +294,9 @@ private function validateAndDenormalize($currentClass, $attribute, $data, $forma /** * Sets an attribute and apply the name converter if necessary. * - * @param array $data - * @param string $attribute * @param mixed $attributeValue - * - * @return array */ - private function updateData(array $data, $attribute, $attributeValue) + private function updateData(array $data, string $attribute, $attributeValue): array { if ($this->nameConverter) { $attribute = $this->nameConverter->normalize($attribute); @@ -319,13 +311,8 @@ private function updateData(array $data, $attribute, $attributeValue) * Is the max depth reached for the given attribute? * * @param AttributeMetadataInterface[] $attributesMetadata - * @param string $class - * @param string $attribute - * @param array $context - * - * @return bool */ - private function isMaxDepthReached(array $attributesMetadata, $class, $attribute, array &$context) + private function isMaxDepthReached(array $attributesMetadata, string $class, string $attribute, array &$context): bool { if ( !isset($context[static::ENABLE_MAX_DEPTH]) || @@ -354,12 +341,9 @@ private function isMaxDepthReached(array $attributesMetadata, $class, $attribute /** * Gets the cache key to use. * - * @param string|null $format - * @param array $context - * * @return bool|string */ - private function getCacheKey($format, array $context) + private function getCacheKey(?string $format, array $context) { try { return md5($format.serialize($context)); diff --git a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php index f3c663c6b788d..7ab102ed7a9ec 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php @@ -26,10 +26,7 @@ class DateIntervalNormalizer implements NormalizerInterface, DenormalizerInterfa private $format; - /** - * @param string $format - */ - public function __construct($format = 'P%yY%mM%dDT%hH%iM%sS') + public function __construct(string $format = 'P%yY%mM%dDT%hH%iM%sS') { $this->format = $format; } diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php index 7bb23194192cb..4d3171dcec643 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php @@ -34,11 +34,7 @@ class DateTimeNormalizer implements NormalizerInterface, DenormalizerInterface \DateTime::class => true, ); - /** - * @param string $format - * @param \DateTimeZone|null $timezone - */ - public function __construct($format = \DateTime::RFC3339, \DateTimeZone $timezone = null) + public function __construct(?string $format = \DateTime::RFC3339, \DateTimeZone $timezone = null) { $this->format = $format; $this->timezone = $timezone; diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index b5dbee7d51f34..3307fbec1a718 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -55,12 +55,8 @@ public function supportsDenormalization($data, $type, $format = null) /** * Checks if the given class has any get{Property} method. - * - * @param string $class - * - * @return bool */ - private function supports($class) + private function supports(string $class): bool { $class = new \ReflectionClass($class); $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); @@ -75,10 +71,8 @@ private function supports($class) /** * Checks if a method's name is get.* or is.*, and can be called without parameters. - * - * @return bool whether the method is a getter or boolean getter */ - private function isGetMethod(\ReflectionMethod $method) + private function isGetMethod(\ReflectionMethod $method): bool { $methodLength = strlen($method->name); diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php index 2921e5baf9532..e41df0b6fd6c1 100644 --- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php @@ -50,12 +50,8 @@ public function supportsDenormalization($data, $type, $format = null) /** * Checks if the given class has any non-static property. - * - * @param string $class - * - * @return bool */ - private function supports($class) + private function supports(string $class): bool { $class = new \ReflectionClass($class); @@ -155,13 +151,10 @@ protected function setAttributeValue($object, $attribute, $value, $format = null /** * @param string|object $classOrObject - * @param string $attribute - * - * @return \ReflectionProperty * * @throws \ReflectionException */ - private function getReflectionProperty($classOrObject, $attribute) + private function getReflectionProperty($classOrObject, string $attribute): \ReflectionProperty { $reflectionClass = new \ReflectionClass($classOrObject); while (true) { diff --git a/src/Symfony/Component/Stopwatch/Section.php b/src/Symfony/Component/Stopwatch/Section.php index 0860dbe7fcdfd..50640b0b27740 100644 --- a/src/Symfony/Component/Stopwatch/Section.php +++ b/src/Symfony/Component/Stopwatch/Section.php @@ -47,9 +47,9 @@ class Section * @param float|null $origin Set the origin of the events in this section, use null to set their origin to their start time * @param bool $morePrecision If true, time is stored as float to keep the original microsecond precision */ - public function __construct($origin = null, $morePrecision = false) + public function __construct(float $origin = null, bool $morePrecision = false) { - $this->origin = is_numeric($origin) ? $origin : null; + $this->origin = $origin; $this->morePrecision = $morePrecision; } diff --git a/src/Symfony/Component/Stopwatch/Stopwatch.php b/src/Symfony/Component/Stopwatch/Stopwatch.php index a1d5d959c8e1a..fe1645fc544e1 100644 --- a/src/Symfony/Component/Stopwatch/Stopwatch.php +++ b/src/Symfony/Component/Stopwatch/Stopwatch.php @@ -36,7 +36,7 @@ class Stopwatch /** * @param bool $morePrecision If true, time is stored as float to keep the original microsecond precision */ - public function __construct($morePrecision = false) + public function __construct(bool $morePrecision = false) { $this->morePrecision = $morePrecision; $this->reset(); diff --git a/src/Symfony/Component/Stopwatch/StopwatchEvent.php b/src/Symfony/Component/Stopwatch/StopwatchEvent.php index d8f9d1361d586..410f935a269eb 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchEvent.php +++ b/src/Symfony/Component/Stopwatch/StopwatchEvent.php @@ -50,7 +50,7 @@ class StopwatchEvent * * @throws \InvalidArgumentException When the raw time is not valid */ - public function __construct($origin, $category = null, $morePrecision = false) + public function __construct(float $origin, string $category = null, bool $morePrecision = false) { $this->origin = $this->formatTime($origin); $this->category = is_string($category) ? $category : 'default'; diff --git a/src/Symfony/Component/Stopwatch/StopwatchPeriod.php b/src/Symfony/Component/Stopwatch/StopwatchPeriod.php index 5626aa5333042..213cf59e12e89 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchPeriod.php +++ b/src/Symfony/Component/Stopwatch/StopwatchPeriod.php @@ -27,7 +27,7 @@ class StopwatchPeriod * @param int|float $end The relative time of the end of the period (in milliseconds) * @param bool $morePrecision If true, time is stored as float to keep the original microsecond precision */ - public function __construct($start, $end, $morePrecision = false) + public function __construct($start, $end, bool $morePrecision = false) { $this->start = $morePrecision ? (float) $start : (int) $start; $this->end = $morePrecision ? (float) $end : (int) $end; diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index f2ee039797753..fa10bd2ddfab3 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -155,7 +155,7 @@ public function testStartTime() } /** - * @expectedException \InvalidArgumentException + * @expectedException \TypeError */ public function testInvalidOriginThrowsAnException() { diff --git a/src/Symfony/Component/Templating/Loader/CacheLoader.php b/src/Symfony/Component/Templating/Loader/CacheLoader.php index b17461c5ee8fb..51f3024082a20 100644 --- a/src/Symfony/Component/Templating/Loader/CacheLoader.php +++ b/src/Symfony/Component/Templating/Loader/CacheLoader.php @@ -33,7 +33,7 @@ class CacheLoader extends Loader * @param LoaderInterface $loader A Loader instance * @param string $dir The directory where to store the cache files */ - public function __construct(LoaderInterface $loader, $dir) + public function __construct(LoaderInterface $loader, string $dir) { $this->loader = $loader; $this->dir = $dir; diff --git a/src/Symfony/Component/Templating/Storage/Storage.php b/src/Symfony/Component/Templating/Storage/Storage.php index 87245b3d425f3..8c817ba5b0187 100644 --- a/src/Symfony/Component/Templating/Storage/Storage.php +++ b/src/Symfony/Component/Templating/Storage/Storage.php @@ -23,7 +23,7 @@ abstract class Storage /** * @param string $template The template name */ - public function __construct($template) + public function __construct(string $template) { $this->template = $template; } diff --git a/src/Symfony/Component/Templating/TemplateReference.php b/src/Symfony/Component/Templating/TemplateReference.php index 3477f088ff245..311e817600543 100644 --- a/src/Symfony/Component/Templating/TemplateReference.php +++ b/src/Symfony/Component/Templating/TemplateReference.php @@ -20,7 +20,7 @@ class TemplateReference implements TemplateReferenceInterface { protected $parameters; - public function __construct($name = null, $engine = null) + public function __construct(string $name = null, string $engine = null) { $this->parameters = array( 'name' => $name, diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php index fead5edcb18bb..042ab1eab8b32 100644 --- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php +++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php @@ -33,7 +33,7 @@ class XliffLintCommand extends Command private $directoryIteratorProvider; private $isReadableProvider; - public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null) + public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null) { parent::__construct($name); diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslationDumperPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslationDumperPass.php index 1ca79cf00a5bd..e620226e83267 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslationDumperPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslationDumperPass.php @@ -23,7 +23,7 @@ class TranslationDumperPass implements CompilerPassInterface private $writerServiceId; private $dumperTag; - public function __construct($writerServiceId = 'translation.writer', $dumperTag = 'translation.dumper') + public function __construct(string $writerServiceId = 'translation.writer', string $dumperTag = 'translation.dumper') { $this->writerServiceId = $writerServiceId; $this->dumperTag = $dumperTag; diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslationExtractorPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslationExtractorPass.php index 06105187952c4..18c67f68ec2a8 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslationExtractorPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslationExtractorPass.php @@ -24,7 +24,7 @@ class TranslationExtractorPass implements CompilerPassInterface private $extractorServiceId; private $extractorTag; - public function __construct($extractorServiceId = 'translation.extractor', $extractorTag = 'translation.extractor') + public function __construct(string $extractorServiceId = 'translation.extractor', string $extractorTag = 'translation.extractor') { $this->extractorServiceId = $extractorServiceId; $this->extractorTag = $extractorTag; diff --git a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php index 14cea77605647..199702b4692f4 100644 --- a/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php +++ b/src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php @@ -22,7 +22,7 @@ class TranslatorPass implements CompilerPassInterface private $readerServiceId; private $loaderTag; - public function __construct($translatorServiceId = 'translator.default', $readerServiceId = 'translation.reader', $loaderTag = 'translation.loader') + public function __construct(string $translatorServiceId = 'translator.default', string $readerServiceId = 'translation.reader', string $loaderTag = 'translation.loader') { $this->translatorServiceId = $translatorServiceId; $this->readerServiceId = $readerServiceId; diff --git a/src/Symfony/Component/Translation/Dumper/FileDumper.php b/src/Symfony/Component/Translation/Dumper/FileDumper.php index 51b111821c8c1..2e047ed7c0e42 100644 --- a/src/Symfony/Component/Translation/Dumper/FileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/FileDumper.php @@ -100,13 +100,8 @@ abstract protected function getExtension(); /** * Gets the relative file path using the template. - * - * @param string $domain The domain - * @param string $locale The locale - * - * @return string The relative file path */ - private function getRelativePath($domain, $locale) + private function getRelativePath(string $domain, string $locale): string { return strtr($this->relativePathTemplate, array( '%domain%' => $domain, diff --git a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php index b9c524e820c03..40b36451dab52 100644 --- a/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php +++ b/src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php @@ -43,12 +43,7 @@ protected function extractFiles($resource) return $files; } - /** - * @param string $file - * - * @return \SplFileInfo - */ - private function toSplFileInfo($file) + private function toSplFileInfo(string $file): \SplFileInfo { return ($file instanceof \SplFileInfo) ? $file : new \SplFileInfo($file); } diff --git a/src/Symfony/Component/Translation/Loader/MoFileLoader.php b/src/Symfony/Component/Translation/Loader/MoFileLoader.php index aad2bba220437..918bf94a0a5dd 100644 --- a/src/Symfony/Component/Translation/Loader/MoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/MoFileLoader.php @@ -134,11 +134,8 @@ protected function loadResource($resource) * Reads an unsigned long from stream respecting endianness. * * @param resource $stream - * @param bool $isBigEndian - * - * @return int */ - private function readLong($stream, $isBigEndian) + private function readLong($stream, bool $isBigEndian): int { $result = unpack($isBigEndian ? 'N1' : 'V1', fread($stream, 4)); $result = current($result); diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 31ab0be3b1660..40d2f660cea70 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -75,7 +75,7 @@ private function extract($resource, MessageCatalogue $catalogue, $domain) * @param MessageCatalogue $catalogue Catalogue where we'll collect messages and metadata * @param string $domain The domain */ - private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, $domain) + private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, string $domain) { $xml = simplexml_import_dom($dom); $encoding = strtoupper($dom->encoding); @@ -115,12 +115,7 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, $ } } - /** - * @param \DOMDocument $dom - * @param MessageCatalogue $catalogue - * @param string $domain - */ - private function extractXliff2(\DOMDocument $dom, MessageCatalogue $catalogue, $domain) + private function extractXliff2(\DOMDocument $dom, MessageCatalogue $catalogue, string $domain) { $xml = simplexml_import_dom($dom); $encoding = strtoupper($dom->encoding); @@ -163,13 +158,8 @@ private function extractXliff2(\DOMDocument $dom, MessageCatalogue $catalogue, $ /** * Convert a UTF8 string to the specified encoding. - * - * @param string $content String to decode - * @param string $encoding Target encoding - * - * @return string */ - private function utf8ToCharset($content, $encoding = null) + private function utf8ToCharset(string $content, string $encoding = null): string { if ('UTF-8' !== $encoding && !empty($encoding)) { return mb_convert_encoding($content, $encoding, 'UTF-8'); @@ -181,13 +171,9 @@ private function utf8ToCharset($content, $encoding = null) /** * Validates and parses the given file into a DOMDocument. * - * @param string $file - * @param \DOMDocument $dom - * @param string $schema source of the schema - * * @throws InvalidResourceException */ - private function validateSchema($file, \DOMDocument $dom, $schema) + private function validateSchema(string $file, \DOMDocument $dom, string $schema) { $internalErrors = libxml_use_internal_errors(true); @@ -224,13 +210,8 @@ private function getSchema($xliffVersion) /** * Internally changes the URI of a dependent xsd to be loaded locally. - * - * @param string $schemaSource Current content of schema file - * @param string $xmlUri External URI of XML to convert to local - * - * @return string */ - private function fixXmlLocation($schemaSource, $xmlUri) + private function fixXmlLocation(string $schemaSource, string $xmlUri): string { $newPath = str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd'; $parts = explode('/', $newPath); @@ -250,12 +231,8 @@ private function fixXmlLocation($schemaSource, $xmlUri) /** * Returns the XML errors of the internal XML parser. - * - * @param bool $internalErrors - * - * @return array An array of errors */ - private function getXmlErrors($internalErrors) + private function getXmlErrors(bool $internalErrors): array { $errors = array(); foreach (libxml_get_errors() as $error) { @@ -279,13 +256,9 @@ private function getXmlErrors($internalErrors) * Gets xliff file version based on the root "version" attribute. * Defaults to 1.2 for backwards compatibility. * - * @param \DOMDocument $dom - * * @throws InvalidArgumentException - * - * @return string */ - private function getVersionNumber(\DOMDocument $dom) + private function getVersionNumber(\DOMDocument $dom): string { /** @var \DOMNode $xliff */ foreach ($dom->getElementsByTagName('xliff') as $xliff) { @@ -308,13 +281,7 @@ private function getVersionNumber(\DOMDocument $dom) return '1.2'; } - /** - * @param \SimpleXMLElement|null $noteElement - * @param string|null $encoding - * - * @return array - */ - private function parseNotesMetadata(\SimpleXMLElement $noteElement = null, $encoding = null) + private function parseNotesMetadata(\SimpleXMLElement $noteElement = null, string $encoding = null): array { $notes = array(); diff --git a/src/Symfony/Component/Translation/MessageCatalogue.php b/src/Symfony/Component/Translation/MessageCatalogue.php index df917bbba9e34..c36ea30ec04fd 100644 --- a/src/Symfony/Component/Translation/MessageCatalogue.php +++ b/src/Symfony/Component/Translation/MessageCatalogue.php @@ -30,7 +30,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf * @param string $locale The locale * @param array $messages An array of messages classified by domain */ - public function __construct($locale, array $messages = array()) + public function __construct(?string $locale, array $messages = array()) { $this->locale = $locale; $this->messages = $messages; diff --git a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php index f79c72b1c2152..c7a7668f87dcf 100644 --- a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php +++ b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php @@ -27,7 +27,7 @@ public function testWrite() $writer = new TranslationWriter(); $writer->addDumper('test', $dumper); - $writer->write(new MessageCatalogue(array()), 'test'); + $writer->write(new MessageCatalogue('en'), 'test'); } public function testDisableBackup() diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 745d6a790a346..2899db0101e1d 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -74,14 +74,9 @@ class Translator implements TranslatorInterface, TranslatorBagInterface private $configCacheFactory; /** - * @param string $locale The locale - * @param MessageFormatterInterface|null $formatter The message formatter - * @param string|null $cacheDir The directory to use for the cache - * @param bool $debug Use cache in debug mode ? - * * @throws InvalidArgumentException If a locale contains invalid characters */ - public function __construct($locale, MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false) + public function __construct(?string $locale, MessageFormatterInterface $formatter = null, string $cacheDir = null, bool $debug = false) { $this->setLocale($locale); @@ -430,8 +425,6 @@ protected function assertValidLocale($locale) /** * Provides the ConfigCache factory implementation, falling back to a * default implementation if necessary. - * - * @return ConfigCacheFactoryInterface $configCacheFactory */ private function getConfigCacheFactory(): ConfigCacheFactoryInterface { diff --git a/src/Symfony/Component/Validator/ConstraintViolation.php b/src/Symfony/Component/Validator/ConstraintViolation.php index 97c1f1c1aac60..b3462e7d1c6b6 100644 --- a/src/Symfony/Component/Validator/ConstraintViolation.php +++ b/src/Symfony/Component/Validator/ConstraintViolation.php @@ -49,7 +49,7 @@ class ConstraintViolation implements ConstraintViolationInterface * caused the violation * @param mixed $cause The cause of the violation */ - public function __construct($message, $messageTemplate, array $parameters, $root, $propertyPath, $invalidValue, $plural = null, $code = null, Constraint $constraint = null, $cause = null) + public function __construct(?string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null) { $this->message = $message; $this->messageTemplate = $messageTemplate; diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index b9537cab04843..04e8e71c312a0 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -25,10 +25,7 @@ class EmailValidator extends ConstraintValidator { private $isStrict; - /** - * @param bool $strict - */ - public function __construct($strict = false) + public function __construct(bool $strict = false) { $this->isStrict = $strict; } @@ -111,24 +108,16 @@ public function validate($value, Constraint $constraint) /** * Check DNS Records for MX type. - * - * @param string $host Host - * - * @return bool */ - private function checkMX($host) + private function checkMX(string $host): bool { return '' !== $host && checkdnsrr($host, 'MX'); } /** * Check if one of MX, A or AAAA DNS RR exists. - * - * @param string $host Host - * - * @return bool */ - private function checkHost($host) + private function checkHost(string $host): bool { return '' !== $host && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'))); } diff --git a/src/Symfony/Component/Validator/Constraints/File.php b/src/Symfony/Component/Validator/Constraints/File.php index 5cc3a7313f7a5..ff2627b38e809 100644 --- a/src/Symfony/Component/Validator/Constraints/File.php +++ b/src/Symfony/Component/Validator/Constraints/File.php @@ -59,6 +59,9 @@ class File extends Constraint protected $maxSize; + /** + * {@inheritdoc} + */ public function __construct($options = null) { parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Context/ExecutionContext.php b/src/Symfony/Component/Validator/Context/ExecutionContext.php index 9c50a4f0f685b..1c1aa7216cb60 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContext.php @@ -140,7 +140,7 @@ class ExecutionContext implements ExecutionContextInterface * @internal Called by {@link ExecutionContextFactory}. Should not be used * in user code. */ - public function __construct(ValidatorInterface $validator, $root, TranslatorInterface $translator, $translationDomain = null) + public function __construct(ValidatorInterface $validator, $root, TranslatorInterface $translator, string $translationDomain = null) { $this->validator = $validator; $this->root = $root; diff --git a/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php b/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php index 84c5a9c8cb8b8..a8369a4955403 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContextFactory.php @@ -34,7 +34,7 @@ class ExecutionContextFactory implements ExecutionContextFactoryInterface * use for translating * violation messages */ - public function __construct(TranslatorInterface $translator, $translationDomain = null) + public function __construct(TranslatorInterface $translator, string $translationDomain = null) { $this->translator = $translator; $this->translationDomain = $translationDomain; diff --git a/src/Symfony/Component/Validator/DependencyInjection/AddConstraintValidatorsPass.php b/src/Symfony/Component/Validator/DependencyInjection/AddConstraintValidatorsPass.php index 207a1ad49d487..f10385c8c8f8e 100644 --- a/src/Symfony/Component/Validator/DependencyInjection/AddConstraintValidatorsPass.php +++ b/src/Symfony/Component/Validator/DependencyInjection/AddConstraintValidatorsPass.php @@ -25,7 +25,7 @@ class AddConstraintValidatorsPass implements CompilerPassInterface private $validatorFactoryServiceId; private $constraintValidatorTag; - public function __construct($validatorFactoryServiceId = 'validator.validator_factory', $constraintValidatorTag = 'validator.constraint_validator') + public function __construct(string $validatorFactoryServiceId = 'validator.validator_factory', string $constraintValidatorTag = 'validator.constraint_validator') { $this->validatorFactoryServiceId = $validatorFactoryServiceId; $this->constraintValidatorTag = $constraintValidatorTag; diff --git a/src/Symfony/Component/Validator/DependencyInjection/AddValidatorInitializersPass.php b/src/Symfony/Component/Validator/DependencyInjection/AddValidatorInitializersPass.php index 52be28534bae2..aa7dc0c74ba9a 100644 --- a/src/Symfony/Component/Validator/DependencyInjection/AddValidatorInitializersPass.php +++ b/src/Symfony/Component/Validator/DependencyInjection/AddValidatorInitializersPass.php @@ -24,7 +24,7 @@ class AddValidatorInitializersPass implements CompilerPassInterface private $builderService; private $initializerTag; - public function __construct($builderService = 'validator.builder', $initializerTag = 'validator.initializer') + public function __construct(string $builderService = 'validator.builder', string $initializerTag = 'validator.initializer') { $this->builderService = $builderService; $this->initializerTag = $initializerTag; diff --git a/src/Symfony/Component/Validator/Exception/InvalidOptionsException.php b/src/Symfony/Component/Validator/Exception/InvalidOptionsException.php index ce87c42ef4988..79d064f5377ab 100644 --- a/src/Symfony/Component/Validator/Exception/InvalidOptionsException.php +++ b/src/Symfony/Component/Validator/Exception/InvalidOptionsException.php @@ -15,7 +15,7 @@ class InvalidOptionsException extends ValidatorException { private $options; - public function __construct($message, array $options) + public function __construct(string $message, array $options) { parent::__construct($message); diff --git a/src/Symfony/Component/Validator/Exception/MissingOptionsException.php b/src/Symfony/Component/Validator/Exception/MissingOptionsException.php index 07c5d9ecda23e..61de56755defc 100644 --- a/src/Symfony/Component/Validator/Exception/MissingOptionsException.php +++ b/src/Symfony/Component/Validator/Exception/MissingOptionsException.php @@ -15,7 +15,7 @@ class MissingOptionsException extends ValidatorException { private $options; - public function __construct($message, array $options) + public function __construct(string $message, array $options) { parent::__construct($message); diff --git a/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php index 49d8cc2082234..3240aab6034c3 100644 --- a/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/Validator/Exception/UnexpectedTypeException.php @@ -13,7 +13,7 @@ class UnexpectedTypeException extends ValidatorException { - public function __construct($value, $expectedType) + public function __construct($value, string $expectedType) { parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); } diff --git a/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php b/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php index 73c9513c168af..c0266e65a5a0b 100644 --- a/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php +++ b/src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php @@ -63,12 +63,8 @@ public function write(ClassMetadata $metadata) /** * Replaces backslashes by dots in a class name. - * - * @param string $class - * - * @return string */ - private function escapeClassName($class) + private function escapeClassName(string $class): string { return str_replace('\\', '.', $class); } diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 39fb926ef684c..caba1fcb20ae3 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -109,12 +109,7 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface */ private $reflClass; - /** - * Constructs a metadata for the given class. - * - * @param string $class - */ - public function __construct($class) + public function __construct(string $class) { $this->name = $class; // class name without namespace diff --git a/src/Symfony/Component/Validator/Mapping/GetterMetadata.php b/src/Symfony/Component/Validator/Mapping/GetterMetadata.php index 5a72bd84b7442..bfa3bce4d5ba7 100644 --- a/src/Symfony/Component/Validator/Mapping/GetterMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GetterMetadata.php @@ -39,7 +39,7 @@ class GetterMetadata extends MemberMetadata * * @throws ValidatorException */ - public function __construct($class, $property, $method = null) + public function __construct(string $class, string $property, string $method = null) { if (null === $method) { $getMethod = 'get'.ucfirst($property); diff --git a/src/Symfony/Component/Validator/Mapping/Loader/FileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/FileLoader.php index b8f9490379aee..3aff5c92b31cb 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/FileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/FileLoader.php @@ -32,7 +32,7 @@ abstract class FileLoader extends AbstractLoader * * @throws MappingException If the file does not exist or is not readable */ - public function __construct($file) + public function __construct(string $file) { if (!is_file($file)) { throw new MappingException(sprintf('The mapping file "%s" does not exist', $file)); diff --git a/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php index 95fc578eb4b5c..01b176cc3d489 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php @@ -28,7 +28,7 @@ class StaticMethodLoader implements LoaderInterface * * @param string $methodName The name of the static method to call */ - public function __construct($methodName = 'loadValidatorMetadata') + public function __construct(string $methodName = 'loadValidatorMetadata') { $this->methodName = $methodName; } diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index d71a13be71f03..6d303e1ee8cba 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -59,7 +59,7 @@ abstract class MemberMetadata extends GenericMetadata implements PropertyMetadat * @param string $name The name of the member * @param string $property The property the member belongs to */ - public function __construct($class, $name, $property) + public function __construct(string $class, string $name, string $property) { $this->class = $class; $this->name = $name; diff --git a/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php b/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php index 7fc19dd2f7020..f15ca30884d74 100644 --- a/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/PropertyMetadata.php @@ -34,7 +34,7 @@ class PropertyMetadata extends MemberMetadata * * @throws ValidatorException */ - public function __construct($class, $name) + public function __construct(string $class, string $name) { if (!property_exists($class, $name)) { throw new ValidatorException(sprintf('Property "%s" does not exist in class "%s"', $name, $class)); diff --git a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php index 270e18961f746..0c53a7bfb7e19 100644 --- a/src/Symfony/Component/VarDumper/Caster/ArgsStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ArgsStub.php @@ -22,7 +22,7 @@ class ArgsStub extends EnumStub { private static $parameters = array(); - public function __construct(array $args, $function, $class) + public function __construct(array $args, string $function, ?string $class) { list($variadic, $params) = self::getParameters($function, $class); diff --git a/src/Symfony/Component/VarDumper/Caster/ClassStub.php b/src/Symfony/Component/VarDumper/Caster/ClassStub.php index 2e1f41c157921..9eebae082962a 100644 --- a/src/Symfony/Component/VarDumper/Caster/ClassStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ClassStub.php @@ -22,7 +22,7 @@ class ClassStub extends ConstStub * @param string A PHP identifier, e.g. a class, method, interface, etc. name * @param callable The callable targeted by the identifier when it is ambiguous or not a real PHP identifier */ - public function __construct($identifier, $callable = null) + public function __construct(string $identifier, $callable = null) { $this->value = $identifier; diff --git a/src/Symfony/Component/VarDumper/Caster/ConstStub.php b/src/Symfony/Component/VarDumper/Caster/ConstStub.php index 26c0010b66a8c..250a250a9f7c4 100644 --- a/src/Symfony/Component/VarDumper/Caster/ConstStub.php +++ b/src/Symfony/Component/VarDumper/Caster/ConstStub.php @@ -20,7 +20,7 @@ */ class ConstStub extends Stub { - public function __construct($name, $value) + public function __construct(string $name, $value) { $this->class = $name; $this->value = $value; diff --git a/src/Symfony/Component/VarDumper/Caster/EnumStub.php b/src/Symfony/Component/VarDumper/Caster/EnumStub.php index 3cee23eac202b..7a4e98a21b4d1 100644 --- a/src/Symfony/Component/VarDumper/Caster/EnumStub.php +++ b/src/Symfony/Component/VarDumper/Caster/EnumStub.php @@ -22,7 +22,7 @@ class EnumStub extends Stub { public $dumpKeys = true; - public function __construct(array $values, $dumpKeys = true) + public function __construct(array $values, bool $dumpKeys = true) { $this->value = $values; $this->dumpKeys = $dumpKeys; diff --git a/src/Symfony/Component/VarDumper/Caster/FrameStub.php b/src/Symfony/Component/VarDumper/Caster/FrameStub.php index 1e1194dc85b89..878675528f7e7 100644 --- a/src/Symfony/Component/VarDumper/Caster/FrameStub.php +++ b/src/Symfony/Component/VarDumper/Caster/FrameStub.php @@ -21,7 +21,7 @@ class FrameStub extends EnumStub public $keepArgs; public $inTraceStub; - public function __construct(array $frame, $keepArgs = true, $inTraceStub = false) + public function __construct(array $frame, bool $keepArgs = true, bool $inTraceStub = false) { $this->value = $frame; $this->keepArgs = $keepArgs; diff --git a/src/Symfony/Component/VarDumper/Caster/LinkStub.php b/src/Symfony/Component/VarDumper/Caster/LinkStub.php index 24f360b8f5553..d709e262de2f6 100644 --- a/src/Symfony/Component/VarDumper/Caster/LinkStub.php +++ b/src/Symfony/Component/VarDumper/Caster/LinkStub.php @@ -23,7 +23,7 @@ class LinkStub extends ConstStub private static $vendorRoots; private static $composerRoots; - public function __construct($label, $line = 0, $href = null) + public function __construct($label, int $line = 0, $href = null) { $this->value = $label; diff --git a/src/Symfony/Component/VarDumper/Caster/TraceStub.php b/src/Symfony/Component/VarDumper/Caster/TraceStub.php index 59548acaee61c..5eea1c876680f 100644 --- a/src/Symfony/Component/VarDumper/Caster/TraceStub.php +++ b/src/Symfony/Component/VarDumper/Caster/TraceStub.php @@ -25,7 +25,7 @@ class TraceStub extends Stub public $sliceLength; public $numberingOffset; - public function __construct(array $trace, $keepArgs = true, $sliceOffset = 0, $sliceLength = null, $numberingOffset = 0) + public function __construct(array $trace, bool $keepArgs = true, int $sliceOffset = 0, int $sliceLength = null, int $numberingOffset = 0) { $this->value = $trace; $this->keepArgs = $keepArgs; diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index 0fbd213abe987..734e07a8fc111 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -42,9 +42,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface * @param string $charset The default character encoding to use for non-UTF8 strings * @param int $flags A bit field of static::DUMP_* constants to fine tune dumps representation */ - public function __construct($output = null, $charset = null, $flags = 0) + public function __construct($output = null, string $charset = null, int $flags = 0) { - $this->flags = (int) $flags; + $this->flags = $flags; $this->setCharset($charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8'); $this->decimalPoint = localeconv(); $this->decimalPoint = $this->decimalPoint['decimal_point']; diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 5bf89112e6f1e..1ec4998553164 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -58,7 +58,7 @@ class CliDumper extends AbstractDumper /** * {@inheritdoc} */ - public function __construct($output = null, $charset = null, $flags = 0) + public function __construct($output = null, string $charset = null, int $flags = 0) { parent::__construct($output, $charset, $flags); diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index a4335d8a04973..14733297369be 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -56,7 +56,7 @@ class HtmlDumper extends CliDumper /** * {@inheritdoc} */ - public function __construct($output = null, $charset = null, $flags = 0) + public function __construct($output = null, string $charset = null, int $flags = 0) { AbstractDumper::__construct($output, $charset, $flags); $this->dumpId = 'sf-dump-'.mt_rand(); diff --git a/src/Symfony/Component/Workflow/DependencyInjection/ValidateWorkflowsPass.php b/src/Symfony/Component/Workflow/DependencyInjection/ValidateWorkflowsPass.php index 7100095735de3..b4e222d335fcd 100644 --- a/src/Symfony/Component/Workflow/DependencyInjection/ValidateWorkflowsPass.php +++ b/src/Symfony/Component/Workflow/DependencyInjection/ValidateWorkflowsPass.php @@ -24,7 +24,7 @@ class ValidateWorkflowsPass implements CompilerPassInterface { private $definitionTag; - public function __construct($definitionTag = 'workflow.definition') + public function __construct(string $definitionTag = 'workflow.definition') { $this->definitionTag = $definitionTag; } diff --git a/src/Symfony/Component/Workflow/Event/Event.php b/src/Symfony/Component/Workflow/Event/Event.php index a268a373c08c3..19c78d47082d3 100644 --- a/src/Symfony/Component/Workflow/Event/Event.php +++ b/src/Symfony/Component/Workflow/Event/Event.php @@ -32,7 +32,7 @@ class Event extends BaseEvent * @param Transition $transition * @param string $workflowName */ - public function __construct($subject, Marking $marking, Transition $transition, $workflowName = 'unnamed') + public function __construct($subject, Marking $marking, Transition $transition, string $workflowName = 'unnamed') { $this->subject = $subject; $this->marking = $marking; diff --git a/src/Symfony/Component/Workflow/EventListener/GuardListener.php b/src/Symfony/Component/Workflow/EventListener/GuardListener.php index b3e1688f8f686..a4114e68e1854 100644 --- a/src/Symfony/Component/Workflow/EventListener/GuardListener.php +++ b/src/Symfony/Component/Workflow/EventListener/GuardListener.php @@ -32,7 +32,7 @@ class GuardListener private $roleHierarchy; private $validator; - public function __construct($configuration, ExpressionLanguage $expressionLanguage, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authenticationChecker, AuthenticationTrustResolverInterface $trustResolver, RoleHierarchyInterface $roleHierarchy = null, ValidatorInterface $validator = null) + public function __construct(array $configuration, ExpressionLanguage $expressionLanguage, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authenticationChecker, AuthenticationTrustResolverInterface $trustResolver, RoleHierarchyInterface $roleHierarchy = null, ValidatorInterface $validator = null) { $this->configuration = $configuration; $this->expressionLanguage = $expressionLanguage; diff --git a/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php index 6d2d0884893dc..cc3acb48c2f13 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php @@ -29,11 +29,7 @@ class MultipleStateMarkingStore implements MarkingStoreInterface private $property; private $propertyAccessor; - /** - * @param string $property - * @param PropertyAccessorInterface|null $propertyAccessor - */ - public function __construct($property = 'marking', PropertyAccessorInterface $propertyAccessor = null) + public function __construct(string $property = 'marking', PropertyAccessorInterface $propertyAccessor = null) { $this->property = $property; $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); diff --git a/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php b/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php index d6afc6aeeb764..1da179db64b37 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php +++ b/src/Symfony/Component/Workflow/MarkingStore/SingleStateMarkingStore.php @@ -28,11 +28,7 @@ class SingleStateMarkingStore implements MarkingStoreInterface private $property; private $propertyAccessor; - /** - * @param string $property - * @param PropertyAccessorInterface|null $propertyAccessor - */ - public function __construct($property = 'marking', PropertyAccessorInterface $propertyAccessor = null) + public function __construct(string $property = 'marking', PropertyAccessorInterface $propertyAccessor = null) { $this->property = $property; $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); diff --git a/src/Symfony/Component/Workflow/StateMachine.php b/src/Symfony/Component/Workflow/StateMachine.php index 00cfdac7d493a..6adf1f4dcbddb 100644 --- a/src/Symfony/Component/Workflow/StateMachine.php +++ b/src/Symfony/Component/Workflow/StateMachine.php @@ -11,7 +11,7 @@ */ class StateMachine extends Workflow { - public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed') + public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, string $name = 'unnamed') { parent::__construct($definition, $markingStore ?: new SingleStateMarkingStore(), $dispatcher, $name); } diff --git a/src/Symfony/Component/Workflow/Transition.php b/src/Symfony/Component/Workflow/Transition.php index fb4786c88a267..b9f52d8e10910 100644 --- a/src/Symfony/Component/Workflow/Transition.php +++ b/src/Symfony/Component/Workflow/Transition.php @@ -28,7 +28,7 @@ class Transition * @param string|string[] $froms * @param string|string[] $tos */ - public function __construct($name, $froms, $tos) + public function __construct(string $name, $froms, $tos) { if (!preg_match('{^[\w\d_-]+$}', $name)) { throw new InvalidArgumentException(sprintf('The transition "%s" contains invalid characters.', $name)); diff --git a/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php b/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php index 27bd06f0d651b..e105224d221dd 100644 --- a/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php +++ b/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php @@ -21,10 +21,7 @@ class WorkflowValidator implements DefinitionValidatorInterface { private $singlePlace; - /** - * @param bool $singlePlace - */ - public function __construct($singlePlace = false) + public function __construct(bool $singlePlace = false) { $this->singlePlace = $singlePlace; } diff --git a/src/Symfony/Component/Workflow/Workflow.php b/src/Symfony/Component/Workflow/Workflow.php index d3d18f03746a7..96e3b2f1d637d 100644 --- a/src/Symfony/Component/Workflow/Workflow.php +++ b/src/Symfony/Component/Workflow/Workflow.php @@ -30,7 +30,7 @@ class Workflow private $dispatcher; private $name; - public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, $name = 'unnamed') + public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, string $name = 'unnamed') { $this->definition = $definition; $this->markingStore = $markingStore ?: new MultipleStateMarkingStore(); diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index cc250665fb0ad..80a9bd03afa83 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -36,7 +36,7 @@ class LintCommand extends Command private $directoryIteratorProvider; private $isReadableProvider; - public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null) + public function __construct(string $name = null, callable $directoryIteratorProvider = null, callable $isReadableProvider = null) { parent::__construct($name); diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 3eea19a3df770..fe9f1d87e2ca7 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -257,13 +257,6 @@ private static function dumpArray(array $value, int $flags): string /** * Parses a YAML scalar. * - * @param string $scalar - * @param int $flags - * @param string[] $delimiters - * @param int &$i - * @param bool $evaluate - * @param array $references - * * @return mixed * * @throws ParseException When malformed inline YAML string is parsed @@ -313,11 +306,6 @@ public static function parseScalar(string $scalar, int $flags = 0, array $delimi /** * Parses a YAML quoted scalar. * - * @param string $scalar - * @param int &$i - * - * @return string - * * @throws ParseException When malformed inline YAML string is parsed */ private static function parseQuotedScalar(string $scalar, int &$i): string @@ -343,13 +331,6 @@ private static function parseQuotedScalar(string $scalar, int &$i): string /** * Parses a YAML sequence. * - * @param string $sequence - * @param int $flags - * @param int &$i - * @param array $references - * - * @return array - * * @throws ParseException When malformed inline YAML string is parsed */ private static function parseSequence(string $sequence, int $flags, int &$i = 0, array $references = array()): array @@ -412,11 +393,6 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0, /** * Parses a YAML mapping. * - * @param string $mapping - * @param int $flags - * @param int &$i - * @param array $references - * * @return array|\stdClass * * @throws ParseException When malformed inline YAML string is parsed @@ -525,10 +501,6 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a /** * Evaluates scalars and replaces magic values. * - * @param string $scalar - * @param int $flags - * @param array $references - * * @return mixed The evaluated YAML string * * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved @@ -651,13 +623,6 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere return (string) $scalar; } - /** - * @param string $value - * @param int &$i - * @param int $flags - * - * @return null|string - */ private static function parseTag(string $value, int &$i, int $flags): ?string { if ('!' !== $value[$i]) { @@ -690,11 +655,6 @@ private static function parseTag(string $value, int &$i, int $flags): ?string throw new ParseException(sprintf('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename); } - /** - * @param string $scalar - * - * @return string - */ public static function evaluateBinaryScalar(string $scalar): string { $parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar)); diff --git a/src/Symfony/Component/Yaml/Unescaper.php b/src/Symfony/Component/Yaml/Unescaper.php index c9285acb49695..78b8bacada9c2 100644 --- a/src/Symfony/Component/Yaml/Unescaper.php +++ b/src/Symfony/Component/Yaml/Unescaper.php @@ -120,10 +120,6 @@ private function unescapeCharacter(string $value): string /** * Get the UTF-8 character for the given code point. - * - * @param int $c The unicode code point - * - * @return string The corresponding UTF-8 character */ private static function utf8chr(int $c): string {