Skip to content
Permalink
Browse files

minor #32286 [Config] finish adding parameter types (Tobion)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[Config] finish adding parameter types

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yno
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #32179
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Completes some missing things in #32201

Commits
-------

2ca8354 [Config] finish adding parameter types
  • Loading branch information...
fabpot committed Jul 5, 2019
2 parents c1fe1fa + 2ca8354 commit bfabad4a3989d4f4db0350cb2b1916197cf5ba9a
Showing with 118 additions and 182 deletions.
  1. +3 −0 src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php
  2. +1 −1 src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php
  3. +1 −1 src/Symfony/Bundle/FrameworkBundle/composer.json
  4. +1 −5 src/Symfony/Component/Config/ConfigCacheFactory.php
  5. +1 −1 src/Symfony/Component/Config/ConfigCacheFactoryInterface.php
  6. +3 −3 src/Symfony/Component/Config/Definition/ArrayNode.php
  7. +13 −19 src/Symfony/Component/Config/Definition/BaseNode.php
  8. +14 −16 src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
  9. +1 −3 src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php
  10. +2 −6 src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php
  11. +10 −29 src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php
  12. +6 −13 src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
  13. +3 −3 src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php
  14. +1 −1 src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php
  15. +0 −2 src/Symfony/Component/Config/Definition/PrototypeNodeInterface.php
  16. +3 −13 src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
  17. +1 −5 src/Symfony/Component/Config/FileLocator.php
  18. +3 −5 src/Symfony/Component/Config/Loader/FileLoader.php
  19. +2 −2 src/Symfony/Component/Config/Loader/Loader.php
  20. +2 −6 src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php
  21. +1 −2 src/Symfony/Component/Config/Tests/ConfigCacheFactoryTest.php
  22. +1 −1 src/Symfony/Component/Config/Tests/Fixtures/Builder/NodeBuilder.php
  23. +2 −2 src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php
  24. +2 −2 src/Symfony/Component/Config/Tests/Loader/LoaderTest.php
  25. +3 −3 src/Symfony/Component/Config/Util/XmlUtils.php
  26. +1 −1 src/Symfony/Component/DependencyInjection/Config/ContainerParametersResourceChecker.php
  27. +2 −2 src/Symfony/Component/DependencyInjection/Loader/ClosureLoader.php
  28. +2 −2 src/Symfony/Component/DependencyInjection/Loader/DirectoryLoader.php
  29. +2 −2 src/Symfony/Component/DependencyInjection/Loader/GlobFileLoader.php
  30. +2 −2 src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php
  31. +1 −1 src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php
  32. +2 −2 src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
  33. +2 −2 src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
  34. +2 −2 src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php
  35. +2 −2 src/Symfony/Component/DependencyInjection/composer.json
  36. +1 −1 src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php
  37. +2 −2 src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php
  38. +2 −2 src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php
  39. +2 −2 src/Symfony/Component/Routing/Loader/ClosureLoader.php
  40. +2 −2 src/Symfony/Component/Routing/Loader/DirectoryLoader.php
  41. +2 −2 src/Symfony/Component/Routing/Loader/GlobFileLoader.php
  42. +2 −2 src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php
  43. +2 −2 src/Symfony/Component/Routing/Loader/PhpFileLoader.php
  44. +2 −2 src/Symfony/Component/Routing/Loader/XmlFileLoader.php
  45. +1 −1 src/Symfony/Component/Routing/Loader/YamlFileLoader.php
  46. +2 −2 src/Symfony/Component/Routing/composer.json
@@ -52,6 +52,9 @@ protected function listBundles($output)
}
}
/**
* @return ExtensionInterface
*/
protected function findExtension($name)
{
$bundles = $this->initializeBundles();
@@ -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().
@@ -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",
@@ -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);
@@ -28,5 +28,5 @@ interface ConfigCacheFactoryInterface
*
* @return ConfigCacheInterface The cache instance
*/
public function cache(string $file, $callable);
public function cache(string $file, callable $callable);
}
@@ -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;
@@ -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,32 +181,28 @@ 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;
}
/**
* Sets this node as deprecated.
*
* 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 @@ public function getPath()
/**
* 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)
{
@@ -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);
}
@@ -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))); };
@@ -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;

0 comments on commit bfabad4

Please sign in to comment.
You can’t perform that action at this time.