diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index cc1b858abb33..fe0d60b5554f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -52,6 +52,9 @@ protected function listBundles($output) } } + /** + * @return ExtensionInterface + */ protected function findExtension($name) { $bundles = $this->initializeBundles(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php index 08690fa3dd07..aafcbd63afa7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -40,7 +40,7 @@ public function __construct(LoaderResolverInterface $resolver, array $defaultOpt /** * {@inheritdoc} */ - public function load($resource, $type = null) + public function load($resource, string $type = null) { if ($this->loading) { // This can happen if a fatal error occurs in parent::load(). diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 6bc99db6af6c..a628750c5271 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -19,7 +19,7 @@ "php": "^7.2.9", "ext-xml": "*", "symfony/cache": "^4.4|^5.0", - "symfony/config": "^4.4|^5.0", + "symfony/config": "^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/error-catcher": "^4.4|^5.0", "symfony/http-foundation": "^4.4|^5.0", diff --git a/src/Symfony/Component/Config/ConfigCacheFactory.php b/src/Symfony/Component/Config/ConfigCacheFactory.php index bcec95c11d9c..11fd3cb3a2d4 100644 --- a/src/Symfony/Component/Config/ConfigCacheFactory.php +++ b/src/Symfony/Component/Config/ConfigCacheFactory.php @@ -35,12 +35,8 @@ public function __construct(bool $debug) /** * {@inheritdoc} */ - public function cache(string $file, $callback) + public function cache(string $file, callable $callback) { - if (!\is_callable($callback)) { - throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback))); - } - $cache = new ConfigCache($file, $this->debug); if (!$cache->isFresh()) { $callback($cache); diff --git a/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php b/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php index 255b85a6575a..7dfa0f243797 100644 --- a/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php +++ b/src/Symfony/Component/Config/ConfigCacheFactoryInterface.php @@ -28,5 +28,5 @@ interface ConfigCacheFactoryInterface * * @return ConfigCacheInterface The cache instance */ - public function cache(string $file, $callable); + public function cache(string $file, callable $callable); } diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 9fabdd5628a4..74167bbf6a97 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -129,16 +129,16 @@ public function setAllowNewKeys(bool $allow) */ public function setPerformDeepMerging(bool $boolean) { - $this->performDeepMerging = (bool) $boolean; + $this->performDeepMerging = $boolean; } /** - * Whether extra keys should just be ignore without an exception. + * Whether extra keys should just be ignored without an exception. * * @param bool $boolean To allow extra keys * @param bool $remove To remove extra keys */ - public function setIgnoreExtraKeys(bool $boolean, $remove = true) + public function setIgnoreExtraKeys(bool $boolean, bool $remove = true) { $this->ignoreExtraKeys = $boolean; $this->removeExtraKeys = $this->ignoreExtraKeys && $remove; diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index 39511c15c6b8..02f816313e68 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -97,17 +97,17 @@ public static function resetPlaceholders(): void self::$placeholders = []; } - public function setAttribute($key, $value) + public function setAttribute(string $key, $value) { $this->attributes[$key] = $value; } - public function getAttribute($key, $default = null) + public function getAttribute(string $key, $default = null) { return isset($this->attributes[$key]) ? $this->attributes[$key] : $default; } - public function hasAttribute($key) + public function hasAttribute(string $key) { return isset($this->attributes[$key]); } @@ -122,17 +122,15 @@ public function setAttributes(array $attributes) $this->attributes = $attributes; } - public function removeAttribute($key) + public function removeAttribute(string $key) { unset($this->attributes[$key]); } /** * Sets an info message. - * - * @param string $info */ - public function setInfo($info) + public function setInfo(string $info) { $this->setAttribute('info', $info); } @@ -183,9 +181,9 @@ public function addEquivalentValue($originalValue, $equivalentValue) * * @param bool $boolean Required node */ - public function setRequired($boolean) + public function setRequired(bool $boolean) { - $this->required = (bool) $boolean; + $this->required = $boolean; } /** @@ -193,22 +191,18 @@ public function setRequired($boolean) * * You can use %node% and %path% placeholders in your message to display, * respectively, the node name and its complete path. - * - * @param string|null $message Deprecated message */ - public function setDeprecated($message) + public function setDeprecated(?string $message) { $this->deprecationMessage = $message; } /** * Sets if this node can be overridden. - * - * @param bool $allow */ - public function setAllowOverwrite($allow) + public function setAllowOverwrite(bool $allow) { - $this->allowOverwrite = (bool) $allow; + $this->allowOverwrite = $allow; } /** @@ -257,7 +251,7 @@ public function isDeprecated() * * @return string */ - public function getDeprecationMessage($node, $path) + public function getDeprecationMessage(string $node, string $path) { return strtr($this->deprecationMessage, ['%node%' => $node, '%path%' => $path]); } @@ -366,9 +360,9 @@ final public function normalize($value) /** * Normalizes the value before any other normalization is applied. * - * @param $value + * @param mixed $value * - * @return The normalized array value + * @return mixed The normalized array value */ protected function preNormalize($value) { diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index e40d97b2fb89..f2a5148d7249 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -66,11 +66,9 @@ public function children() /** * Sets a prototype for child nodes. * - * @param string $type The type of node - * * @return NodeDefinition */ - public function prototype($type) + public function prototype(string $type) { return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this); } @@ -194,12 +192,12 @@ public function disallowNewKeysInSubsequentConfigs() /** * Sets a normalization rule for XML configurations. * - * @param string $singular The key to remap - * @param string $plural The plural of the key for irregular plurals + * @param string $singular The key to remap + * @param string|null $plural The plural of the key for irregular plurals * * @return $this */ - public function fixXmlConfig($singular, $plural = null) + public function fixXmlConfig(string $singular, string $plural = null) { $this->normalization()->remap($singular, $plural); @@ -234,7 +232,7 @@ public function fixXmlConfig($singular, $plural = null) * * @return $this */ - public function useAttributeAsKey($name, $removeKeyItem = true) + public function useAttributeAsKey(string $name, bool $removeKeyItem = true) { $this->key = $name; $this->removeKeyItem = $removeKeyItem; @@ -245,11 +243,9 @@ public function useAttributeAsKey($name, $removeKeyItem = true) /** * Sets whether the node can be unset. * - * @param bool $allow - * * @return $this */ - public function canBeUnset($allow = true) + public function canBeUnset(bool $allow = true) { $this->merge()->allowUnset($allow); @@ -341,7 +337,7 @@ public function performNoDeepMerging() * * @return $this */ - public function ignoreExtraKeys($remove = true) + public function ignoreExtraKeys(bool $remove = true) { $this->ignoreExtraKeys = true; $this->removeExtraKeys = $remove; @@ -350,15 +346,13 @@ public function ignoreExtraKeys($remove = true) } /** - * Sets key normalization. - * - * @param bool $bool Whether to enable key normalization + * Sets whether to enable key normalization. * * @return $this */ - public function normalizeKeys($bool) + public function normalizeKeys(bool $bool) { - $this->normalizeKeys = (bool) $bool; + $this->normalizeKeys = $bool; return $this; } @@ -417,6 +411,10 @@ protected function createNode() } if ($this->default) { + if (!\is_array($this->defaultValue)) { + throw new \InvalidArgumentException($node->getPath().': the default value of an array node has to be an array.'); + } + $node->setDefaultValue($this->defaultValue); } diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index 05949d2b5a3b..4d918cef12b3 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -178,13 +178,11 @@ public function thenEmptyArray() * * if you want to add the value of the node in your message just use a %s placeholder. * - * @param string $message - * * @return $this * * @throws \InvalidArgumentException */ - public function thenInvalid($message) + public function thenInvalid(string $message) { $this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); }; diff --git a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php index 105e2d64709b..a88d49ba93a4 100644 --- a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php @@ -30,11 +30,9 @@ public function __construct(NodeDefinition $node) /** * Sets whether the node can be unset. * - * @param bool $allow - * * @return $this */ - public function allowUnset($allow = true) + public function allowUnset(bool $allow = true) { $this->allowFalse = $allow; @@ -44,11 +42,9 @@ public function allowUnset($allow = true) /** * Sets whether the node can be overwritten. * - * @param bool $deny Whether the overwriting is forbidden or not - * * @return $this */ - public function denyOverwrite($deny = true) + public function denyOverwrite(bool $deny = true) { $this->allowOverwrite = !$deny; diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php index 84ad86794c1e..a9b48690e53c 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php @@ -49,11 +49,9 @@ public function setParent(ParentNodeDefinitionInterface $parent = null) /** * Creates a child array node. * - * @param string $name The name of the node - * * @return ArrayNodeDefinition The child node */ - public function arrayNode($name) + public function arrayNode(string $name) { return $this->node($name, 'array'); } @@ -61,11 +59,9 @@ public function arrayNode($name) /** * Creates a child scalar node. * - * @param string $name The name of the node - * * @return ScalarNodeDefinition The child node */ - public function scalarNode($name) + public function scalarNode(string $name) { return $this->node($name, 'scalar'); } @@ -73,11 +69,9 @@ public function scalarNode($name) /** * Creates a child Boolean node. * - * @param string $name The name of the node - * * @return BooleanNodeDefinition The child node */ - public function booleanNode($name) + public function booleanNode(string $name) { return $this->node($name, 'boolean'); } @@ -85,11 +79,9 @@ public function booleanNode($name) /** * Creates a child integer node. * - * @param string $name The name of the node - * * @return IntegerNodeDefinition The child node */ - public function integerNode($name) + public function integerNode(string $name) { return $this->node($name, 'integer'); } @@ -97,11 +89,9 @@ public function integerNode($name) /** * Creates a child float node. * - * @param string $name The name of the node - * * @return FloatNodeDefinition The child node */ - public function floatNode($name) + public function floatNode(string $name) { return $this->node($name, 'float'); } @@ -109,11 +99,9 @@ public function floatNode($name) /** * Creates a child EnumNode. * - * @param string $name - * * @return EnumNodeDefinition */ - public function enumNode($name) + public function enumNode(string $name) { return $this->node($name, 'enum'); } @@ -121,11 +109,9 @@ public function enumNode($name) /** * Creates a child variable node. * - * @param string $name The name of the node - * * @return VariableNodeDefinition The builder of the child node */ - public function variableNode($name) + public function variableNode(string $name) { return $this->node($name, 'variable'); } @@ -143,15 +129,12 @@ public function end() /** * Creates a child node. * - * @param string|null $name The name of the node - * @param string $type The type of the node - * * @return NodeDefinition The child node * * @throws \RuntimeException When the node type is not registered * @throws \RuntimeException When the node class is not found */ - public function node($name, $type) + public function node(?string $name, string $type) { $class = $this->getNodeClass($type); @@ -202,7 +185,7 @@ public function append(NodeDefinition $node) * * @return $this */ - public function setNodeClass($type, $class) + public function setNodeClass(string $type, string $class) { $this->nodeMapping[strtolower($type)] = $class; @@ -212,14 +195,12 @@ public function setNodeClass($type, $class) /** * Returns the class name of the node definition. * - * @param string $type The node type - * * @return string The node definition class name * * @throws \RuntimeException When the node type is not registered * @throws \RuntimeException When the node class is not found */ - protected function getNodeClass($type) + protected function getNodeClass(string $type) { $type = strtolower($type); diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index c51b0b4a67ca..5e42b85e1f0b 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -59,11 +59,9 @@ public function setParent(NodeParentInterface $parent) /** * Sets info message. * - * @param string $info The info text - * * @return $this */ - public function info($info) + public function info(string $info) { return $this->attribute('info', $info); } @@ -83,12 +81,11 @@ public function example($example) /** * Sets an attribute on the node. * - * @param string $key - * @param mixed $value + * @param mixed $value * * @return $this */ - public function attribute($key, $value) + public function attribute(string $key, $value) { $this->attributes[$key] = $value; @@ -112,7 +109,7 @@ public function end() * * @return NodeInterface */ - public function getNode($forceRootNode = false) + public function getNode(bool $forceRootNode = false) { if ($forceRootNode) { $this->parent = null; @@ -165,11 +162,9 @@ public function isRequired() * You can use %node% and %path% placeholders in your message to display, * respectively, the node name and its complete path. * - * @param string $message Deprecation message - * * @return $this */ - public function setDeprecated($message = 'The child node "%node%" at path "%path%" is deprecated.') + public function setDeprecated(string $message = 'The child node "%node%" at path "%path%" is deprecated.') { $this->deprecationMessage = $message; @@ -287,11 +282,9 @@ public function validate() /** * Sets whether the node can be overwritten. * - * @param bool $deny Whether the overwriting is forbidden or not - * * @return $this */ - public function cannotBeOverwritten($deny = true) + public function cannotBeOverwritten(bool $deny = true) { $this->merge()->denyOverwrite($deny); diff --git a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php index d3cdca90df1c..06cbbd4345ff 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php @@ -30,12 +30,12 @@ public function __construct(NodeDefinition $node) /** * Registers a key to remap to its plural form. * - * @param string $key The key to remap - * @param string $plural The plural of the key in case of irregular plural + * @param string $key The key to remap + * @param string|null $plural The plural of the key in case of irregular plural * * @return $this */ - public function remap($key, $plural = null) + public function remap(string $key, string $plural = null) { $this->remappings[] = [$key, null === $plural ? $key.'s' : $plural]; diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index 7276b55a896c..5543f55879fc 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -26,7 +26,7 @@ class XmlReferenceDumper { private $reference; - public function dump(ConfigurationInterface $configuration, $namespace = null) + public function dump(ConfigurationInterface $configuration, string $namespace = null) { return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace); } diff --git a/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php b/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php index 53ed43667ffc..b160aa94a496 100644 --- a/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php +++ b/src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php @@ -20,8 +20,6 @@ interface PrototypeNodeInterface extends NodeInterface { /** * Sets the name of the node. - * - * @param string $name The name of the node */ public function setName(string $name); } diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index dd6ccd94a358..61291e2e057c 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -37,10 +37,8 @@ class PrototypedArrayNode extends ArrayNode /** * Sets the minimum number of elements that a prototype based node must * contain. By default this is zero, meaning no elements. - * - * @param int $number */ - public function setMinNumberOfElements($number) + public function setMinNumberOfElements(int $number) { $this->minNumberOfElements = $number; } @@ -69,7 +67,7 @@ public function setMinNumberOfElements($number) * @param string $attribute The name of the attribute which value is to be used as a key * @param bool $remove Whether or not to remove the key */ - public function setKeyAttribute($attribute, $remove = true) + public function setKeyAttribute(string $attribute, bool $remove = true) { $this->keyAttribute = $attribute; $this->removeKeyAttribute = $remove; @@ -87,17 +85,9 @@ public function getKeyAttribute() /** * Sets the default value of this node. - * - * @param string $value - * - * @throws \InvalidArgumentException if the default value is not an array */ - public function setDefaultValue($value) + public function setDefaultValue(array $value) { - if (!\is_array($value)) { - throw new \InvalidArgumentException($this->getPath().': the default value of an array node has to be an array.'); - } - $this->defaultValue = $value; } diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index 345e63e6cd61..28a3559ee46b 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -76,12 +76,8 @@ public function locate(string $name, string $currentPath = null, $first = true) /** * Returns whether the file path is an absolute path. - * - * @param string $file A file path - * - * @return bool */ - private function isAbsolutePath(string $file) + private function isAbsolutePath(string $file): bool { if ('/' === $file[0] || '\\' === $file[0] || (\strlen($file) > 3 && ctype_alpha($file[0]) diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index ab48492a4b21..f39d08111905 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -38,10 +38,8 @@ public function __construct(FileLocatorInterface $locator) /** * Sets the current directory. - * - * @param string $dir */ - public function setCurrentDir($dir) + public function setCurrentDir(string $dir) { $this->currentDir = $dir; } @@ -70,7 +68,7 @@ public function getLocator() * @throws FileLoaderImportCircularReferenceException * @throws FileLocatorFileNotFoundException */ - public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null) + public function import($resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null) { if (\is_string($resource) && \strlen($resource) !== $i = strcspn($resource, '*?{[')) { $ret = []; @@ -125,7 +123,7 @@ protected function glob(string $pattern, bool $recursive, &$resource = null, boo yield from $resource; } - private function doImport($resource, $type = null, bool $ignoreErrors = false, $sourceResource = null) + private function doImport($resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null) { try { $loader = $this->resolve($resource, $type); diff --git a/src/Symfony/Component/Config/Loader/Loader.php b/src/Symfony/Component/Config/Loader/Loader.php index 698ab40afbf3..62cae685e298 100644 --- a/src/Symfony/Component/Config/Loader/Loader.php +++ b/src/Symfony/Component/Config/Loader/Loader.php @@ -46,7 +46,7 @@ public function setResolver(LoaderResolverInterface $resolver) * * @return mixed */ - public function import($resource, $type = null) + public function import($resource, string $type = null) { return $this->resolve($resource, $type)->load($resource, $type); } @@ -61,7 +61,7 @@ public function import($resource, $type = null) * * @throws LoaderLoadException If no loader is found */ - public function resolve($resource, $type = null) + public function resolve($resource, string $type = null) { if ($this->supports($resource, $type)) { return $this; diff --git a/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php b/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php index fc1702f3cb89..a789644cae13 100644 --- a/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php +++ b/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php @@ -32,15 +32,11 @@ public function __construct(iterable $resourceCheckers = []) /** * {@inheritdoc} */ - public function cache(string $file, $callback) + public function cache(string $file, callable $callable) { - if (!\is_callable($callback)) { - throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback))); - } - $cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers); if (!$cache->isFresh()) { - $callback($cache); + $callable($cache); } return $cache; diff --git a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php index 24e3224ce5ba..a1dd169eca0e 100644 --- a/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php +++ b/src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php @@ -17,8 +17,7 @@ class ConfigCacheFactoryTest extends TestCase { /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid type for callback argument. Expected callable, but got "object". + * @expectedException \TypeError */ public function testCacheWithInvalidCallback() { diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php index 22b8b32fb6de..49209c9ba41d 100644 --- a/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php @@ -20,7 +20,7 @@ public function barNode($name) return $this->node($name, 'bar'); } - protected function getNodeClass($type) + protected function getNodeClass(string $type) { switch ($type) { case 'variable': diff --git a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php index 0b2e3fb6b9a5..ad6d7271a868 100644 --- a/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php @@ -98,12 +98,12 @@ class TestFileLoader extends FileLoader { private $supports = true; - public function load($resource, $type = null) + public function load($resource, string $type = null) { return $resource; } - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return $this->supports; } diff --git a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php index cd14d58fe5ea..9d43a2c4ef77 100644 --- a/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php +++ b/src/Symfony/Component/Config/Tests/Loader/LoaderTest.php @@ -103,11 +103,11 @@ public function testImportWithType() class ProjectLoader1 extends Loader { - public function load($resource, $type = null) + public function load($resource, string $type = null) { } - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return \is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION); } diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index cca11e7b92a3..60525faf1d8f 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($content, $schemaOrCallable = null) + public static function parse(string $content, $schemaOrCallable = null) { if (!\extension_loaded('dom')) { throw new \LogicException('Extension DOM is required.'); @@ -120,7 +120,7 @@ public static function parse($content, $schemaOrCallable = null) * @throws XmlParsingException When XML parsing returns any errors * @throws \RuntimeException When DOM extension is missing */ - public static function loadFile($file, $schemaOrCallable = null) + public static function loadFile(string $file, $schemaOrCallable = null) { $content = @file_get_contents($file); if ('' === trim($content)) { @@ -154,7 +154,7 @@ public static function loadFile($file, $schemaOrCallable = null) * * @return array A PHP array */ - public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true) + public static function convertDomElementToArray(\DOMElement $element, bool $checkPrefix = true) { $prefix = (string) $element->prefix; $empty = true; diff --git a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResourceChecker.php b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResourceChecker.php index 6ed77e3fd2c4..2f2affaa5b6c 100644 --- a/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResourceChecker.php +++ b/src/Symfony/Component/DependencyInjection/Config/ContainerParametersResourceChecker.php @@ -39,7 +39,7 @@ public function supports(ResourceInterface $metadata) /** * {@inheritdoc} */ - public function isFresh(ResourceInterface $resource, $timestamp) + public function isFresh(ResourceInterface $resource, int $timestamp) { foreach ($resource->getParameters() as $key => $value) { if (!$this->container->hasParameter($key) || $this->container->getParameter($key) !== $value) { diff --git a/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php b/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php index 939dd7cb7c4a..57aa83d6a0a7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php @@ -33,7 +33,7 @@ public function __construct(ContainerBuilder $container) /** * {@inheritdoc} */ - public function load($resource, $type = null) + public function load($resource, string $type = null) { $resource($this->container); } @@ -41,7 +41,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($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 a57cac3b5ee9..943986982e34 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, $type = null) + public function load($file, string $type = null) { $file = rtrim($file, '/'); $path = $this->locator->locate($file); @@ -43,7 +43,7 @@ public function load($file, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { if ('directory' === $type) { return true; diff --git a/src/Symfony/Component/DependencyInjection/Loader/GlobFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/GlobFileLoader.php index 4b25610efe48..53af9cf2b8a1 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, $type = null) + public function load($resource, string $type = null) { foreach ($this->glob($resource, false, $globResource) as $path => $info) { $this->import($path); @@ -33,7 +33,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($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 307a3eefbbe5..7d4423477f41 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, $type = null) + public function load($resource, string $type = null) { $path = $this->locator->locate($resource); @@ -49,7 +49,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($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 033798f6813f..efc593f06b71 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php @@ -51,7 +51,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($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 6368eb64c224..fd7a1fafc553 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -39,7 +39,7 @@ class XmlFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, $type = null) + public function load($resource, string $type = null) { $path = $this->locator->locate($resource); @@ -72,7 +72,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($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 f835fb5ce20c..336e0da5f25c 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -112,7 +112,7 @@ class YamlFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, $type = null) + public function load($resource, string $type = null) { $path = $this->locator->locate($resource); @@ -156,7 +156,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($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 b94ee1953fd7..ce9e4f0b9370 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php @@ -235,12 +235,12 @@ public function testRegisterClassesWithIncompatibleExclude() class TestFileLoader extends FileLoader { - public function load($resource, $type = null) + public function load($resource, string $type = null) { return $resource; } - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return false; } diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 351471e26a3c..893722f19f05 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "symfony/yaml": "^4.4|^5.0", - "symfony/config": "^4.4|^5.0", + "symfony/config": "^5.0", "symfony/expression-language": "^4.4|^5.0" }, "suggest": { @@ -33,7 +33,7 @@ "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them" }, "conflict": { - "symfony/config": "<4.4", + "symfony/config": "<5.0", "symfony/finder": "<4.4", "symfony/proxy-manager-bridge": "<4.4", "symfony/yaml": "<4.4" diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index d6dc923674e6..a654aef58247 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -94,7 +94,7 @@ public function setRouteAnnotationClass($class) * * @throws \InvalidArgumentException When route can't be parsed */ - public function load($class, $type = null) + public function load($class, string $type = null) { if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); diff --git a/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php index 3fb70ea20b43..7e52f3196fb3 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php @@ -32,7 +32,7 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader * * @throws \InvalidArgumentException When the directory does not exist or its routes cannot be parsed */ - public function load($path, $type = null) + public function load($path, string $type = null) { if (!is_dir($dir = $this->locator->locate($path))) { return parent::supports($path, $type) ? parent::load($path, $type) : new RouteCollection(); @@ -74,7 +74,7 @@ function (\SplFileInfo $current) { /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { if ('annotation' === $type) { return true; diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index a0965749696a..264ec28a0148 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -50,7 +50,7 @@ public function __construct(FileLocatorInterface $locator, AnnotationClassLoader * * @throws \InvalidArgumentException When the file does not exist or its routes cannot be parsed */ - public function load($file, $type = null) + public function load($file, string $type = null) { $path = $this->locator->locate($file); @@ -73,7 +73,7 @@ public function load($file, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type); } diff --git a/src/Symfony/Component/Routing/Loader/ClosureLoader.php b/src/Symfony/Component/Routing/Loader/ClosureLoader.php index 5df9f6ae8f17..cea5f9c1947d 100644 --- a/src/Symfony/Component/Routing/Loader/ClosureLoader.php +++ b/src/Symfony/Component/Routing/Loader/ClosureLoader.php @@ -31,7 +31,7 @@ class ClosureLoader extends Loader * * @return RouteCollection A RouteCollection instance */ - public function load($closure, $type = null) + public function load($closure, string $type = null) { return $closure(); } @@ -39,7 +39,7 @@ public function load($closure, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return $resource instanceof \Closure && (!$type || 'closure' === $type); } diff --git a/src/Symfony/Component/Routing/Loader/DirectoryLoader.php b/src/Symfony/Component/Routing/Loader/DirectoryLoader.php index 08e833e0a1ea..c0f349177475 100644 --- a/src/Symfony/Component/Routing/Loader/DirectoryLoader.php +++ b/src/Symfony/Component/Routing/Loader/DirectoryLoader.php @@ -20,7 +20,7 @@ class DirectoryLoader extends FileLoader /** * {@inheritdoc} */ - public function load($file, $type = null) + public function load($file, string $type = null) { $path = $this->locator->locate($file); @@ -49,7 +49,7 @@ public function load($file, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { // only when type is forced to directory, not to conflict with AnnotationLoader diff --git a/src/Symfony/Component/Routing/Loader/GlobFileLoader.php b/src/Symfony/Component/Routing/Loader/GlobFileLoader.php index 03ee341b9825..780fb15dc779 100644 --- a/src/Symfony/Component/Routing/Loader/GlobFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/GlobFileLoader.php @@ -24,7 +24,7 @@ class GlobFileLoader extends FileLoader /** * {@inheritdoc} */ - public function load($resource, $type = null) + public function load($resource, string $type = null) { $collection = new RouteCollection(); @@ -40,7 +40,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return 'glob' === $type; } diff --git a/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php b/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php index 2486536b25a6..d16a8bb218b3 100644 --- a/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php +++ b/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php @@ -42,7 +42,7 @@ abstract protected function getServiceObject($id); * * @return RouteCollection */ - public function load($resource, $type = null) + public function load($resource, string $type = null) { if (!preg_match('/^[^\:]+(?:::?(?:[^\:]+))?$/', $resource)) { throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service::method" or "service" if your service has an "__invoke" method.', $resource)); @@ -79,7 +79,7 @@ public function load($resource, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return 'service' === $type; } diff --git a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php index 1d1ae7dfcb84..7af543744eba 100644 --- a/src/Symfony/Component/Routing/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/PhpFileLoader.php @@ -33,7 +33,7 @@ class PhpFileLoader extends FileLoader * * @return RouteCollection A RouteCollection instance */ - public function load($file, $type = null) + public function load($file, string $type = null) { $path = $this->locator->locate($file); $this->setCurrentDir(\dirname($path)); @@ -61,7 +61,7 @@ public function load($file, $type = null) /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type); } diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 7a2cbb94b48f..d619be04d13d 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -39,7 +39,7 @@ class XmlFileLoader extends FileLoader * @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be * parsed because it does not validate against the scheme */ - public function load($file, $type = null) + public function load($file, string $type = null) { $path = $this->locator->locate($file); @@ -91,7 +91,7 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa /** * {@inheritdoc} */ - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return \is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type); } diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 6f2d04965a0c..f044418652e8 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -42,7 +42,7 @@ class YamlFileLoader extends FileLoader * * @throws \InvalidArgumentException When a route can't be parsed because YAML is invalid */ - public function load($file, $type = null) + public function load($file, string $type = null) { $path = $this->locator->locate($file); diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index eb39683d43b7..9cb239e4a505 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -19,7 +19,7 @@ "php": "^7.2.9" }, "require-dev": { - "symfony/config": "^4.4|^5.0", + "symfony/config": "^5.0", "symfony/http-foundation": "^4.4|^5.0", "symfony/yaml": "^4.4|^5.0", "symfony/expression-language": "^4.4|^5.0", @@ -28,7 +28,7 @@ "psr/log": "~1.0" }, "conflict": { - "symfony/config": "<4.4", + "symfony/config": "<5.0", "symfony/dependency-injection": "<4.4", "symfony/yaml": "<4.4" },