diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php index 5bdf54565d647..a6443a3cad48c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -42,7 +42,7 @@ public function __construct(LoaderResolverInterface $resolver, array $defaultOpt /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { if ($this->loading) { // This can happen if a fatal error occurs in parent::load(). diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index d7930b2325828..6e1d96453947a 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -32,9 +32,9 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface protected $removeExtraKeys = true; protected $normalizeKeys = true; - public function setNormalizeKeys($normalizeKeys) + public function setNormalizeKeys(bool $normalizeKeys) { - $this->normalizeKeys = (bool) $normalizeKeys; + $this->normalizeKeys = $normalizeKeys; } /** @@ -46,7 +46,7 @@ public function setNormalizeKeys($normalizeKeys) * If you have a mixed key like foo-bar_moo, it will not be altered. * The key will also not be altered if the target key already exists. */ - protected function preNormalize($value) + protected function preNormalize(mixed $value) { if (!$this->normalizeKeys || !\is_array($value)) { return $value; @@ -200,7 +200,7 @@ public function addChild(NodeInterface $node) * @throws UnsetKeyException * @throws InvalidConfigurationException if the node doesn't have enough children */ - protected function finalizeValue($value) + protected function finalizeValue(mixed $value) { if (false === $value) { throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value))); @@ -246,7 +246,7 @@ protected function finalizeValue($value) /** * {@inheritdoc} */ - protected function validateType($value) + protected function validateType(mixed $value) { if (!\is_array($value) && (!$this->allowFalse || false !== $value)) { $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "array", but got "%s"', $this->getPath(), get_debug_type($value))); @@ -264,7 +264,7 @@ protected function validateType($value) * * @throws InvalidConfigurationException */ - protected function normalizeValue($value) + protected function normalizeValue(mixed $value) { if (false === $value) { return $value; @@ -345,7 +345,7 @@ protected function remapXml(array $value) * @throws InvalidConfigurationException * @throws \RuntimeException */ - protected function mergeValues($leftSide, $rightSide) + protected function mergeValues(mixed $leftSide, mixed $rightSide) { if (false === $rightSide) { // if this is still false after the last config has been merged the diff --git a/src/Symfony/Component/Config/Definition/BooleanNode.php b/src/Symfony/Component/Config/Definition/BooleanNode.php index c64ecb8394477..7cf651b21122a 100644 --- a/src/Symfony/Component/Config/Definition/BooleanNode.php +++ b/src/Symfony/Component/Config/Definition/BooleanNode.php @@ -23,7 +23,7 @@ class BooleanNode extends ScalarNode /** * {@inheritdoc} */ - protected function validateType($value) + protected function validateType(mixed $value) { if (!\is_bool($value)) { $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "bool", but got "%s".', $this->getPath(), get_debug_type($value))); @@ -39,7 +39,7 @@ protected function validateType($value) /** * {@inheritdoc} */ - protected function isValueEmpty($value) + protected function isValueEmpty(mixed $value) { // a boolean value cannot be empty return false; diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index 5609638459a62..48ca041f579d5 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -154,7 +154,7 @@ public function addDefaultsIfNotSet() * * @return $this */ - public function addDefaultChildrenIfNoneSet($children = null) + public function addDefaultChildrenIfNoneSet(int|string|array|null $children = null) { $this->addDefaultChildren = $children; diff --git a/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php index c4bff1756fb0d..221029cbed891 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php @@ -26,13 +26,11 @@ abstract class NumericNodeDefinition extends ScalarNodeDefinition /** * Ensures that the value is smaller than the given reference. * - * @param int|float $max - * * @return $this * * @throws \InvalidArgumentException when the constraint is inconsistent */ - public function max($max) + public function max(int|float $max) { if (isset($this->min) && $this->min > $max) { throw new \InvalidArgumentException(sprintf('You cannot define a max(%s) as you already have a min(%s).', $max, $this->min)); @@ -45,13 +43,11 @@ public function max($max) /** * Ensures that the value is bigger than the given reference. * - * @param int|float $min - * * @return $this * * @throws \InvalidArgumentException when the constraint is inconsistent */ - public function min($min) + public function min(int|float $min) { if (isset($this->max) && $this->max < $min) { throw new \InvalidArgumentException(sprintf('You cannot define a min(%s) as you already have a max(%s).', $min, $this->max)); diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index a8b18a0239e7b..b927f061de9ae 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -268,10 +268,8 @@ private function writeLine(string $text, int $indent = 0) /** * Renders the string conversion of the value. - * - * @param mixed $value */ - private function writeValue($value): string + private function writeValue(mixed $value): string { if ('%%%%not_defined%%%%' === $value) { return ''; diff --git a/src/Symfony/Component/Config/Definition/EnumNode.php b/src/Symfony/Component/Config/Definition/EnumNode.php index 822e6b57f1642..1c9ebce1ba642 100644 --- a/src/Symfony/Component/Config/Definition/EnumNode.php +++ b/src/Symfony/Component/Config/Definition/EnumNode.php @@ -41,7 +41,7 @@ public function getValues() /** * {@inheritdoc} */ - protected function finalizeValue($value) + protected function finalizeValue(mixed $value) { $value = parent::finalizeValue($value); diff --git a/src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php b/src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php index fcaaf49435f9d..ceb5e239bf017 100644 --- a/src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php +++ b/src/Symfony/Component/Config/Definition/Exception/InvalidConfigurationException.php @@ -22,7 +22,7 @@ class InvalidConfigurationException extends Exception private $path; private $containsHints = false; - public function setPath($path) + public function setPath(string $path) { $this->path = $path; } diff --git a/src/Symfony/Component/Config/Definition/FloatNode.php b/src/Symfony/Component/Config/Definition/FloatNode.php index 527f996efa168..235927f7b817a 100644 --- a/src/Symfony/Component/Config/Definition/FloatNode.php +++ b/src/Symfony/Component/Config/Definition/FloatNode.php @@ -23,7 +23,7 @@ class FloatNode extends NumericNode /** * {@inheritdoc} */ - protected function validateType($value) + protected function validateType(mixed $value) { // Integers are also accepted, we just cast them if (\is_int($value)) { diff --git a/src/Symfony/Component/Config/Definition/IntegerNode.php b/src/Symfony/Component/Config/Definition/IntegerNode.php index dfb4cc674dc0b..62643feb4888b 100644 --- a/src/Symfony/Component/Config/Definition/IntegerNode.php +++ b/src/Symfony/Component/Config/Definition/IntegerNode.php @@ -23,7 +23,7 @@ class IntegerNode extends NumericNode /** * {@inheritdoc} */ - protected function validateType($value) + protected function validateType(mixed $value) { if (!\is_int($value)) { $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "int", but got "%s".', $this->getPath(), get_debug_type($value))); diff --git a/src/Symfony/Component/Config/Definition/NodeInterface.php b/src/Symfony/Component/Config/Definition/NodeInterface.php index 45f1f681c1ea5..bc6b01c754ddb 100644 --- a/src/Symfony/Component/Config/Definition/NodeInterface.php +++ b/src/Symfony/Component/Config/Definition/NodeInterface.php @@ -65,36 +65,29 @@ public function getDefaultValue(); /** * Normalizes a value. * - * @param mixed $value The value to normalize - * * @return mixed The normalized value * * @throws InvalidTypeException if the value type is invalid */ - public function normalize($value); + public function normalize(mixed $value); /** * Merges two values together. * - * @param mixed $leftSide - * @param mixed $rightSide - * * @return mixed The merged value * * @throws ForbiddenOverwriteException if the configuration path cannot be overwritten * @throws InvalidTypeException if the value type is invalid */ - public function merge($leftSide, $rightSide); + public function merge(mixed $leftSide, mixed $rightSide); /** * Finalizes a value. * - * @param mixed $value The value to finalize - * * @return mixed The finalized value * * @throws InvalidTypeException if the value type is invalid * @throws InvalidConfigurationException if the value is invalid configuration */ - public function finalize($value); + public function finalize(mixed $value); } diff --git a/src/Symfony/Component/Config/Definition/NumericNode.php b/src/Symfony/Component/Config/Definition/NumericNode.php index 50d137c2d71fb..4b5eec41a9f24 100644 --- a/src/Symfony/Component/Config/Definition/NumericNode.php +++ b/src/Symfony/Component/Config/Definition/NumericNode.php @@ -23,11 +23,7 @@ class NumericNode extends ScalarNode protected $min; protected $max; - /** - * @param int|float|null $min - * @param int|float|null $max - */ - public function __construct(?string $name, NodeInterface $parent = null, $min = null, $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR) + public function __construct(?string $name, NodeInterface $parent = null, int|float|null $min = null, int|float|null $max = null, string $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR) { parent::__construct($name, $parent, $pathSeparator); $this->min = $min; @@ -37,7 +33,7 @@ public function __construct(?string $name, NodeInterface $parent = null, $min = /** * {@inheritdoc} */ - protected function finalizeValue($value) + protected function finalizeValue(mixed $value) { $value = parent::finalizeValue($value); @@ -60,7 +56,7 @@ protected function finalizeValue($value) /** * {@inheritdoc} */ - protected function isValueEmpty($value) + protected function isValueEmpty(mixed $value) { // a numeric value cannot be empty return false; diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 49c90ea9e9e3d..479c6d98bed34 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -104,7 +104,7 @@ public function hasDefaultValue() * * @param int|string|array|null $children The number of children|The child name|The children names to be added */ - public function setAddChildrenIfNoneSet($children = ['defaults']) + public function setAddChildrenIfNoneSet(int|string|array|null $children = ['defaults']) { if (null === $children) { $this->defaultChildren = ['defaults']; @@ -165,7 +165,7 @@ public function addChild(NodeInterface $node) /** * {@inheritdoc} */ - protected function finalizeValue($value) + protected function finalizeValue(mixed $value) { if (false === $value) { throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value))); @@ -195,7 +195,7 @@ protected function finalizeValue($value) * * @throws DuplicateKeyException */ - protected function normalizeValue($value) + protected function normalizeValue(mixed $value) { if (false === $value) { return $value; @@ -262,7 +262,7 @@ protected function normalizeValue($value) /** * {@inheritdoc} */ - protected function mergeValues($leftSide, $rightSide) + protected function mergeValues(mixed $leftSide, mixed $rightSide) { if (false === $rightSide) { // if this is still false after the last config has been merged the diff --git a/src/Symfony/Component/Config/Definition/ScalarNode.php b/src/Symfony/Component/Config/Definition/ScalarNode.php index 5296c27960283..798a3aeda7e71 100644 --- a/src/Symfony/Component/Config/Definition/ScalarNode.php +++ b/src/Symfony/Component/Config/Definition/ScalarNode.php @@ -30,7 +30,7 @@ class ScalarNode extends VariableNode /** * {@inheritdoc} */ - protected function validateType($value) + protected function validateType(mixed $value) { if (!is_scalar($value) && null !== $value) { $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected "scalar", but got "%s".', $this->getPath(), get_debug_type($value))); @@ -46,7 +46,7 @@ protected function validateType($value) /** * {@inheritdoc} */ - protected function isValueEmpty($value) + protected function isValueEmpty(mixed $value) { // assume environment variables are never empty (which in practice is likely to be true during runtime) // not doing so breaks many configs that are valid today diff --git a/src/Symfony/Component/Config/Definition/VariableNode.php b/src/Symfony/Component/Config/Definition/VariableNode.php index e868ece13e543..5571661012ba8 100644 --- a/src/Symfony/Component/Config/Definition/VariableNode.php +++ b/src/Symfony/Component/Config/Definition/VariableNode.php @@ -27,7 +27,7 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface protected $defaultValue; protected $allowEmptyValue = true; - public function setDefaultValue($value) + public function setDefaultValue(mixed $value) { $this->defaultValueSet = true; $this->defaultValue = $value; @@ -72,14 +72,14 @@ public function setName(string $name) /** * {@inheritdoc} */ - protected function validateType($value) + protected function validateType(mixed $value) { } /** * {@inheritdoc} */ - protected function finalizeValue($value) + protected function finalizeValue(mixed $value) { // deny environment variables only when using custom validators // this avoids ever passing an empty value to final validation closures @@ -109,7 +109,7 @@ protected function finalizeValue($value) /** * {@inheritdoc} */ - protected function normalizeValue($value) + protected function normalizeValue(mixed $value) { return $value; } @@ -117,7 +117,7 @@ protected function normalizeValue($value) /** * {@inheritdoc} */ - protected function mergeValues($leftSide, $rightSide) + protected function mergeValues(mixed $leftSide, mixed $rightSide) { return $rightSide; } @@ -129,13 +129,11 @@ protected function mergeValues($leftSide, $rightSide) * method may be overridden by subtypes to better match their understanding * of empty data. * - * @param mixed $value - * * @return bool * * @see finalizeValue() */ - protected function isValueEmpty($value) + protected function isValueEmpty(mixed $value) { return empty($value); } diff --git a/src/Symfony/Component/Config/Exception/LoaderLoadException.php b/src/Symfony/Component/Config/Exception/LoaderLoadException.php index 7c00284b07a45..cfd5bfe55ed15 100644 --- a/src/Symfony/Component/Config/Exception/LoaderLoadException.php +++ b/src/Symfony/Component/Config/Exception/LoaderLoadException.php @@ -73,7 +73,7 @@ public function __construct(string $resource, string $sourceResource = null, int parent::__construct($message, $code, $previous); } - protected function varToString($var) + protected function varToString(mixed $var) { if (\is_object($var)) { return sprintf('Object(%s)', \get_class($var)); diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index da350908a6bd9..21122e52c92e2 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -25,7 +25,7 @@ class FileLocator implements FileLocatorInterface /** * @param string|string[] $paths A path or an array of paths where to look for resources */ - public function __construct($paths = []) + public function __construct(string|array $paths = []) { $this->paths = (array) $paths; } diff --git a/src/Symfony/Component/Config/Loader/DelegatingLoader.php b/src/Symfony/Component/Config/Loader/DelegatingLoader.php index e5a74ee63b39d..77e483c45e7c5 100644 --- a/src/Symfony/Component/Config/Loader/DelegatingLoader.php +++ b/src/Symfony/Component/Config/Loader/DelegatingLoader.php @@ -31,7 +31,7 @@ public function __construct(LoaderResolverInterface $resolver) /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { if (false === $loader = $this->resolver->resolve($resource, $type)) { throw new LoaderLoadException($resource, null, 0, null, $type); @@ -43,7 +43,7 @@ public function load($resource, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { return false !== $this->resolver->resolve($resource, $type); } diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index 2351f13eda386..5cf51003fad17 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -70,7 +70,7 @@ public function getLocator() * @throws FileLoaderImportCircularReferenceException * @throws FileLocatorFileNotFoundException */ - public function import($resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, $exclude = null) + public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, string|array|null $exclude = null) { if (\is_string($resource) && \strlen($resource) !== ($i = strcspn($resource, '*?{[')) && false === strpos($resource, "\n")) { $excluded = []; @@ -133,7 +133,7 @@ protected function glob(string $pattern, bool $recursive, &$resource = null, boo yield from $resource; } - private function doImport($resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null) + private function doImport(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null) { try { $loader = $this->resolve($resource, $type); diff --git a/src/Symfony/Component/Config/Loader/GlobFileLoader.php b/src/Symfony/Component/Config/Loader/GlobFileLoader.php index fecb1c5d073ac..857b733611102 100644 --- a/src/Symfony/Component/Config/Loader/GlobFileLoader.php +++ b/src/Symfony/Component/Config/Loader/GlobFileLoader.php @@ -21,7 +21,7 @@ class GlobFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { return $this->import($resource); } @@ -29,7 +29,7 @@ public function load($resource, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { return 'glob' === $type; } diff --git a/src/Symfony/Component/Config/Loader/Loader.php b/src/Symfony/Component/Config/Loader/Loader.php index 3c0fe0846cff6..95f4bf6fef687 100644 --- a/src/Symfony/Component/Config/Loader/Loader.php +++ b/src/Symfony/Component/Config/Loader/Loader.php @@ -47,12 +47,9 @@ public function setResolver(LoaderResolverInterface $resolver) /** * Imports a resource. * - * @param mixed $resource A resource - * @param string|null $type The resource type or null if unknown - * * @return mixed */ - public function import($resource, string $type = null) + public function import(mixed $resource, string $type = null) { return $this->resolve($resource, $type)->load($resource, $type); } @@ -60,14 +57,11 @@ public function import($resource, string $type = null) /** * Finds a loader able to load an imported resource. * - * @param mixed $resource A resource - * @param string|null $type The resource type or null if unknown - * * @return $this|LoaderInterface * * @throws LoaderLoadException If no loader is found */ - public function resolve($resource, string $type = null) + public function resolve(mixed $resource, string $type = null) { if ($this->supports($resource, $type)) { return $this; diff --git a/src/Symfony/Component/Config/Loader/LoaderInterface.php b/src/Symfony/Component/Config/Loader/LoaderInterface.php index fee6f9f1c334c..54848962638c9 100644 --- a/src/Symfony/Component/Config/Loader/LoaderInterface.php +++ b/src/Symfony/Component/Config/Loader/LoaderInterface.php @@ -21,13 +21,11 @@ interface LoaderInterface /** * Loads a resource. * - * @param mixed $resource The resource - * * @return mixed * * @throws \Exception If something went wrong */ - public function load($resource, string $type = null); + public function load(mixed $resource, string $type = null); /** * Returns whether this class supports the given resource. @@ -36,7 +34,7 @@ public function load($resource, string $type = null); * * @return bool True if this class supports the given resource, false otherwise */ - public function supports($resource, string $type = null); + public function supports(mixed $resource, string $type = null); /** * Gets the loader resolver. diff --git a/src/Symfony/Component/Config/Loader/LoaderResolver.php b/src/Symfony/Component/Config/Loader/LoaderResolver.php index d243b91d42542..a20ecf43b2d58 100644 --- a/src/Symfony/Component/Config/Loader/LoaderResolver.php +++ b/src/Symfony/Component/Config/Loader/LoaderResolver.php @@ -39,7 +39,7 @@ public function __construct(array $loaders = []) /** * {@inheritdoc} */ - public function resolve($resource, string $type = null) + public function resolve(mixed $resource, string $type = null) { foreach ($this->loaders as $loader) { if ($loader->supports($resource, $type)) { diff --git a/src/Symfony/Component/Config/Loader/LoaderResolverInterface.php b/src/Symfony/Component/Config/Loader/LoaderResolverInterface.php index 2c45a4cbd79b7..fd5dc693541b5 100644 --- a/src/Symfony/Component/Config/Loader/LoaderResolverInterface.php +++ b/src/Symfony/Component/Config/Loader/LoaderResolverInterface.php @@ -21,10 +21,9 @@ interface LoaderResolverInterface /** * Returns a loader able to load the resource. * - * @param mixed $resource A resource - * @param string|null $type The resource type or null if unknown + * @param string|null $type The resource type or null if unknown * * @return LoaderInterface|false The loader or false if none is able to load the resource */ - public function resolve($resource, string $type = null); + public function resolve(mixed $resource, string $type = null); } diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php index 190ab991acd3d..d47370132e63d 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCache.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCache.php @@ -181,7 +181,7 @@ private function safelyUnserialize(string $file) /** * @internal */ - public static function handleUnserializeCallback($class) + public static function handleUnserializeCallback(string $class) { trigger_error('Class not found: '.$class); } diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index a5a8a78dc505e..fce5a6b801050 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -68,11 +68,9 @@ public function ignoreAndRemoveMatrixProvider(): array } /** - * @param array|\Exception $expected - * * @dataProvider ignoreAndRemoveMatrixProvider */ - public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, $expected, string $message = '') + public function testIgnoreAndRemoveBehaviors(bool $ignore, bool $remove, array|\Exception $expected, string $message = '') { if ($expected instanceof \Exception) { $this->expectException(\get_class($expected)); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index e307b615315d0..45e3ccf5de249 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -98,11 +98,9 @@ public function testPrototypedArrayNodeDefaultWhenUsingDefaultChildren() } /** - * @param int|array|string|null $args - * * @dataProvider providePrototypedArrayNodeDefaults */ - public function testPrototypedArrayNodeDefault($args, bool $shouldThrowWhenUsingAttrAsKey, bool $shouldThrowWhenNotUsingAttrAsKey, array $defaults) + public function testPrototypedArrayNodeDefault(int|array|string|null $args, bool $shouldThrowWhenUsingAttrAsKey, bool $shouldThrowWhenNotUsingAttrAsKey, array $defaults) { $node = new ArrayNodeDefinition('root'); $node @@ -437,10 +435,7 @@ protected function assertNode(string $expectedName, string $expectedType, NodeDe $this->assertSame($expectedName, $this->getField($actualNode, 'name')); } - /** - * @param object $object - */ - protected function getField($object, string $field) + protected function getField(object $object, string $field) { $reflection = new \ReflectionProperty($object, $field); $reflection->setAccessible(true); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index 74ae972e54aab..21af3b7236075 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 @@ protected function getTestBuilder(): ExprBuilder * * @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 @@ protected function returnClosure($val): \Closure * @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/Config/Tests/Definition/FloatNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php index d675f47046f90..5a0fccb2868da 100644 --- a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php @@ -19,10 +19,8 @@ class FloatNodeTest extends TestCase { /** * @dataProvider getValidValues - * - * @param int|float $value */ - public function testNormalize($value) + public function testNormalize(int|float $value) { $node = new FloatNode('test'); $this->assertSame($value, $node->normalize($value)); @@ -30,10 +28,8 @@ public function testNormalize($value) /** * @dataProvider getValidValues - * - * @param int|float $value */ - public function testValidNonEmptyValues($value) + public function testValidNonEmptyValues(int|float $value) { $node = new FloatNode('test'); $node->setAllowEmptyValue(false); diff --git a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php index b02d6ce6df2d4..e68d9a68a8703 100644 --- a/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/PrototypedArrayNodeTest.php @@ -264,7 +264,7 @@ protected function getPrototypeNodeWithDefaultChildren() * * @dataProvider getDataForKeyRemovedLeftValueOnly */ - public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, $children, array $expected) + public function testMappedAttributeKeyIsRemovedLeftValueOnly($value, array $children, array $expected) { $node = new PrototypedArrayNode('root'); $node->setKeyAttribute('id', true); diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php index cb5106844324c..df1bcd45374d4 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php @@ -16,7 +16,7 @@ class NodeBuilder extends BaseNodeBuilder { - public function barNode($name): NodeDefinition + public function barNode(?string $name): NodeDefinition { return $this->node($name, 'bar'); } diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/CustomNode.php b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/CustomNode.php index f6c53ceeeb88f..233728cc6f246 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Configuration/CustomNode.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Configuration/CustomNode.php @@ -32,17 +32,17 @@ public function getDefaultValue() return true; } - public function normalize($value) + public function normalize(mixed $value) { return $value; } - public function merge($leftSide, $rightSide) + public function merge(mixed $leftSide, mixed $rightSide) { return array_merge($leftSide, $rightSide); } - public function finalize($value) + public function finalize(mixed $value) { return $value; } diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index 26e361b293145..4555347754cf7 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -155,12 +155,12 @@ class TestFileLoader extends FileLoader { private $supports = true; - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { return $resource; } - public function supports($resource, string $type = null): bool + public function supports(mixed $resource, string $type = null): bool { return $this->supports; } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index 9b163f100fd7b..127e931989311 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -104,11 +104,11 @@ public function testImportWithType() class ProjectLoader1 extends Loader { - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { } - public function supports($resource, string $type = null): bool + public function supports(mixed $resource, string $type = null): bool { return \is_string($resource) && 'foo' === pathinfo($resource, \PATHINFO_EXTENSION); } diff --git a/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php b/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php index 4073566d19f2a..3cf8cfdbfa3dc 100644 --- a/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php +++ b/src/Symfony/Component/Config/Tests/Resource/ResourceStub.php @@ -27,7 +27,7 @@ public function __toString(): string return 'stub'; } - public function isFresh($timestamp): bool + public function isFresh(int $timestamp): bool { return $this->fresh; } diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 585f4ade4385a..184917b9eddbb 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -72,7 +72,7 @@ public function testLoadFile() XmlUtils::loadFile($fixtures.'invalid_schema.xml', 'invalid_callback_or_file'); $this->fail(); } catch (\InvalidArgumentException $e) { - $this->assertStringContainsString('XSD file or callable', $e->getMessage()); + $this->assertStringContainsString('Invalid XSD file: "invalid_callback_or_file".', $e->getMessage()); } $mock = $this->createMock(Validator::class); @@ -150,7 +150,7 @@ public function getDataForConvertDomToArray(): array /** * @dataProvider getDataForPhpize */ - public function testPhpize($expected, $value) + public function testPhpize($expected, string $value) { $this->assertSame($expected, XmlUtils::phpize($value)); } diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index ac82c020812df..517ba68221057 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -44,7 +44,7 @@ private function __construct() * @throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself * @throws \RuntimeException When DOM extension is missing */ - public static function parse(string $content, $schemaOrCallable = null) + public static function parse(string $content, string|callable|null $schemaOrCallable = null) { if (!\extension_loaded('dom')) { throw new \LogicException('Extension DOM is required.'); @@ -80,13 +80,13 @@ public static function parse(string $content, $schemaOrCallable = null) } catch (\Exception $e) { $valid = false; } - } elseif (!\is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) { + } elseif (is_file($schemaOrCallable)) { $schemaSource = file_get_contents((string) $schemaOrCallable); $valid = @$dom->schemaValidateSource($schemaSource); } else { libxml_use_internal_errors($internalErrors); - throw new XmlParsingException('The schemaOrCallable argument has to be a valid path to XSD file or callable.'); + throw new XmlParsingException(sprintf('Invalid XSD file: "%s".', $schemaOrCallable)); } if (!$valid) { @@ -116,7 +116,7 @@ public static function parse(string $content, $schemaOrCallable = null) * @throws XmlParsingException When XML parsing returns any errors * @throws \RuntimeException When DOM extension is missing */ - public static function loadFile(string $file, $schemaOrCallable = null) + public static function loadFile(string $file, string|callable|null $schemaOrCallable = null) { if (!is_file($file)) { throw new \InvalidArgumentException(sprintf('Resource "%s" is not a file.', $file)); @@ -213,11 +213,9 @@ public static function convertDomElementToArray(\DOMElement $element, bool $chec /** * Converts an xml value to a PHP type. * - * @param mixed $value - * * @return mixed */ - public static function phpize($value) + public static function phpize(string|\Stringable $value) { $value = (string) $value; $lowercaseValue = strtolower($value); @@ -229,12 +227,12 @@ public static function phpize($value) $raw = $value; $cast = (int) $value; - return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw); + return '0' == $value[0] ? octdec($value) : (($raw === (string) $cast) ? $cast : $raw); case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)): $raw = $value; $cast = (int) $value; - return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw); + return '0' == $value[1] ? octdec($value) : (($raw === (string) $cast) ? $cast : $raw); case 'true' === $lowercaseValue: return true; case 'false' === $lowercaseValue: diff --git a/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php b/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php index a8337d4e66e62..bfcffd312c883 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php @@ -34,7 +34,7 @@ public function __construct(ContainerBuilder $container, string $env = null) /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { $resource($this->container, $this->env); } @@ -42,7 +42,7 @@ public function load($resource, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { return $resource instanceof \Closure; } diff --git a/src/Symfony/Component/DependencyInjection/Loader/DirectoryLoader.php b/src/Symfony/Component/DependencyInjection/Loader/DirectoryLoader.php index 943986982e344..126a0f4d97f57 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/DirectoryLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/DirectoryLoader.php @@ -21,7 +21,7 @@ class DirectoryLoader extends FileLoader /** * {@inheritdoc} */ - public function load($file, string $type = null) + public function load(mixed $file, string $type = null) { $file = rtrim($file, '/'); $path = $this->locator->locate($file); @@ -43,7 +43,7 @@ public function load($file, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { if ('directory' === $type) { return true; diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index 54688910b245d..e7322d7ed1ac2 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -52,7 +52,7 @@ public function __construct(ContainerBuilder $container, FileLocatorInterface $l * * @param bool|string $ignoreErrors Whether errors should be ignored; pass "not_found" to ignore only when the loaded resource is not found */ - public function import($resource, string $type = null, $ignoreErrors = false, string $sourceResource = null, $exclude = null) + public function import(mixed $resource, string $type = null, bool|string $ignoreErrors = false, string $sourceResource = null, $exclude = null) { $args = \func_get_args(); diff --git a/src/Symfony/Component/DependencyInjection/Loader/GlobFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/GlobFileLoader.php index 53af9cf2b8a18..2bb85bb31dad4 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/GlobFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/GlobFileLoader.php @@ -21,7 +21,7 @@ class GlobFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { foreach ($this->glob($resource, false, $globResource) as $path => $info) { $this->import($path); @@ -33,7 +33,7 @@ public function load($resource, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { return 'glob' === $type; } diff --git a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php index fbf313878b807..4caa62dd21980 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php @@ -24,7 +24,7 @@ class IniFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { $path = $this->locator->locate($resource); @@ -55,7 +55,7 @@ public function load($resource, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { if (!\is_string($resource)) { return false; diff --git a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php index 559b8b162ef60..9cb4048657c1c 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php @@ -45,7 +45,7 @@ public function __construct(ContainerBuilder $container, FileLocatorInterface $l /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { // the container and loader variables are exposed to the included file below $container = $this->container; @@ -75,7 +75,7 @@ public function load($resource, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { if (!\is_string($resource)) { return false; diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index a9cc5075cb994..60dad8e7e57bd 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -43,7 +43,7 @@ class XmlFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { $path = $this->locator->locate($resource); @@ -96,7 +96,7 @@ private function loadXml(\DOMDocument $xml, string $path, \DOMNode $root = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { if (!\is_string($resource)) { return false; diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 8f3924dc4fb3d..38311b45aeb06 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -117,7 +117,7 @@ class YamlFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { $path = $this->locator->locate($resource); @@ -182,7 +182,7 @@ private function loadContent($content, $path) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { if (!\is_string($resource)) { return false; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php index 3f1503bede8e8..04dc879ef03b8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -295,12 +295,12 @@ class TestFileLoader extends FileLoader { public $autoRegisterAliasesForSinglyImplementedInterfaces = true; - public function load($resource, string $type = null) + public function load(mixed $resource, string $type = null) { return $resource; } - public function supports($resource, string $type = null): bool + public function supports(mixed $resource, string $type = null): bool { return false; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/GlobFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/GlobFileLoaderTest.php index 2f45c844c568e..032a9af261653 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/GlobFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/GlobFileLoaderTest.php @@ -38,7 +38,7 @@ public function testLoadAddsTheGlobResourceToTheContainer() class GlobFileLoaderWithoutImport extends GlobFileLoader { - public function import($resource, string $type = null, $ignoreErrors = false, string $sourceResource = null, $exclude = null) + public function import(mixed $resource, string $type = null, bool|string $ignoreErrors = false, string $sourceResource = null, $exclude = null) { return null; } diff --git a/src/Symfony/Component/Routing/Loader/ClosureLoader.php b/src/Symfony/Component/Routing/Loader/ClosureLoader.php index 320cdc4d8d5d9..631d8888af474 100644 --- a/src/Symfony/Component/Routing/Loader/ClosureLoader.php +++ b/src/Symfony/Component/Routing/Loader/ClosureLoader.php @@ -36,7 +36,7 @@ public function load(mixed $closure, string $type = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { return $resource instanceof \Closure && (!$type || 'closure' === $type); } diff --git a/src/Symfony/Component/Routing/Loader/ContainerLoader.php b/src/Symfony/Component/Routing/Loader/ContainerLoader.php index d8730aec61479..2f2511f4e75f8 100644 --- a/src/Symfony/Component/Routing/Loader/ContainerLoader.php +++ b/src/Symfony/Component/Routing/Loader/ContainerLoader.php @@ -31,7 +31,7 @@ public function __construct(ContainerInterface $container, string $env = null) /** * {@inheritdoc} */ - public function supports($resource, string $type = null) + public function supports(mixed $resource, string $type = null) { return 'service' === $type && \is_string($resource); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/GlobFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/GlobFileLoaderTest.php index 29e659300ca88..4cf5d7c810859 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/GlobFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/GlobFileLoaderTest.php @@ -38,7 +38,7 @@ public function testLoadAddsTheGlobResourceToTheContainer() class GlobFileLoaderWithoutImport extends GlobFileLoader { - public function import($resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, $exclude = null) + public function import(mixed $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null, $exclude = null) { return new RouteCollection(); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php index 54d3643b1f584..e086467a87199 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectLoaderTest.php @@ -98,7 +98,7 @@ class TestObjectLoader extends ObjectLoader { public $loaderMap = []; - public function supports($resource, string $type = null): bool + public function supports(mixed $resource, string $type = null): bool { return 'service'; } diff --git a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php index 2de3164876450..2d890c8c3616a 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php @@ -320,7 +320,7 @@ private function createFailingLoader(): LoaderInterface class StaleResource implements SelfCheckingResourceInterface { - public function isFresh($timestamp): bool + public function isFresh(int $timestamp): bool { return false; }