From e1afcb6de1444a320f0190a4b1184ea8bb729f29 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 2 Jul 2021 16:28:33 +0200 Subject: [PATCH] Backport type fixes --- .../Controller/ControllerResolver.php | 5 +- .../DataCollector/RouterDataCollector.php | 2 - .../AnnotatedRouteControllerLoader.php | 2 +- .../Translation/Translator.php | 2 - .../Resource/ClassExistenceResource.php | 3 - .../Config/Resource/ComposerResource.php | 3 - .../Config/Resource/DirectoryResource.php | 3 - .../Config/Resource/FileExistenceResource.php | 3 - .../Config/Resource/FileResource.php | 3 - .../Config/Resource/GlobResource.php | 3 - .../Config/Resource/ResourceInterface.php | 2 - .../Definition/Builder/ExprBuilderTest.php | 4 +- .../Component/Console/Command/Command.php | 18 +++--- .../Component/Console/Helper/Table.php | 8 +-- .../Component/Console/Input/InputArgument.php | 12 ++-- .../Console/Input/InputInterface.php | 12 ++-- .../Component/Console/Input/InputOption.php | 14 ++--- .../Component/Console/Output/Output.php | 2 +- .../CssSelector/Node/AttributeNode.php | 3 - .../Component/CssSelector/Node/ClassNode.php | 3 - .../CssSelector/Node/CombinedSelectorNode.php | 3 - .../CssSelector/Node/ElementNode.php | 3 - .../CssSelector/Node/FunctionNode.php | 3 - .../Component/CssSelector/Node/HashNode.php | 3 - .../CssSelector/Node/NegationNode.php | 3 - .../Component/CssSelector/Node/PseudoNode.php | 3 - .../CssSelector/Node/SelectorNode.php | 3 - .../Compiler/AutowirePass.php | 2 +- .../Config/ContainerParametersResource.php | 3 - .../DependencyInjection/Container.php | 2 +- .../DependencyInjection/ContainerBuilder.php | 2 - .../ContainerInterface.php | 4 +- .../DependencyInjection/Definition.php | 2 +- .../Configurator/ServiceConfigurator.php | 2 +- .../Loader/YamlFileLoader.php | 6 -- .../ParameterBag/ContainerBag.php | 4 ++ .../ParameterBag/ParameterBag.php | 18 ++---- .../ParameterBag/ParameterBagInterface.php | 2 - .../ResolveChildDefinitionsPassTest.php | 6 +- .../Component/ErrorHandler/ErrorHandler.php | 2 +- .../Exception/FlattenException.php | 6 ++ .../Tests/EventDispatcherTest.php | 4 ++ .../Component/Filesystem/Filesystem.php | 2 +- .../Tests/Fixtures/MockStream/MockStream.php | 2 +- .../Finder/Iterator/SortableIterator.php | 3 +- .../Tests/Iterator/SortableIteratorTest.php | 2 +- .../HttpClient/Response/CurlResponse.php | 2 +- .../HttpFoundation/File/UploadedFile.php | 2 +- .../Component/HttpFoundation/FileBag.php | 26 ++++----- .../Component/HttpFoundation/HeaderBag.php | 14 ++--- .../HttpFoundation/Tests/JsonResponseTest.php | 2 +- .../AbstractRedisSessionHandlerTestCase.php | 2 +- .../ArgumentMetadataFactoryInterface.php | 2 +- .../DataCollector/LoggerDataCollector.php | 2 - .../DataCollector/RequestDataCollector.php | 2 +- .../HttpKernel/Debug/FileLinkFormatter.php | 2 +- .../Component/Intl/Resources/bin/common.php | 14 ++--- .../Transport/Serialization/PhpSerializer.php | 2 +- src/Symfony/Component/Mime/Header/Headers.php | 4 +- .../Mime/MimeTypeGuesserInterface.php | 2 - src/Symfony/Component/Mime/Part/DataPart.php | 6 +- .../OptionsResolver/OptionsResolver.php | 13 +---- .../Component/Process/Pipes/AbstractPipes.php | 2 +- .../Routing/Loader/AnnotationFileLoader.php | 3 - .../Routing/Loader/ContainerLoader.php | 2 +- .../Matcher/Dumper/StaticPrefixCollection.php | 2 +- src/Symfony/Component/Routing/Route.php | 56 ------------------- .../Constraints/UserPasswordValidator.php | 4 ++ .../Http/Firewall/ContextListener.php | 2 +- .../Serializer/Annotation/Groups.php | 4 +- .../ConstraintViolationListNormalizer.php | 2 +- .../Extractor/ExtractorInterface.php | 2 +- .../Translation/MessageCatalogue.php | 3 +- .../Component/Translation/Translator.php | 2 - .../Validator/Constraints/RangeValidator.php | 2 +- .../Test/ConstraintValidatorTestCase.php | 2 - .../Component/VarDumper/Caster/LinkStub.php | 2 +- .../VarDumper/Caster/ResourceCaster.php | 2 +- .../Component/VarDumper/Caster/SplCaster.php | 2 +- .../Component/VarDumper/Dumper/HtmlDumper.php | 2 +- .../Component/VarDumper/Server/Connection.php | 2 +- 81 files changed, 126 insertions(+), 271 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php index 5cb655d942..3c746b996e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php @@ -67,11 +67,8 @@ class ControllerResolver extends ContainerControllerResolver */ protected function instantiateController($class) { - return $this->configureController(parent::instantiateController($class), $class); - } + $controller = parent::instantiateController($class); - private function configureController($controller, string $class) - { if ($controller instanceof ContainerAwareInterface) { $controller->setContainer($this->container); } diff --git a/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php b/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php index 58fcc68e8e..60681f7291 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php +++ b/src/Symfony/Bundle/FrameworkBundle/DataCollector/RouterDataCollector.php @@ -16,8 +16,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\DataCollector\RouterDataCollector as BaseRouterDataCollector; /** - * RouterDataCollector. - * * @author Fabien Potencier * * @final since Symfony 4.4 diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php index 51419c8914..6e5a71b8fa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/AnnotatedRouteControllerLoader.php @@ -25,7 +25,7 @@ class AnnotatedRouteControllerLoader extends AnnotationClassLoader /** * Configures the _controller default parameter of a given Route instance. * - * @param mixed $annot The annotation class instance + * @param object $annot The annotation class instance */ protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index e11e515aba..cd5444034b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -20,8 +20,6 @@ use Symfony\Component\Translation\Formatter\MessageFormatterInterface; use Symfony\Component\Translation\Translator as BaseTranslator; /** - * Translator. - * * @author Fabien Potencier */ class Translator extends BaseTranslator implements WarmableInterface diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index c77e343b5c..8179ce7fb4 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -42,9 +42,6 @@ class ClassExistenceResource implements SelfCheckingResourceInterface } } - /** - * {@inheritdoc} - */ public function __toString() { return $this->resource; diff --git a/src/Symfony/Component/Config/Resource/ComposerResource.php b/src/Symfony/Component/Config/Resource/ComposerResource.php index 822766b75b..eefce22a3f 100644 --- a/src/Symfony/Component/Config/Resource/ComposerResource.php +++ b/src/Symfony/Component/Config/Resource/ComposerResource.php @@ -35,9 +35,6 @@ class ComposerResource implements SelfCheckingResourceInterface return array_keys($this->vendors); } - /** - * {@inheritdoc} - */ public function __toString() { return __CLASS__; diff --git a/src/Symfony/Component/Config/Resource/DirectoryResource.php b/src/Symfony/Component/Config/Resource/DirectoryResource.php index 3d703db7f6..e6b0d318bd 100644 --- a/src/Symfony/Component/Config/Resource/DirectoryResource.php +++ b/src/Symfony/Component/Config/Resource/DirectoryResource.php @@ -39,9 +39,6 @@ class DirectoryResource implements SelfCheckingResourceInterface } } - /** - * {@inheritdoc} - */ public function __toString() { return md5(serialize([$this->resource, $this->pattern])); diff --git a/src/Symfony/Component/Config/Resource/FileExistenceResource.php b/src/Symfony/Component/Config/Resource/FileExistenceResource.php index 5723416158..760c061bf4 100644 --- a/src/Symfony/Component/Config/Resource/FileExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/FileExistenceResource.php @@ -36,9 +36,6 @@ class FileExistenceResource implements SelfCheckingResourceInterface $this->exists = file_exists($resource); } - /** - * {@inheritdoc} - */ public function __toString() { return $this->resource; diff --git a/src/Symfony/Component/Config/Resource/FileResource.php b/src/Symfony/Component/Config/Resource/FileResource.php index 95fe8a0bf8..96d7d97317 100644 --- a/src/Symfony/Component/Config/Resource/FileResource.php +++ b/src/Symfony/Component/Config/Resource/FileResource.php @@ -41,9 +41,6 @@ class FileResource implements SelfCheckingResourceInterface } } - /** - * {@inheritdoc} - */ public function __toString() { return $this->resource; diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index f825a92911..f65a019bef 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -60,9 +60,6 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface return $this->prefix; } - /** - * {@inheritdoc} - */ public function __toString() { return 'glob.'.$this->prefix.(int) $this->recursive.$this->pattern.(int) $this->forExclusion.implode("\0", $this->excludedPrefixes); diff --git a/src/Symfony/Component/Config/Resource/ResourceInterface.php b/src/Symfony/Component/Config/Resource/ResourceInterface.php index d98fd427a2..9a0cd9a47f 100644 --- a/src/Symfony/Component/Config/Resource/ResourceInterface.php +++ b/src/Symfony/Component/Config/Resource/ResourceInterface.php @@ -26,8 +26,6 @@ interface ResourceInterface * to be identical for different ResourceInterface instances referring to the same * resource; and it should be unlikely to collide with that of other, unrelated * resource instances. - * - * @return string A string representation unique to the underlying Resource */ public function __toString(); } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index bec4275404..e96c57c409 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -222,8 +222,6 @@ class ExprBuilderTest extends TestCase * * @param array|null $config The config you want to use for the finalization, if nothing provided * a simple ['key'=>'value'] will be used - * - * @return array The finalized config values */ protected function finalizeTestBuilder(NodeDefinition $nodeDefinition, array $config = null): array { @@ -254,7 +252,7 @@ class ExprBuilderTest extends TestCase * @param mixed $value The value to test * @param mixed $config The config values that new to be finalized */ - protected function assertFinalizedValueIs($value, NodeDefinition $nodeDefinition, $config = null) + protected function assertFinalizedValueIs($value, NodeDefinition $nodeDefinition, $config = null): void { $this->assertEquals(['key' => $value], $this->finalizeTestBuilder($nodeDefinition, $config)); } diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index d4ab2eb8df..722e9428d9 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -375,10 +375,10 @@ class Command /** * Adds an argument. * - * @param string $name The argument name - * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL - * @param string $description A description text - * @param string|string[]|null $default The default value (for InputArgument::OPTIONAL mode only) + * @param string $name The argument name + * @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL + * @param string $description A description text + * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) * * @throws InvalidArgumentException When argument mode is not valid * @@ -394,11 +394,11 @@ class Command /** * Adds an option. * - * @param string $name The option name - * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the InputOption::VALUE_* constants - * @param string $description A description text - * @param string|string[]|bool|null $default The default value (must be null for InputOption::VALUE_NONE) + * @param string $name The option name + * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int|null $mode The option mode: One of the InputOption::VALUE_* constants + * @param string $description A description text + * @param mixed $default The default value (must be null for InputOption::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible * diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index d51aee9890..8f9e972408 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -585,11 +585,11 @@ class Table return new TableRows(function () use ($rows, $unmergedRows): \Traversable { foreach ($rows as $rowKey => $row) { - yield $this->fillCells($row); + yield $row instanceof TableSeparator ? $row : $this->fillCells($row); if (isset($unmergedRows[$rowKey])) { - foreach ($unmergedRows[$rowKey] as $unmergedRow) { - yield $this->fillCells($unmergedRow); + foreach ($unmergedRows[$rowKey] as $row) { + yield $row instanceof TableSeparator ? $row : $this->fillCells($row); } } } @@ -670,7 +670,7 @@ class Table /** * fill cells for a row that contains colspan > 1. */ - private function fillCells($row) + private function fillCells(iterable $row) { $newRow = []; diff --git a/src/Symfony/Component/Console/Input/InputArgument.php b/src/Symfony/Component/Console/Input/InputArgument.php index 140c86d0e6..11de14fe68 100644 --- a/src/Symfony/Component/Console/Input/InputArgument.php +++ b/src/Symfony/Component/Console/Input/InputArgument.php @@ -31,10 +31,10 @@ class InputArgument private $description; /** - * @param string $name The argument name - * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL - * @param string $description A description text - * @param string|string[]|null $default The default value (for self::OPTIONAL mode only) + * @param string $name The argument name + * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL + * @param string $description A description text + * @param mixed $default The default value (for self::OPTIONAL mode only) * * @throws InvalidArgumentException When argument mode is not valid */ @@ -86,7 +86,7 @@ class InputArgument /** * Sets the default value. * - * @param string|string[]|null $default The default value + * @param mixed $default The default value * * @throws LogicException When incorrect default value is given */ @@ -110,7 +110,7 @@ class InputArgument /** * Returns the default value. * - * @return string|string[]|null The default value + * @return mixed */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index b9bcf3bbcd..4ecab0f4fb 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -85,7 +85,7 @@ interface InputInterface * * @param string $name The argument name * - * @return string|string[]|null The argument value + * @return mixed * * @throws InvalidArgumentException When argument given doesn't exist */ @@ -94,8 +94,8 @@ interface InputInterface /** * Sets an argument value by name. * - * @param string $name The argument name - * @param string|string[]|null $value The argument value + * @param string $name The argument name + * @param mixed $value The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ @@ -122,7 +122,7 @@ interface InputInterface * * @param string $name The option name * - * @return string|string[]|bool|null The option value + * @return mixed * * @throws InvalidArgumentException When option given doesn't exist */ @@ -131,8 +131,8 @@ interface InputInterface /** * Sets an option value by name. * - * @param string $name The option name - * @param string|string[]|bool|null $value The option value + * @param string $name The option name + * @param mixed $value The option value * * @throws InvalidArgumentException When option given doesn't exist */ diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 5e48f88b81..2bb86cd2b0 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -48,11 +48,11 @@ class InputOption private $description; /** - * @param string $name The option name - * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the VALUE_* constants - * @param string $description A description text - * @param string|string[]|bool|null $default The default value (must be null for self::VALUE_NONE) + * @param string $name The option name + * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int|null $mode The option mode: One of the VALUE_* constants + * @param string $description A description text + * @param mixed $default The default value (must be null for self::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible */ @@ -164,7 +164,7 @@ class InputOption /** * Sets the default value. * - * @param string|string[]|bool|null $default The default value + * @param mixed $default The default value * * @throws LogicException When incorrect default value is given */ @@ -188,7 +188,7 @@ class InputOption /** * Returns the default value. * - * @return string|string[]|bool|null The default value + * @return mixed */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Output/Output.php b/src/Symfony/Component/Console/Output/Output.php index 8572481330..fb838f0532 100644 --- a/src/Symfony/Component/Console/Output/Output.php +++ b/src/Symfony/Component/Console/Output/Output.php @@ -163,7 +163,7 @@ abstract class Output implements OutputInterface break; } - $this->doWrite($message, $newline); + $this->doWrite($message ?? '', $newline); } } diff --git a/src/Symfony/Component/CssSelector/Node/AttributeNode.php b/src/Symfony/Component/CssSelector/Node/AttributeNode.php index bf702d9ce4..0b6e0ee0a1 100644 --- a/src/Symfony/Component/CssSelector/Node/AttributeNode.php +++ b/src/Symfony/Component/CssSelector/Node/AttributeNode.php @@ -71,9 +71,6 @@ class AttributeNode extends AbstractNode return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; diff --git a/src/Symfony/Component/CssSelector/Node/ClassNode.php b/src/Symfony/Component/CssSelector/Node/ClassNode.php index 1998b4bd5b..1efca808dc 100644 --- a/src/Symfony/Component/CssSelector/Node/ClassNode.php +++ b/src/Symfony/Component/CssSelector/Node/ClassNode.php @@ -50,9 +50,6 @@ class ClassNode extends AbstractNode return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); diff --git a/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php b/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php index f97fd21aeb..a217a45edd 100644 --- a/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php +++ b/src/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php @@ -57,9 +57,6 @@ class CombinedSelectorNode extends AbstractNode return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); } - /** - * {@inheritdoc} - */ public function __toString(): string { $combinator = ' ' === $this->combinator ? '' : $this->combinator; diff --git a/src/Symfony/Component/CssSelector/Node/ElementNode.php b/src/Symfony/Component/CssSelector/Node/ElementNode.php index 7949ed9198..fbf8ea0f99 100644 --- a/src/Symfony/Component/CssSelector/Node/ElementNode.php +++ b/src/Symfony/Component/CssSelector/Node/ElementNode.php @@ -50,9 +50,6 @@ class ElementNode extends AbstractNode return new Specificity(0, 0, $this->element ? 1 : 0); } - /** - * {@inheritdoc} - */ public function __toString(): string { $element = $this->element ?: '*'; diff --git a/src/Symfony/Component/CssSelector/Node/FunctionNode.php b/src/Symfony/Component/CssSelector/Node/FunctionNode.php index d3e9b4fc7c..c464cf7c05 100644 --- a/src/Symfony/Component/CssSelector/Node/FunctionNode.php +++ b/src/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -65,9 +65,6 @@ class FunctionNode extends AbstractNode return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { $arguments = implode(', ', array_map(function (Token $token) { diff --git a/src/Symfony/Component/CssSelector/Node/HashNode.php b/src/Symfony/Component/CssSelector/Node/HashNode.php index f73fa2e740..94114c095e 100644 --- a/src/Symfony/Component/CssSelector/Node/HashNode.php +++ b/src/Symfony/Component/CssSelector/Node/HashNode.php @@ -50,9 +50,6 @@ class HashNode extends AbstractNode return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id); diff --git a/src/Symfony/Component/CssSelector/Node/NegationNode.php b/src/Symfony/Component/CssSelector/Node/NegationNode.php index afa47cf878..f00522fb96 100644 --- a/src/Symfony/Component/CssSelector/Node/NegationNode.php +++ b/src/Symfony/Component/CssSelector/Node/NegationNode.php @@ -50,9 +50,6 @@ class NegationNode extends AbstractNode return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector); diff --git a/src/Symfony/Component/CssSelector/Node/PseudoNode.php b/src/Symfony/Component/CssSelector/Node/PseudoNode.php index 7d4a011e1f..12b7bd2666 100644 --- a/src/Symfony/Component/CssSelector/Node/PseudoNode.php +++ b/src/Symfony/Component/CssSelector/Node/PseudoNode.php @@ -50,9 +50,6 @@ class PseudoNode extends AbstractNode return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier); diff --git a/src/Symfony/Component/CssSelector/Node/SelectorNode.php b/src/Symfony/Component/CssSelector/Node/SelectorNode.php index a76aa5bb5f..6e52b2fa72 100644 --- a/src/Symfony/Component/CssSelector/Node/SelectorNode.php +++ b/src/Symfony/Component/CssSelector/Node/SelectorNode.php @@ -50,9 +50,6 @@ class SelectorNode extends AbstractNode return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); } - /** - * {@inheritdoc} - */ public function __toString(): string { return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 0fbcbbf0d0..b222d5787e 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -374,7 +374,7 @@ class AutowirePass extends AbstractRecursivePass $this->ambiguousServiceTypes[$type][] = $id; } - private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): callable + private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): \Closure { if (null === $this->typesClone->container) { $this->typesClone->container = new ContainerBuilder($this->container->getParameterBag()); diff --git a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php index e9a4fffe2a..d2a74eb50f 100644 --- a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php +++ b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResource.php @@ -32,9 +32,6 @@ class ContainerParametersResource implements ResourceInterface $this->parameters = $parameters; } - /** - * {@inheritdoc} - */ public function __toString() { return 'container_parameters_'.md5(serialize($this->parameters)); diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 55183cb5e1..e17c1caa95 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -109,7 +109,7 @@ class Container implements ResettableContainerInterface * * @param string $name The parameter name * - * @return array|bool|float|int|string|null The parameter value + * @return mixed * * @throws InvalidArgumentException if the parameter is not defined */ diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 3cfe4e4cfe..ef3af7165d 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -883,8 +883,6 @@ class ContainerBuilder extends Container implements TaggedContainerInterface } /** - * Gets all defined aliases. - * * @return Alias[] An array of aliases */ public function getAliases() diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php index 92eeb1f13f..3123e2d13b 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -54,8 +54,6 @@ interface ContainerInterface extends PsrContainerInterface public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); /** - * Returns true if the given service is defined. - * * @param string $id The service identifier * * @return bool true if the service is defined, false otherwise @@ -76,7 +74,7 @@ interface ContainerInterface extends PsrContainerInterface * * @param string $name The parameter name * - * @return array|bool|float|int|string|null The parameter value + * @return mixed The parameter value * * @throws InvalidArgumentException if the parameter is not defined */ diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 4b3cf31938..727594dcb4 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -805,7 +805,7 @@ class Definition /** * Sets a configurator to call after the service is fully initialized. * - * @param string|array|Reference $configurator A PHP function, reference or an array containing a class/Reference and a method to call + * @param string|array|Reference|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call * * @return $this */ diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php index 71fa30c4e0..1dbc0a9a24 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ServiceConfigurator.php @@ -47,7 +47,7 @@ class ServiceConfigurator extends AbstractServiceConfigurator private $allowParent; private $path; - public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, $id, array $defaultTags, string $path = null) + public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, ?string $id, array $defaultTags, string $path = null) { $this->container = $container; $this->instanceof = $instanceof; diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 310aa351f2..20780ad6fa 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -850,9 +850,6 @@ class YamlFileLoader extends FileLoader return $value; } - /** - * Loads from Extensions. - */ private function loadFromExtensions(array $content) { foreach ($content as $namespace => $values) { @@ -868,9 +865,6 @@ class YamlFileLoader extends FileLoader } } - /** - * Checks the keywords used to define a service. - */ private function checkDefinition(string $id, array $definition, string $file) { if ($this->isLoadingInstanceof) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php index 7671dfc6ca..42855d2376 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php @@ -35,6 +35,8 @@ class ContainerBag extends FrozenParameterBag implements ContainerBagInterface /** * {@inheritdoc} + * + * @return mixed */ public function get($name) { @@ -43,6 +45,8 @@ class ContainerBag extends FrozenParameterBag implements ContainerBagInterface /** * {@inheritdoc} + * + * @return bool */ public function has($name) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index ae63e67ad9..a2de1a4f54 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -25,16 +25,13 @@ class ParameterBag implements ParameterBagInterface protected $parameters = []; protected $resolved = false; - /** - * @param array $parameters An array of parameters - */ public function __construct(array $parameters = []) { $this->add($parameters); } /** - * Clears all parameters. + * {@inheritdoc} */ public function clear() { @@ -42,9 +39,7 @@ class ParameterBag implements ParameterBagInterface } /** - * Adds parameters to the service container parameters. - * - * @param array $parameters An array of parameters + * {@inheritdoc} */ public function add(array $parameters) { @@ -104,10 +99,7 @@ class ParameterBag implements ParameterBagInterface } /** - * Sets a service container parameter. - * - * @param string $name The parameter name - * @param mixed $value The parameter value + * {@inheritdoc} */ public function set($name, $value) { @@ -123,9 +115,7 @@ class ParameterBag implements ParameterBagInterface } /** - * Removes a parameter. - * - * @param string $name The parameter name + * {@inheritdoc} */ public function remove($name) { diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php index 6a4e0fa4ac..75a7020660 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php @@ -31,8 +31,6 @@ interface ParameterBagInterface /** * Adds parameters to the service container parameters. * - * @param array $parameters An array of parameters - * * @throws LogicException if the parameter can not be added */ public function add(array $parameters); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php index 7dea34d75c..f14cbb0196 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php @@ -250,7 +250,7 @@ class ResolveChildDefinitionsPassTest extends TestCase $container->register('parent', 'parentClass'); $container->register('sibling', 'siblingClass') - ->setConfigurator(new ChildDefinition('parent'), 'foo') + ->setConfigurator([new ChildDefinition('parent'), 'foo']) ->setFactory([new ChildDefinition('parent'), 'foo']) ->addArgument(new ChildDefinition('parent')) ->setProperty('prop', new ChildDefinition('parent')) @@ -260,8 +260,8 @@ class ResolveChildDefinitionsPassTest extends TestCase $this->process($container); $configurator = $container->getDefinition('sibling')->getConfigurator(); - $this->assertSame('Symfony\Component\DependencyInjection\Definition', \get_class($configurator)); - $this->assertSame('parentClass', $configurator->getClass()); + $this->assertSame('Symfony\Component\DependencyInjection\Definition', \get_class($configurator[0])); + $this->assertSame('parentClass', $configurator[0]->getClass()); $factory = $container->getDefinition('sibling')->getFactory(); $this->assertSame('Symfony\Component\DependencyInjection\Definition', \get_class($factory[0])); diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index d357658ac1..e6e21d6017 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -196,7 +196,7 @@ class ErrorHandler * Sets a logger to non assigned errors levels. * * @param LoggerInterface $logger A PSR-3 logger to put as default for the given levels - * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants + * @param array|int|null $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants * @param bool $replace Whether to replace or not any existing logger */ public function setDefaultLogger(LoggerInterface $logger, $levels = \E_ALL, bool $replace = false): void diff --git a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php index 18e9b5ac1b..330b5cc3f4 100644 --- a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php +++ b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php @@ -62,11 +62,17 @@ class FlattenException extends LegacyFlattenException /** @var string|null */ private $asString; + /** + * @return static + */ public static function create(\Exception $exception, $statusCode = null, array $headers = []): self { return static::createFromThrowable($exception, $statusCode, $headers); } + /** + * @return static + */ public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self { $e = new static(); diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index 32f242e6f1..62097774cd 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -476,6 +476,10 @@ class TestEventListener $e->stopPropagation(); } } + + public function __invoke() + { + } } class TestWithDispatcher diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index da43d2fbd4..e80b895649 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -761,7 +761,7 @@ class Filesystem /** * @internal */ - public static function handleError($type, $msg) + public static function handleError(int $type, string $msg) { self::$lastError = $msg; } diff --git a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php index a1d410b198..3c66d8b9ac 100644 --- a/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php +++ b/src/Symfony/Component/Filesystem/Tests/Fixtures/MockStream/MockStream.php @@ -33,7 +33,7 @@ class MockStream /** * @param string $path The file path or URL to stat - * @param array $flags Holds additional flags set by the streams API + * @param int $flags Holds additional flags set by the streams API * * @return array File stats */ diff --git a/src/Symfony/Component/Finder/Iterator/SortableIterator.php b/src/Symfony/Component/Finder/Iterator/SortableIterator.php index dd9ae4ae41..8559ba51cd 100644 --- a/src/Symfony/Component/Finder/Iterator/SortableIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SortableIterator.php @@ -30,8 +30,7 @@ class SortableIterator implements \IteratorAggregate private $sort; /** - * @param \Traversable $iterator The Iterator to filter - * @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback) + * @param int|callable $sort The sort type (SORT_BY_NAME, SORT_BY_TYPE, or a PHP callback) * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index 12eacb8661..098cd75674 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -18,7 +18,7 @@ class SortableIteratorTest extends RealIteratorTestCase public function testConstructor() { try { - new SortableIterator(new Iterator([]), 'foobar'); + new SortableIterator(new Iterator([]), -255); $this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid'); } catch (\Exception $e) { $this->assertInstanceOf(\InvalidArgumentException::class, $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid'); diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 9709a189f5..cc5bf4f0b2 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -316,7 +316,7 @@ final class CurlResponse implements ResponseInterface /** * Parses header lines as curl yields them to us. */ - private static function parseHeaderLine($ch, string $data, array &$info, array &$headers, ?array $options, CurlClientState $multi, int $id, ?string &$location, ?callable $resolveRedirect, ?LoggerInterface $logger, &$content = null): int + private static function parseHeaderLine($ch, string $data, array &$info, array &$headers, ?array $options, CurlClientState $multi, int $id, ?string &$location, ?callable $resolveRedirect, ?LoggerInterface $logger): int { $waitFor = @curl_getinfo($ch, \CURLINFO_PRIVATE) ?: '_0'; diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 575d5087df..89764c3a0f 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -254,7 +254,7 @@ class UploadedFile extends File * * @return int|float Returns float if size > PHP_INT_MAX */ - private static function parseFilesize($size) + private static function parseFilesize(string $size) { if ('' === $size) { return 0; diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php index bb187f7207..3c3612ef25 100644 --- a/src/Symfony/Component/HttpFoundation/FileBag.php +++ b/src/Symfony/Component/HttpFoundation/FileBag.php @@ -75,22 +75,20 @@ class FileBag extends ParameterBag return $file; } - if (\is_array($file)) { - $file = $this->fixPhpFilesArray($file); - $keys = array_keys($file); - sort($keys); + $file = $this->fixPhpFilesArray($file); + $keys = array_keys($file); + sort($keys); - if (self::FILE_KEYS == $keys) { - if (\UPLOAD_ERR_NO_FILE == $file['error']) { - $file = null; - } else { - $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false); - } + if (self::FILE_KEYS == $keys) { + if (\UPLOAD_ERR_NO_FILE == $file['error']) { + $file = null; } else { - $file = array_map([$this, 'convertFileInformation'], $file); - if (array_keys($keys) === $keys) { - $file = array_filter($file); - } + $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false); + } + } else { + $file = array_map(function ($v) { return $v instanceof UploadedFile || \is_array($v) ? $this->convertFileInformation($v) : $v; }, $file); + if (array_keys($keys) === $keys) { + $file = array_filter($file); } } diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index cb280b9872..15393544fc 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -133,9 +133,9 @@ class HeaderBag implements \IteratorAggregate, \Countable /** * Sets a header by name. * - * @param string $key The key - * @param string|string[] $values The value or an array of values - * @param bool $replace Whether to replace the actual value or not (true by default) + * @param string $key The key + * @param string|string[]|null $values The value or an array of values + * @param bool $replace Whether to replace the actual value or not (true by default) */ public function set($key, $values, $replace = true) { @@ -228,8 +228,8 @@ class HeaderBag implements \IteratorAggregate, \Countable /** * Adds a custom Cache-Control directive. * - * @param string $key The Cache-Control directive name - * @param mixed $value The Cache-Control directive value + * @param string $key The Cache-Control directive name + * @param bool|string $value The Cache-Control directive value */ public function addCacheControlDirective($key, $value = true) { @@ -255,11 +255,11 @@ class HeaderBag implements \IteratorAggregate, \Countable * * @param string $key The directive name * - * @return mixed The directive value if defined, null otherwise + * @return bool|string|null The directive value if defined, null otherwise */ public function getCacheControlDirective($key) { - return \array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; + return $this->cacheControl[$key] ?? null; } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index 9cd63da728..bd26ef3413 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -257,7 +257,7 @@ class JsonResponseTest extends TestCase public function testConstructorWithObjectWithToStringMethod() { $class = new class() { - public function __toString() + public function __toString(): string { return '{}'; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php index 3f3982ff45..de5188d42c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php @@ -122,7 +122,7 @@ abstract class AbstractRedisSessionHandlerTestCase extends TestCase $lowTtl = 10; $this->redisClient->setex(self::PREFIX.'id', $lowTtl, 'foo'); - $this->storage->updateTimestamp('id', []); + $this->storage->updateTimestamp('id', 'data'); $this->assertGreaterThan($lowTtl, $this->redisClient->ttl(self::PREFIX.'id')); } diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php index 6ea179d783..a34befc22d 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactoryInterface.php @@ -19,7 +19,7 @@ namespace Symfony\Component\HttpKernel\ControllerMetadata; interface ArgumentMetadataFactoryInterface { /** - * @param mixed $controller The controller to resolve the arguments for + * @param string|object|array $controller The controller to resolve the arguments for * * @return ArgumentMetadata[] */ diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index 2797a347c8..0e25f8960f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -18,8 +18,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; /** - * LogDataCollector. - * * @author Fabien Potencier * * @final since Symfony 4.4 diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 0e3c13ba06..f40c2fb9f6 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -388,7 +388,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter /** * Parse a controller. * - * @param mixed $controller The controller to parse + * @param string|object|array|null $controller The controller to parse * * @return array|string An array of controller data or a simple string */ diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 6d7c1e942e..79755a8ad7 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -32,7 +32,7 @@ class FileLinkFormatter /** * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand */ - public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) + public function __construct(string $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $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/Intl/Resources/bin/common.php b/src/Symfony/Component/Intl/Resources/bin/common.php index 1ed762fee4..cf47fa448b 100644 --- a/src/Symfony/Component/Intl/Resources/bin/common.php +++ b/src/Symfony/Component/Intl/Resources/bin/common.php @@ -13,35 +13,35 @@ define('LINE_WIDTH', 75); define('LINE', str_repeat('-', LINE_WIDTH)."\n"); -function bailout($message) +function bailout(string $message) { echo wordwrap($message, LINE_WIDTH)." Aborting.\n"; exit(1); } -function strip_minor_versions($version) +function strip_minor_versions(string $version) { preg_match('/^(?P[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches); return $matches['version']; } -function centered($text) +function centered(string $text) { $padding = (int) ((LINE_WIDTH - strlen($text)) / 2); return str_repeat(' ', $padding).$text; } -function cd($dir) +function cd(string $dir) { if (false === chdir($dir)) { bailout("Could not switch to directory $dir."); } } -function run($command) +function run(string $command) { exec($command, $output, $status); @@ -53,7 +53,7 @@ function run($command) } } -function get_icu_version_from_genrb($genrb) +function get_icu_version_from_genrb(string $genrb) { exec($genrb.' --version - 2>&1', $output, $status); @@ -70,7 +70,7 @@ function get_icu_version_from_genrb($genrb) error_reporting(\E_ALL); -set_error_handler(function ($type, $msg, $file, $line) { +set_error_handler(function (int $type, string $msg, string $file, int $line) { throw new \ErrorException($msg, 0, $type, $file, $line); }); diff --git a/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php b/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php index 42e0056022..7fde86aa2b 100644 --- a/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php +++ b/src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php @@ -81,7 +81,7 @@ class PhpSerializer implements SerializerInterface /** * @internal */ - public static function handleUnserializeCallback($class) + public static function handleUnserializeCallback(string $class) { throw new MessageDecodingFailedException(sprintf('Message class "%s" not found during decoding.', $class)); } diff --git a/src/Symfony/Component/Mime/Header/Headers.php b/src/Symfony/Component/Mime/Header/Headers.php index 53ce8f94ae..1a7b4b276e 100644 --- a/src/Symfony/Component/Mime/Header/Headers.php +++ b/src/Symfony/Component/Mime/Header/Headers.php @@ -229,7 +229,7 @@ final class Headers /** * @internal */ - public function getHeaderBody($name) + public function getHeaderBody(string $name) { return $this->has($name) ? $this->get($name)->getBody() : null; } @@ -266,7 +266,7 @@ final class Headers /** * @internal */ - public function setHeaderParameter(string $name, string $parameter, $value): void + public function setHeaderParameter(string $name, string $parameter, ?string $value): void { if (!$this->has($name)) { throw new LogicException(sprintf('Unable to set parameter "%s" on header "%s" as the header is not defined.', $parameter, $name)); diff --git a/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php b/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php index 68b05055e6..6eded54c63 100644 --- a/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php +++ b/src/Symfony/Component/Mime/MimeTypeGuesserInterface.php @@ -26,8 +26,6 @@ interface MimeTypeGuesserInterface /** * Guesses the MIME type of the file with the given path. * - * @param string $path The path to the file - * * @return string|null The MIME type or null, if none could be guessed * * @throws \LogicException If the guesser is not supported diff --git a/src/Symfony/Component/Mime/Part/DataPart.php b/src/Symfony/Component/Mime/Part/DataPart.php index bbe8eca10b..18e474df65 100644 --- a/src/Symfony/Component/Mime/Part/DataPart.php +++ b/src/Symfony/Component/Mime/Part/DataPart.php @@ -39,8 +39,10 @@ class DataPart extends TextPart parent::__construct($body, null, $subtype, $encoding); - $this->filename = $filename; - $this->setName($filename); + if (null !== $filename) { + $this->filename = $filename; + $this->setName($filename); + } $this->setDisposition('attachment'); } diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index f63efbddf4..759883d418 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -232,10 +232,6 @@ class OptionsResolver implements Options } /** - * Sets a list of default values. - * - * @param array $defaults The default values to set - * * @return $this * * @throws AccessException If called from a lazy option or normalizer @@ -468,8 +464,7 @@ class OptionsResolver implements Options * * The resolved option value is set to the return value of the closure. * - * @param string $option The option name - * @param \Closure $normalizer The normalizer + * @param string $option The option name * * @return $this * @@ -512,10 +507,6 @@ class OptionsResolver implements Options * * The resolved option value is set to the return value of the closure. * - * @param string $option The option name - * @param \Closure $normalizer The normalizer - * @param bool $forcePrepend If set to true, prepend instead of appending - * * @return $this * * @throws UndefinedOptionsException If the option is undefined @@ -767,8 +758,6 @@ class OptionsResolver implements Options * - Options have invalid types; * - Options have invalid values. * - * @param array $options A map of option names to values - * * @return array The merged and validated options * * @throws UndefinedOptionsException If an option name is undefined diff --git a/src/Symfony/Component/Process/Pipes/AbstractPipes.php b/src/Symfony/Component/Process/Pipes/AbstractPipes.php index 6b72aed7d0..21ab3e389c 100644 --- a/src/Symfony/Component/Process/Pipes/AbstractPipes.php +++ b/src/Symfony/Component/Process/Pipes/AbstractPipes.php @@ -171,7 +171,7 @@ abstract class AbstractPipes implements PipesInterface /** * @internal */ - public function handleError($type, $msg) + public function handleError(int $type, string $msg) { $this->lastError = $msg; } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index cd262f1ad1..6db5a22f04 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -26,9 +26,6 @@ class AnnotationFileLoader extends FileLoader { protected $loader; - /** - * @throws \RuntimeException - */ public function __construct(FileLocatorInterface $locator, AnnotationClassLoader $loader) { if (!\function_exists('token_get_all')) { diff --git a/src/Symfony/Component/Routing/Loader/ContainerLoader.php b/src/Symfony/Component/Routing/Loader/ContainerLoader.php index 948da7b101..f248011baf 100644 --- a/src/Symfony/Component/Routing/Loader/ContainerLoader.php +++ b/src/Symfony/Component/Routing/Loader/ContainerLoader.php @@ -32,7 +32,7 @@ class ContainerLoader extends ObjectLoader */ public function supports($resource, $type = null) { - return 'service' === $type; + return 'service' === $type && \is_string($resource); } /** diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php index 1c5c5fdeb0..d50925c661 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php @@ -195,7 +195,7 @@ class StaticPrefixCollection return [substr($prefix, 0, $i), substr($prefix, 0, $staticLength ?? $i)]; } - public static function handleError($type, $msg) + public static function handleError(int $type, string $msg) { return false !== strpos($msg, 'Compilation failed: lookbehind assertion is not fixed length'); } diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index 63d1f6fe3d..473fbd4c15 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -116,8 +116,6 @@ class Route implements \Serializable } /** - * Returns the pattern for the path. - * * @return string The path pattern */ public function getPath() @@ -128,8 +126,6 @@ class Route implements \Serializable /** * Sets the pattern for the path. * - * This method implements a fluent interface. - * * @param string $pattern The path pattern * * @return $this @@ -158,8 +154,6 @@ class Route implements \Serializable } /** - * Returns the pattern for the host. - * * @return string The host pattern */ public function getHost() @@ -170,8 +164,6 @@ class Route implements \Serializable /** * Sets the pattern for the host. * - * This method implements a fluent interface. - * * @param string $pattern The host pattern * * @return $this @@ -199,8 +191,6 @@ class Route implements \Serializable * Sets the schemes (e.g. 'https') this route is restricted to. * So an empty array means that any scheme is allowed. * - * This method implements a fluent interface. - * * @param string|string[] $schemes The scheme or an array of schemes * * @return $this @@ -240,8 +230,6 @@ class Route implements \Serializable * Sets the HTTP methods (e.g. 'POST') this route is restricted to. * So an empty array means that any method is allowed. * - * This method implements a fluent interface. - * * @param string|string[] $methods The method or an array of methods * * @return $this @@ -255,8 +243,6 @@ class Route implements \Serializable } /** - * Returns the options. - * * @return array The options */ public function getOptions() @@ -265,10 +251,6 @@ class Route implements \Serializable } /** - * Sets the options. - * - * This method implements a fluent interface. - * * @return $this */ public function setOptions(array $options) @@ -281,10 +263,6 @@ class Route implements \Serializable } /** - * Adds options. - * - * This method implements a fluent interface. - * * @return $this */ public function addOptions(array $options) @@ -300,8 +278,6 @@ class Route implements \Serializable /** * Sets an option value. * - * This method implements a fluent interface. - * * @param string $name An option name * @param mixed $value The option value * @@ -340,8 +316,6 @@ class Route implements \Serializable } /** - * Returns the defaults. - * * @return array The defaults */ public function getDefaults() @@ -350,12 +324,6 @@ class Route implements \Serializable } /** - * Sets the defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * * @return $this */ public function setDefaults(array $defaults) @@ -366,12 +334,6 @@ class Route implements \Serializable } /** - * Adds defaults. - * - * This method implements a fluent interface. - * - * @param array $defaults The defaults - * * @return $this */ public function addDefaults(array $defaults) @@ -433,8 +395,6 @@ class Route implements \Serializable } /** - * Returns the requirements. - * * @return array The requirements */ public function getRequirements() @@ -443,12 +403,6 @@ class Route implements \Serializable } /** - * Sets the requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * * @return $this */ public function setRequirements(array $requirements) @@ -459,12 +413,6 @@ class Route implements \Serializable } /** - * Adds requirements. - * - * This method implements a fluent interface. - * - * @param array $requirements The requirements - * * @return $this */ public function addRequirements(array $requirements) @@ -526,8 +474,6 @@ class Route implements \Serializable } /** - * Returns the condition. - * * @return string The condition */ public function getCondition() @@ -538,8 +484,6 @@ class Route implements \Serializable /** * Sets the condition. * - * This method implements a fluent interface. - * * @param string $condition The condition * * @return $this diff --git a/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php b/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php index 24b032484f..f93aa7eb6c 100644 --- a/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php +++ b/src/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php @@ -45,6 +45,10 @@ class UserPasswordValidator extends ConstraintValidator return; } + if (!\is_string($password)) { + throw new UnexpectedTypeException($password, 'string'); + } + $user = $this->tokenStorage->getToken()->getUser(); if (!$user instanceof UserInterface) { diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 90d6d7eafa..47990f811b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -328,7 +328,7 @@ class ContextListener extends AbstractListener implements ListenerInterface /** * @internal */ - public static function handleUnserializeCallback($class) + public static function handleUnserializeCallback(string $class) { throw new \ErrorException('Class not found: '.$class, 0x37313bc); } diff --git a/src/Symfony/Component/Serializer/Annotation/Groups.php b/src/Symfony/Component/Serializer/Annotation/Groups.php index 4358a3e26d..29953eec03 100644 --- a/src/Symfony/Component/Serializer/Annotation/Groups.php +++ b/src/Symfony/Component/Serializer/Annotation/Groups.php @@ -29,7 +29,7 @@ class Groups private $groups; /** - * @throws InvalidArgumentException + * @param string[] $groups */ public function __construct(array $data) { @@ -48,8 +48,6 @@ class Groups } /** - * Gets groups. - * * @return string[] */ public function getGroups() diff --git a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php index 3b373c288a..d7fb3bc043 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php @@ -32,7 +32,7 @@ class ConstraintViolationListNormalizer implements NormalizerInterface, Cacheabl private $defaultContext; private $nameConverter; - public function __construct($defaultContext = [], NameConverterInterface $nameConverter = null) + public function __construct(array $defaultContext = [], NameConverterInterface $nameConverter = null) { $this->defaultContext = $defaultContext; $this->nameConverter = $nameConverter; diff --git a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php b/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php index 91de20192e..1adc757003 100644 --- a/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php +++ b/src/Symfony/Component/Translation/Extractor/ExtractorInterface.php @@ -24,7 +24,7 @@ interface ExtractorInterface /** * Extracts translation messages from files, a file or a directory to the catalogue. * - * @param string|array $resource Files, a file or a directory + * @param string|iterable $resource Files, a file or a directory */ public function extract($resource, MessageCatalogue $catalogue); diff --git a/src/Symfony/Component/Translation/MessageCatalogue.php b/src/Symfony/Component/Translation/MessageCatalogue.php index cc8d3ceef3..c146ec0074 100644 --- a/src/Symfony/Component/Translation/MessageCatalogue.php +++ b/src/Symfony/Component/Translation/MessageCatalogue.php @@ -27,8 +27,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf private $parent; /** - * @param string $locale The locale - * @param array $messages An array of messages classified by domain + * @param array $messages An array of messages classified by domain */ public function __construct(?string $locale, array $messages = []) { diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 0f03b5afc3..5e5d9570ca 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -177,8 +177,6 @@ class Translator implements LegacyTranslatorInterface, TranslatorInterface, Tran /** * Sets the fallback locales. * - * @param array $locales The fallback locales - * * @throws InvalidArgumentException If a locale contains invalid characters */ public function setFallbackLocales(array $locales) diff --git a/src/Symfony/Component/Validator/Constraints/RangeValidator.php b/src/Symfony/Component/Validator/Constraints/RangeValidator.php index 5f16510751..9f9e46e115 100644 --- a/src/Symfony/Component/Validator/Constraints/RangeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RangeValidator.php @@ -157,7 +157,7 @@ class RangeValidator extends ConstraintValidator } } - private function getLimit($propertyPath, $default, Constraint $constraint) + private function getLimit(?string $propertyPath, $default, Constraint $constraint) { if (null === $propertyPath) { return $default; diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index b5c263aca7..7e18d71fa6 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -233,8 +233,6 @@ abstract class ConstraintValidatorTestCase extends TestCase } /** - * @param $message - * * @return ConstraintViolationAssertion */ protected function buildViolation($message) diff --git a/src/Symfony/Component/VarDumper/Caster/LinkStub.php b/src/Symfony/Component/VarDumper/Caster/LinkStub.php index 6360716d7b..9b67836926 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, int $line = 0, $href = null) + public function __construct(string $label, int $line = 0, string $href = null) { $this->value = $label; diff --git a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php index 5a7c428525..a3278a886e 100644 --- a/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ResourceCaster.php @@ -48,7 +48,7 @@ class ResourceCaster public static function castStream($stream, array $a, Stub $stub, $isNested) { $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested); - if (isset($a['uri'])) { + if ($a['uri'] ?? false) { $a['uri'] = new LinkStub($a['uri']); } diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index 5abc51a9f3..be9d66bdd7 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -129,7 +129,7 @@ class SplCaster } } - if (isset($a[$prefix.'realPath'])) { + if ($a[$prefix.'realPath'] ?? false) { $a[$prefix.'realPath'] = new LinkStub($a[$prefix.'realPath']); } diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 6b205a7373..f1dedf6ac9 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -998,7 +998,7 @@ EOHTML } } -function esc($str) +function esc(string $str) { return htmlspecialchars($str, \ENT_QUOTES, 'UTF-8'); } diff --git a/src/Symfony/Component/VarDumper/Server/Connection.php b/src/Symfony/Component/VarDumper/Server/Connection.php index d8be23587e..ae4e76f7ef 100644 --- a/src/Symfony/Component/VarDumper/Server/Connection.php +++ b/src/Symfony/Component/VarDumper/Server/Connection.php @@ -78,7 +78,7 @@ class Connection return false; } - private static function nullErrorHandler($t, $m) + private static function nullErrorHandler(int $t, string $m) { // no-op }