diff --git a/src/Symfony/Component/DependencyInjection/Alias.php b/src/Symfony/Component/DependencyInjection/Alias.php index 3e74fd92c830..79e7e243471c 100644 --- a/src/Symfony/Component/DependencyInjection/Alias.php +++ b/src/Symfony/Component/DependencyInjection/Alias.php @@ -44,13 +44,11 @@ public function isPublic() /** * Sets if this Alias is public. * - * @param bool $boolean If this Alias should be public - * * @return $this */ - public function setPublic($boolean) + public function setPublic(bool $boolean) { - $this->public = (bool) $boolean; + $this->public = $boolean; $this->private = false; return $this; @@ -64,13 +62,11 @@ public function setPublic($boolean) * but triggers a deprecation notice when accessed from the container, * so that the alias can be made really private in 4.0. * - * @param bool $boolean - * * @return $this */ - public function setPrivate($boolean) + public function setPrivate(bool $boolean) { - $this->private = (bool) $boolean; + $this->private = $boolean; return $this; } @@ -96,7 +92,7 @@ public function isPrivate() * * @throws InvalidArgumentException when the message template is invalid */ - public function setDeprecated($status = true, $template = null) + public function setDeprecated(bool $status = true, string $template = null) { if (null !== $template) { if (preg_match('#[\r\n]|\*/#', $template)) { @@ -110,7 +106,7 @@ public function setDeprecated($status = true, $template = null) $this->deprecationTemplate = $template; } - $this->deprecated = (bool) $status; + $this->deprecated = $status; return $this; } diff --git a/src/Symfony/Component/DependencyInjection/ChildDefinition.php b/src/Symfony/Component/DependencyInjection/ChildDefinition.php index f80fa3e8e3e7..a0c503536ba7 100644 --- a/src/Symfony/Component/DependencyInjection/ChildDefinition.php +++ b/src/Symfony/Component/DependencyInjection/ChildDefinition.php @@ -109,7 +109,7 @@ public function replaceArgument($index, $value) /** * @internal */ - public function setAutoconfigured($autoconfigured) + public function setAutoconfigured(bool $autoconfigured) { throw new BadMethodCallException('A ChildDefinition cannot be autoconfigured.'); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php index 76e6d35a795d..a7f1ee47efc5 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php @@ -167,7 +167,7 @@ public function __construct(ExtensionInterface $extension, ParameterBagInterface /** * {@inheritdoc} */ - public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) + public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) { throw new LogicException(sprintf('You cannot add compiler pass "%s" from extension "%s". Compiler passes must be registered before the container is compiled.', \get_class($pass), $this->extensionClass)); } diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 75f8c1dcffee..539c1a04bf8d 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -107,7 +107,7 @@ public function getParameterBag() * * @throws InvalidArgumentException if the parameter is not defined */ - public function getParameter($name) + public function getParameter(string $name) { return $this->parameterBag->get($name); } @@ -119,7 +119,7 @@ public function getParameter($name) * * @return bool The presence of parameter in container */ - public function hasParameter($name) + public function hasParameter(string $name) { return $this->parameterBag->has($name); } @@ -130,7 +130,7 @@ public function hasParameter($name) * @param string $name The parameter name * @param mixed $value The parameter value */ - public function setParameter($name, $value) + public function setParameter(string $name, $value) { $this->parameterBag->set($name, $value); } @@ -141,10 +141,9 @@ public function setParameter($name, $value) * Setting a synthetic service to null resets it: has() returns false and get() * behaves in the same way as if the service was never created. * - * @param string $id The service identifier * @param object $service The service instance */ - public function set($id, $service) + public function set(string $id, $service) { // Runs the internal initializer; used by the dumped container to include always-needed files if (isset($this->privates['service_container']) && $this->privates['service_container'] instanceof \Closure) { @@ -218,7 +217,7 @@ public function has($id) * * @see Reference */ - public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1) + public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1) { return $this->services[$id] ?? $this->services[$id = $this->aliases[$id] ?? $id] @@ -285,7 +284,7 @@ private function make(string $id, int $invalidBehavior) * * @return bool true if service has already been initialized, false otherwise */ - public function initialized($id) + public function initialized(string $id) { if (isset($this->aliases[$id])) { $id = $this->aliases[$id]; diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 8b13b4d7ada4..4163b3349cfc 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -160,12 +160,10 @@ public function __construct(ParameterBagInterface $parameterBag = null) * * If you are not using the loaders and therefore don't want * to depend on the Config component, set this flag to false. - * - * @param bool $track True if you want to track resources, false otherwise */ - public function setResourceTracking($track) + public function setResourceTracking(bool $track) { - $this->trackResources = (bool) $track; + $this->trackResources = $track; } /** @@ -198,13 +196,11 @@ public function registerExtension(ExtensionInterface $extension) /** * Returns an extension by alias or namespace. * - * @param string $name An alias or a namespace - * * @return ExtensionInterface An extension instance * * @throws LogicException if the extension is not registered */ - public function getExtension($name) + public function getExtension(string $name) { if (isset($this->extensions[$name])) { return $this->extensions[$name]; @@ -230,11 +226,9 @@ public function getExtensions() /** * Checks if we have an extension. * - * @param string $name The name of the extension - * * @return bool If the extension exists */ - public function hasExtension($name) + public function hasExtension(string $name) { return isset($this->extensions[$name]) || isset($this->extensionsByNs[$name]); } @@ -424,7 +418,7 @@ public function fileExists(string $path, $trackContents = true): bool * @throws BadMethodCallException When this ContainerBuilder is compiled * @throws \LogicException if the extension is not registered */ - public function loadFromExtension($extension, array $values = null) + public function loadFromExtension(string $extension, array $values = null) { if ($this->isCompiled()) { throw new BadMethodCallException('Cannot load from an extension on a compiled container.'); @@ -450,7 +444,7 @@ public function loadFromExtension($extension, array $values = null) * * @return $this */ - public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) + public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0) { $this->getCompiler()->addPass($pass, $type, $priority); @@ -486,15 +480,12 @@ public function getCompiler() /** * Sets a service. * - * @param string $id The service identifier * @param object $service The service instance * * @throws BadMethodCallException When this ContainerBuilder is compiled */ - public function set($id, $service) + public function set(string $id, $service) { - $id = (string) $id; - if ($this->isCompiled() && (isset($this->definitions[$id]) && !$this->definitions[$id]->isSynthetic())) { // setting a synthetic service on a compiled container is alright throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id)); @@ -507,12 +498,10 @@ public function set($id, $service) /** * Removes a service definition. - * - * @param string $id The service identifier */ - public function removeDefinition($id) + public function removeDefinition(string $id) { - if (isset($this->definitions[$id = (string) $id])) { + if (isset($this->definitions[$id])) { unset($this->definitions[$id]); $this->removedIds[$id] = true; } @@ -547,7 +536,7 @@ public function has($id) * * @see Reference */ - public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) + public function get($id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { if ($this->isCompiled() && isset($this->removedIds[$id = (string) $id]) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $invalidBehavior) { return parent::get($id); @@ -556,7 +545,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV return $this->doGet($id, $invalidBehavior); } - private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, array &$inlineServices = null, $isConstructorArgument = false) + private function doGet(string $id, int $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, array &$inlineServices = null, bool $isConstructorArgument = false) { if (isset($inlineServices[$id])) { return $inlineServices[$id]; @@ -689,11 +678,9 @@ public function merge(self $container) /** * Returns the configuration array for the given extension. * - * @param string $name The name of the extension - * * @return array An array of configuration */ - public function getExtensionConfig($name) + public function getExtensionConfig(string $name) { if (!isset($this->extensionConfigs[$name])) { $this->extensionConfigs[$name] = []; @@ -704,11 +691,8 @@ public function getExtensionConfig($name) /** * Prepends a config array to the configs of the given extension. - * - * @param string $name The name of the extension - * @param array $config The config to set */ - public function prependExtensionConfig($name, array $config) + public function prependExtensionConfig(string $name, array $config) { if (!isset($this->extensionConfigs[$name])) { $this->extensionConfigs[$name] = []; @@ -828,10 +812,8 @@ public function setAliases(array $aliases) * @throws InvalidArgumentException if the id is not a string or an Alias * @throws InvalidArgumentException if the alias is for itself */ - public function setAlias($alias, $id) + public function setAlias(string $alias, $id) { - $alias = (string) $alias; - if ('' === $alias || '\\' === $alias[-1] || \strlen($alias) !== strcspn($alias, "\0\r\n'")) { throw new InvalidArgumentException(sprintf('Invalid alias id: "%s"', $alias)); } @@ -856,9 +838,9 @@ public function setAlias($alias, $id) * * @param string $alias The alias to remove */ - public function removeAlias($alias) + public function removeAlias(string $alias) { - if (isset($this->aliasDefinitions[$alias = (string) $alias])) { + if (isset($this->aliasDefinitions[$alias])) { unset($this->aliasDefinitions[$alias]); $this->removedIds[$alias] = true; } @@ -867,13 +849,11 @@ public function removeAlias($alias) /** * Returns true if an alias exists under the given identifier. * - * @param string $id The service identifier - * * @return bool true if the alias exists, false otherwise */ - public function hasAlias($id) + public function hasAlias(string $id) { - return isset($this->aliasDefinitions[$id = (string) $id]); + return isset($this->aliasDefinitions[$id]); } /** @@ -889,16 +869,12 @@ public function getAliases() /** * Gets an alias. * - * @param string $id The service identifier - * * @return Alias An Alias instance * * @throws InvalidArgumentException if the alias does not exist */ - public function getAlias($id) + public function getAlias(string $id) { - $id = (string) $id; - if (!isset($this->aliasDefinitions[$id])) { throw new InvalidArgumentException(sprintf('The service alias "%s" does not exist.', $id)); } @@ -912,12 +888,9 @@ public function getAlias($id) * This methods allows for simple registration of service definition * with a fluid interface. * - * @param string $id The service identifier - * @param string $class|null The service class - * * @return Definition A Definition instance */ - public function register($id, $class = null) + public function register(string $id, string $class = null) { return $this->setDefinition($id, new Definition($class)); } @@ -928,12 +901,9 @@ public function register($id, $class = null) * This method implements a shortcut for using setDefinition() with * an autowired definition. * - * @param string $id The service identifier - * @param string|null $class The service class - * * @return Definition The created definition */ - public function autowire($id, $class = null) + public function autowire(string $id, string $class = null) { return $this->setDefinition($id, (new Definition($class))->setAutowired(true)); } @@ -974,21 +944,16 @@ public function getDefinitions() /** * Sets a service definition. * - * @param string $id The service identifier - * @param Definition $definition A Definition instance - * * @return Definition the service definition * * @throws BadMethodCallException When this ContainerBuilder is compiled */ - public function setDefinition($id, Definition $definition) + public function setDefinition(string $id, Definition $definition) { if ($this->isCompiled()) { throw new BadMethodCallException('Adding definition to a compiled container is not allowed'); } - $id = (string) $id; - if ('' === $id || '\\' === $id[-1] || \strlen($id) !== strcspn($id, "\0\r\n'")) { throw new InvalidArgumentException(sprintf('Invalid service id: "%s"', $id)); } @@ -1001,28 +966,22 @@ public function setDefinition($id, Definition $definition) /** * Returns true if a service definition exists under the given identifier. * - * @param string $id The service identifier - * * @return bool true if the service definition exists, false otherwise */ - public function hasDefinition($id) + public function hasDefinition(string $id) { - return isset($this->definitions[(string) $id]); + return isset($this->definitions[$id]); } /** * Gets a service definition. * - * @param string $id The service identifier - * * @return Definition A Definition instance * * @throws ServiceNotFoundException if the service definition does not exist */ - public function getDefinition($id) + public function getDefinition(string $id) { - $id = (string) $id; - if (!isset($this->definitions[$id])) { throw new ServiceNotFoundException($id); } @@ -1035,16 +994,12 @@ public function getDefinition($id) * * The method "unaliases" recursively to return a Definition instance. * - * @param string $id The service identifier or alias - * * @return Definition A Definition instance * * @throws ServiceNotFoundException if the service definition does not exist */ - public function findDefinition($id) + public function findDefinition(string $id) { - $id = (string) $id; - $seen = []; while (isset($this->aliasDefinitions[$id])) { $id = (string) $this->aliasDefinitions[$id]; @@ -1066,9 +1021,7 @@ public function findDefinition($id) /** * Creates a service for a service definition. * - * @param Definition $definition A service definition instance - * @param string $id The service identifier - * @param bool $tryProxy Whether to try proxying the service with a lazy proxy + * @param bool $tryProxy Whether to try proxying the service with a lazy proxy * * @return object The service described by the service definition * @@ -1076,7 +1029,7 @@ public function findDefinition($id) * @throws RuntimeException When the service is a synthetic service * @throws InvalidArgumentException When configure callable is not callable */ - private function createService(Definition $definition, array &$inlineServices, $isConstructorArgument = false, $id = null, $tryProxy = true) + private function createService(Definition $definition, array &$inlineServices, $isConstructorArgument = false, string $id = null, bool $tryProxy = true) { if (null === $id && isset($inlineServices[$h = spl_object_hash($definition)])) { return $inlineServices[$h]; @@ -1207,7 +1160,7 @@ public function resolveServices($value) return $this->doResolveServices($value); } - private function doResolveServices($value, array &$inlineServices = [], $isConstructorArgument = false) + private function doResolveServices($value, array &$inlineServices = [], bool $isConstructorArgument = false) { if (\is_array($value)) { foreach ($value as $k => $v) { @@ -1289,12 +1242,9 @@ private function doResolveServices($value, array &$inlineServices = [], $isConst * } * } * - * @param string $name - * @param bool $throwOnAbstract - * * @return array An array of tags with the tagged service as key, holding a list of attribute arrays */ - public function findTaggedServiceIds($name, $throwOnAbstract = false) + public function findTaggedServiceIds(string $name, bool $throwOnAbstract = false) { $this->usedTags[] = $name; $tags = []; @@ -1351,11 +1301,9 @@ public function getExpressionLanguageProviders() /** * Returns a ChildDefinition that will be used for autoconfiguring the interface/class. * - * @param string $interface The class or interface to match - * * @return ChildDefinition */ - public function registerForAutoconfiguration($interface) + public function registerForAutoconfiguration(string $interface) { if (!isset($this->autoconfiguredInstanceof[$interface])) { $this->autoconfiguredInstanceof[$interface] = new ChildDefinition(''); @@ -1506,11 +1454,9 @@ public function getRemovedBindingIds() /** * Removes bindings for a service. * - * @param string $id The service identifier - * * @internal */ - public function removeBindings($id) + public function removeBindings(string $id) { if ($this->hasDefinition($id)) { foreach ($this->getDefinition($id)->getBindings() as $key => $binding) { @@ -1635,11 +1581,9 @@ private function callMethod($service, $call, array &$inlineServices) /** * Shares a given service in the container. * - * @param Definition $definition - * @param object $service - * @param string|null $id + * @param object $service */ - private function shareService(Definition $definition, $service, $id, array &$inlineServices) + private function shareService(Definition $definition, $service, ?string $id, array &$inlineServices) { $inlineServices[null !== $id ? $id : spl_object_hash($definition)] = $service; @@ -1661,7 +1605,7 @@ private function getExpressionLanguage() return $this->expressionLanguage; } - private function inVendors($path) + private function inVendors(string $path) { if (null === $this->vendors) { $resource = new ComposerResource(); diff --git a/src/Symfony/Component/DependencyInjection/ContainerInterface.php b/src/Symfony/Component/DependencyInjection/ContainerInterface.php index f859b020314e..3d5bc66a28c9 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerInterface.php @@ -33,10 +33,9 @@ interface ContainerInterface extends PsrContainerInterface /** * Sets a service. * - * @param string $id The service identifier * @param object $service The service instance */ - public function set($id, $service); + public function set(string $id, $service); /** * Gets a service. @@ -51,7 +50,7 @@ public function set($id, $service); * * @see Reference */ - public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); + public function get($id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE); /** * Returns true if the given service is defined. @@ -65,11 +64,9 @@ public function has($id); /** * Check for whether or not a service has been initialized. * - * @param string $id - * * @return bool true if the service has been initialized, false otherwise */ - public function initialized($id); + public function initialized(string $id); /** * Gets a parameter. @@ -80,7 +77,7 @@ public function initialized($id); * * @throws InvalidArgumentException if the parameter is not defined */ - public function getParameter($name); + public function getParameter(string $name); /** * Checks if a parameter exists. @@ -89,7 +86,7 @@ public function getParameter($name); * * @return bool The presence of parameter in container */ - public function hasParameter($name); + public function hasParameter(string $name); /** * Sets a parameter. @@ -97,5 +94,5 @@ public function hasParameter($name); * @param string $name The parameter name * @param mixed $value The parameter value */ - public function setParameter($name, $value); + public function setParameter(string $name, $value); } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 9b39379ad0e9..67b78ceaffcc 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -56,11 +56,7 @@ class Definition */ public $innerServiceId; - /** - * @param string|null $class The service class - * @param array $arguments An array of arguments to pass to the service constructor - */ - public function __construct($class = null, array $arguments = []) + public function __construct(string $class = null, array $arguments = []) { if (null !== $class) { $this->setClass($class); @@ -135,7 +131,7 @@ public function getFactory() * * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals */ - public function setDecoratedService($id, $renamedId = null, $priority = 0) + public function setDecoratedService(?string $id, ?string $renamedId = null, int $priority = 0) { if ($renamedId && $id === $renamedId) { throw new InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id)); @@ -165,19 +161,10 @@ public function getDecoratedService() /** * Sets the service class. * - * @param string $class The service class - * * @return $this */ - public function setClass($class) + public function setClass(?string $class) { - if ($class instanceof Parameter) { - @trigger_error(sprintf('Passing an instance of %s as class name to %s in deprecated in Symfony 4.4 and will result in a TypeError in 5.0. Please pass the string "%%%s%%" instead.', Parameter::class, __CLASS__, (string) $class), E_USER_DEPRECATED); - } - if (null !== $class && !\is_string($class)) { - @trigger_error(sprintf('The class name passed to %s is expected to be a string. Passing a %s is deprecated in Symfony 4.4 and will result in a TypeError in 5.0.', __CLASS__, \is_object($class) ? \get_class($class) : \gettype($class)), E_USER_DEPRECATED); - } - $this->changes['class'] = true; $this->class = $class; @@ -232,12 +219,11 @@ public function getProperties() /** * Sets a specific property. * - * @param string $name - * @param mixed $value + * @param mixed $value * * @return $this */ - public function setProperty($name, $value) + public function setProperty(string $name, $value) { $this->properties[$name] = $value; @@ -356,7 +342,7 @@ public function setMethodCalls(array $calls = []) * * @throws InvalidArgumentException on empty $method param */ - public function addMethodCall($method, array $arguments = [], bool $returnsClone = false) + public function addMethodCall(string $method, array $arguments = [], bool $returnsClone = false) { if (empty($method)) { throw new InvalidArgumentException('Method name cannot be empty.'); @@ -369,11 +355,9 @@ public function addMethodCall($method, array $arguments = [], bool $returnsClone /** * Removes a method to call after service initialization. * - * @param string $method The method name to remove - * * @return $this */ - public function removeMethodCall($method) + public function removeMethodCall(string $method) { foreach ($this->calls as $i => $call) { if ($call[0] === $method) { @@ -388,11 +372,9 @@ public function removeMethodCall($method) /** * Check if the current definition has a given method to call after service initialization. * - * @param string $method The method name to search for - * * @return bool */ - public function hasMethodCall($method) + public function hasMethodCall(string $method) { foreach ($this->calls as $call) { if ($call[0] === $method) { @@ -444,7 +426,7 @@ public function getInstanceofConditionals() * * @return $this */ - public function setAutoconfigured($autoconfigured) + public function setAutoconfigured(bool $autoconfigured) { $this->changes['autoconfigured'] = true; @@ -486,11 +468,9 @@ public function getTags() /** * Gets a tag by name. * - * @param string $name The tag name - * * @return array An array of attributes */ - public function getTag($name) + public function getTag(string $name) { return isset($this->tags[$name]) ? $this->tags[$name] : []; } @@ -498,12 +478,9 @@ public function getTag($name) /** * Adds a tag for this definition. * - * @param string $name The tag name - * @param array $attributes An array of attributes - * * @return $this */ - public function addTag($name, array $attributes = []) + public function addTag(string $name, array $attributes = []) { $this->tags[$name][] = $attributes; @@ -513,11 +490,9 @@ public function addTag($name, array $attributes = []) /** * Whether this definition has a tag with the given name. * - * @param string $name - * * @return bool */ - public function hasTag($name) + public function hasTag(string $name) { return isset($this->tags[$name]); } @@ -525,11 +500,9 @@ public function hasTag($name) /** * Clears all tags for a given name. * - * @param string $name The tag name - * * @return $this */ - public function clearTag($name) + public function clearTag(string $name) { unset($this->tags[$name]); @@ -551,11 +524,9 @@ public function clearTags() /** * Sets a file to require before creating the service. * - * @param string $file A full pathname to include - * * @return $this */ - public function setFile($file) + public function setFile(?string $file) { $this->changes['file'] = true; @@ -577,15 +548,13 @@ public function getFile() /** * Sets if the service must be shared or not. * - * @param bool $shared Whether the service must be shared or not - * * @return $this */ - public function setShared($shared) + public function setShared(bool $shared) { $this->changes['shared'] = true; - $this->shared = (bool) $shared; + $this->shared = $shared; return $this; } @@ -603,15 +572,13 @@ public function isShared() /** * Sets the visibility of this service. * - * @param bool $boolean - * * @return $this */ - public function setPublic($boolean) + public function setPublic(bool $boolean) { $this->changes['public'] = true; - $this->public = (bool) $boolean; + $this->public = $boolean; $this->private = false; return $this; @@ -635,13 +602,11 @@ public function isPublic() * but triggers a deprecation notice when accessed from the container, * so that the service can be made really private in 4.0. * - * @param bool $boolean - * * @return $this */ - public function setPrivate($boolean) + public function setPrivate(bool $boolean) { - $this->private = (bool) $boolean; + $this->private = $boolean; return $this; } @@ -659,15 +624,13 @@ public function isPrivate() /** * Sets the lazy flag of this service. * - * @param bool $lazy - * * @return $this */ - public function setLazy($lazy) + public function setLazy(bool $lazy) { $this->changes['lazy'] = true; - $this->lazy = (bool) $lazy; + $this->lazy = $lazy; return $this; } @@ -686,13 +649,11 @@ public function isLazy() * Sets whether this definition is synthetic, that is not constructed by the * container, but dynamically injected. * - * @param bool $boolean - * * @return $this */ - public function setSynthetic($boolean) + public function setSynthetic(bool $boolean) { - $this->synthetic = (bool) $boolean; + $this->synthetic = $boolean; return $this; } @@ -712,13 +673,11 @@ public function isSynthetic() * Whether this definition is abstract, that means it merely serves as a * template for other definitions. * - * @param bool $boolean - * * @return $this */ - public function setAbstract($boolean) + public function setAbstract(bool $boolean) { - $this->abstract = (bool) $boolean; + $this->abstract = $boolean; return $this; } @@ -738,14 +697,13 @@ public function isAbstract() * Whether this definition is deprecated, that means it should not be called * anymore. * - * @param bool $status * @param string $template Template message to use if the definition is deprecated * * @return $this * * @throws InvalidArgumentException when the message template is invalid */ - public function setDeprecated($status = true, $template = null) + public function setDeprecated(bool $status = true, string $template = null) { if (null !== $template) { if (preg_match('#[\r\n]|\*/#', $template)) { @@ -761,7 +719,7 @@ public function setDeprecated($status = true, $template = null) $this->changes['deprecated'] = true; - $this->deprecated = (bool) $status; + $this->deprecated = $status; return $this; } @@ -784,7 +742,7 @@ public function isDeprecated() * * @return string */ - public function getDeprecationMessage($id) + public function getDeprecationMessage(string $id) { return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate); } @@ -834,15 +792,13 @@ public function isAutowired() /** * Enables/disables autowiring. * - * @param bool $autowired - * * @return $this */ - public function setAutowired($autowired) + public function setAutowired(bool $autowired) { $this->changes['autowired'] = true; - $this->autowired = (bool) $autowired; + $this->autowired = $autowired; return $this; } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index d643402edfb2..acbbe395fc21 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -18,6 +18,7 @@ use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass; use Symfony\Component\DependencyInjection\Compiler\CheckCircularReferencesPass; +use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphEdge; use Symfony\Component\DependencyInjection\Compiler\ServiceReferenceGraphNode; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -339,7 +340,10 @@ private function getProxyDumper(): ProxyDumper return $this->proxyDumper; } - private function analyzeCircularReferences($sourceId, array $edges, &$checkedNodes, &$currentPath = []) + /** + * @param ServiceReferenceGraphEdge[] $edges + */ + private function analyzeCircularReferences(string $sourceId, array $edges, array &$checkedNodes, array &$currentPath = []) { $checkedNodes[$sourceId] = true; $currentPath[$sourceId] = $sourceId; @@ -368,7 +372,7 @@ private function analyzeCircularReferences($sourceId, array $edges, &$checkedNod unset($currentPath[$sourceId]); } - private function connectCircularReferences($sourceId, &$currentPath, &$subPath = []) + private function connectCircularReferences(string $sourceId, array &$currentPath, array &$subPath = []) { $subPath[$sourceId] = $sourceId; $currentPath[$sourceId] = $sourceId; @@ -391,7 +395,7 @@ private function connectCircularReferences($sourceId, &$currentPath, &$subPath = unset($subPath[$sourceId]); } - private function collectLineage($class, array &$lineage) + private function collectLineage(string $class, array &$lineage) { if (isset($lineage[$class])) { return; @@ -1284,9 +1288,8 @@ private function addDefaultParametersMethod(): string $code = <<<'EOF' - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; if (isset($this->buildParameters[$name])) { return $this->buildParameters[$name]; } @@ -1301,9 +1304,8 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; if (isset($this->buildParameters[$name])) { return true; } @@ -1311,7 +1313,7 @@ public function hasParameter($name) return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } @@ -1334,7 +1336,7 @@ public function getParameterBag() EOF; if (!$this->asFiles) { - $code = preg_replace('/^.*buildParameters.*\n.*\n.*\n/m', '', $code); + $code = preg_replace('/^.*buildParameters.*\n.*\n.*\n\n?/m', '', $code); } if ($dynamicPhp) { @@ -1891,7 +1893,7 @@ private function export($value) return $this->doExport($value, true); } - private function doExport($value, $resolveEnv = false) + private function doExport($value, bool $resolveEnv = false) { $shouldCacheValue = $resolveEnv && \is_string($value); if ($shouldCacheValue && isset($this->exportedVariables[$value])) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index ca7bb60a9bf6..089c82735cbc 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -93,12 +93,8 @@ private function addMethodCalls(array $methodcalls, \DOMElement $parent) /** * Adds a service. - * - * @param Definition $definition - * @param string $id - * @param \DOMElement $parent */ - private function addService($definition, $id, \DOMElement $parent) + private function addService(Definition $definition, ?string $id, \DOMElement $parent) { $service = $this->document->createElement('service'); if (null !== $id) { @@ -217,12 +213,8 @@ private function addService($definition, $id, \DOMElement $parent) /** * Adds a service alias. - * - * @param string $alias - * @param Alias $id - * @param \DOMElement $parent */ - private function addServiceAlias($alias, Alias $id, \DOMElement $parent) + private function addServiceAlias(string $alias, Alias $id, \DOMElement $parent) { $service = $this->document->createElement('service'); $service->setAttribute('id', $alias); @@ -265,13 +257,8 @@ private function addServices(\DOMElement $parent) /** * Converts parameters. - * - * @param array $parameters - * @param string $type - * @param \DOMElement $parent - * @param string $keyAttribute */ - private function convertParameters(array $parameters, $type, \DOMElement $parent, $keyAttribute = 'key') + private function convertParameters(array $parameters, string $type, \DOMElement $parent, string $keyAttribute = 'key') { $withKeys = array_keys($parameters) !== range(0, \count($parameters) - 1); foreach ($parameters as $key => $value) { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index cb89bb1758e0..5e411b8d8243 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -303,7 +303,7 @@ private function getParameterCall(string $id): string return sprintf('%%%s%%', $id); } - private function getExpressionCall($expression) + private function getExpressionCall(string $expression) { return sprintf('@=%s', $expression); } diff --git a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php index 568c91d4f69b..dffd64255401 100644 --- a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php +++ b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php @@ -54,7 +54,7 @@ public static function getProvidedTypes() /** * {@inheritdoc} */ - public function getEnv($prefix, $name, \Closure $getEnv) + public function getEnv(string $prefix, string $name, \Closure $getEnv) { $i = strpos($name, ':'); diff --git a/src/Symfony/Component/DependencyInjection/EnvVarProcessorInterface.php b/src/Symfony/Component/DependencyInjection/EnvVarProcessorInterface.php index 654fe55e982f..d3275fe290e3 100644 --- a/src/Symfony/Component/DependencyInjection/EnvVarProcessorInterface.php +++ b/src/Symfony/Component/DependencyInjection/EnvVarProcessorInterface.php @@ -31,7 +31,7 @@ interface EnvVarProcessorInterface * * @throws RuntimeException on error */ - public function getEnv($prefix, $name, \Closure $getEnv); + public function getEnv(string $prefix, string $name, \Closure $getEnv); /** * @return string[] The PHP-types managed by getEnv(), keyed by prefixes diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/BindTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/BindTrait.php index a7f76d248c53..b9ff1bb5757d 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/BindTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/BindTrait.php @@ -31,7 +31,7 @@ trait BindTrait * * @return $this */ - final public function bind($nameOrFqcn, $valueOrRef): object + final public function bind(string $nameOrFqcn, $valueOrRef): object { $valueOrRef = static::processValue($valueOrRef, true); if (!preg_match('/^(?:(?:array|bool|float|int|string)[ \t]*+)?\$/', $nameOrFqcn) && !$valueOrRef instanceof Reference) { diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/CallTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/CallTrait.php index 3f800cdc2beb..cd491ee87d1c 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/CallTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/CallTrait.php @@ -25,7 +25,7 @@ trait CallTrait * * @throws InvalidArgumentException on empty $method param */ - final public function call($method, array $arguments = []): object + final public function call(string $method, array $arguments = []): object { $this->definition->addMethodCall($method, static::processValue($arguments, true)); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php index 18679e68ead4..8c1c8542009a 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ClassTrait.php @@ -18,7 +18,7 @@ trait ClassTrait * * @return $this */ - final public function class($class): object + final public function class(?string $class): object { $this->definition->setClass($class); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DecorateTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DecorateTrait.php index 2fe364a4c69b..ddb8e07e6074 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DecorateTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DecorateTrait.php @@ -26,7 +26,7 @@ trait DecorateTrait * * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals */ - final public function decorate($id, $renamedId = null, $priority = 0): object + final public function decorate(?string $id, ?string $renamedId = null, int $priority = 0): object { $this->definition->setDecoratedService($id, $renamedId, $priority); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DeprecateTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DeprecateTrait.php index b4598a48d6fe..496286223e37 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DeprecateTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/DeprecateTrait.php @@ -24,7 +24,7 @@ trait DeprecateTrait * * @throws InvalidArgumentException when the message template is invalid */ - final public function deprecate($template = null): object + final public function deprecate(string $template = null): object { $this->definition->setDeprecated(true, $template); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FileTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FileTrait.php index f55d7582ae6d..322684da8ebb 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FileTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FileTrait.php @@ -16,11 +16,9 @@ trait FileTrait /** * Sets a file to require before creating the service. * - * @param string $file A full pathname to include - * * @return $this */ - final public function file($file): object + final public function file(string $file): object { $this->definition->setFile($file); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ShareTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ShareTrait.php index 4e844bb75722..520d17bc73a0 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ShareTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/ShareTrait.php @@ -16,11 +16,9 @@ trait ShareTrait /** * Sets if the service must be shared or not. * - * @param bool $shared Whether the service must be shared or not - * * @return $this */ - final public function share($shared = true): object + final public function share(bool $shared = true): object { $this->definition->setShared($shared); diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php index 46493fcd0779..e35960509108 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/TagTrait.php @@ -18,12 +18,9 @@ trait TagTrait /** * Adds a tag for this definition. * - * @param string $name The tag name - * @param array $attributes An array of attributes - * * @return $this */ - final public function tag($name, array $attributes = []): object + final public function tag(string $name, array $attributes = []): object { if (!\is_string($name) || '' === $name) { throw new InvalidArgumentException(sprintf('The tag name for service "%s" must be a non-empty string.', $this->id)); diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php index 543e871fe530..b4a70537276a 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php @@ -27,7 +27,7 @@ class EnvPlaceholderParameterBag extends ParameterBag /** * {@inheritdoc} */ - public function get($name) + public function get(string $name) { if (0 === strpos($name, 'env(') && ')' === substr($name, -1) && 'env()' !== $name) { $env = substr($name, 4, -1); diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php index a5199937e233..5a4aaf8b2a43 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/FrozenParameterBag.php @@ -53,7 +53,7 @@ public function add(array $parameters) /** * {@inheritdoc} */ - public function set($name, $value) + public function set(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } @@ -61,7 +61,7 @@ public function set($name, $value) /** * {@inheritdoc} */ - public function remove($name) + public function remove(string $name) { throw new LogicException('Impossible to call remove() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 988dbf88cca6..e9b70c0d0d3f 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -64,10 +64,8 @@ public function all() /** * {@inheritdoc} */ - public function get($name) + public function get(string $name) { - $name = (string) $name; - if (!\array_key_exists($name, $this->parameters)) { if (!$name) { throw new ParameterNotFoundException($name); @@ -109,15 +107,15 @@ public function get($name) * @param string $name The parameter name * @param mixed $value The parameter value */ - public function set($name, $value) + public function set(string $name, $value) { - $this->parameters[(string) $name] = $value; + $this->parameters[$name] = $value; } /** * {@inheritdoc} */ - public function has($name) + public function has(string $name) { return \array_key_exists((string) $name, $this->parameters); } @@ -127,9 +125,9 @@ public function has($name) * * @param string $name The parameter name */ - public function remove($name) + public function remove(string $name) { - unset($this->parameters[(string) $name]); + unset($this->parameters[$name]); } /** @@ -190,8 +188,7 @@ public function resolveValue($value, array $resolving = []) /** * Resolves parameters inside a string. * - * @param string $value The string to resolve - * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) + * @param array $resolving An array of keys that are being resolved (used internally to detect circular references) * * @return string The resolved string * @@ -199,7 +196,7 @@ public function resolveValue($value, array $resolving = []) * @throws ParameterCircularReferenceException if a circular reference if detected * @throws RuntimeException when a given parameter has a type problem */ - public function resolveString($value, array $resolving = []) + public function resolveString(string $value, array $resolving = []) { // we do this to deal with non string values (Boolean, integer, ...) // as the preg_replace_callback throw an exception when trying diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php index 6a4e0fa4acc0..f224216cc3d8 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php @@ -47,39 +47,32 @@ public function all(); /** * Gets a service container parameter. * - * @param string $name The parameter name - * * @return mixed The parameter value * * @throws ParameterNotFoundException if the parameter is not defined */ - public function get($name); + public function get(string $name); /** * Removes a parameter. - * - * @param string $name The parameter name */ - public function remove($name); + public function remove(string $name); /** * Sets a service container parameter. * - * @param string $name The parameter name - * @param mixed $value The parameter value + * @param mixed $value The parameter value * * @throws LogicException if the parameter can not be set */ - public function set($name, $value); + public function set(string $name, $value); /** * Returns true if a parameter name is defined. * - * @param string $name The parameter name - * * @return bool true if the parameter name is defined, false otherwise */ - public function has($name); + public function has(string $name); /** * Replaces parameter placeholders (%name%) by their values for all parameters. diff --git a/src/Symfony/Component/DependencyInjection/ReverseContainer.php b/src/Symfony/Component/DependencyInjection/ReverseContainer.php index 15e198c14396..280e9e2dd5a6 100644 --- a/src/Symfony/Component/DependencyInjection/ReverseContainer.php +++ b/src/Symfony/Component/DependencyInjection/ReverseContainer.php @@ -31,7 +31,7 @@ public function __construct(Container $serviceContainer, ContainerInterface $rev $this->serviceContainer = $serviceContainer; $this->reversibleLocator = $reversibleLocator; $this->tagName = $tagName; - $this->getServiceId = \Closure::bind(function ($service): ?string { + $this->getServiceId = \Closure::bind(function (object $service): ?string { return array_search($service, $this->services, true) ?: array_search($service, $this->privates, true) ?: null; }, $serviceContainer, Container::class); } @@ -40,10 +40,8 @@ public function __construct(Container $serviceContainer, ContainerInterface $rev * Returns the id of the passed object when it exists as a service. * * To be reversible, services need to be either public or be tagged with "container.reversible". - * - * @param object $service */ - public function getId($service): ?string + public function getId(object $service): ?string { if ($this->serviceContainer === $service) { return 'service_container'; diff --git a/src/Symfony/Component/DependencyInjection/ServiceLocator.php b/src/Symfony/Component/DependencyInjection/ServiceLocator.php index 6741281d9032..1d414b825345 100644 --- a/src/Symfony/Component/DependencyInjection/ServiceLocator.php +++ b/src/Symfony/Component/DependencyInjection/ServiceLocator.php @@ -57,7 +57,7 @@ public function get($id) } } - public function __invoke($id) + public function __invoke(string $id) { return isset($this->factories[$id]) ? $this->get($id) : null; } @@ -65,7 +65,7 @@ public function __invoke($id) /** * @internal */ - public function withContext($externalId, Container $container) + public function withContext(string $externalId, Container $container) { $locator = clone $this; $locator->externalId = $externalId; diff --git a/src/Symfony/Component/DependencyInjection/TaggedContainerInterface.php b/src/Symfony/Component/DependencyInjection/TaggedContainerInterface.php index 90b297fff2f3..2e32cd5977a3 100644 --- a/src/Symfony/Component/DependencyInjection/TaggedContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/TaggedContainerInterface.php @@ -25,5 +25,5 @@ interface TaggedContainerInterface extends ContainerInterface * * @return array An array of tags */ - public function findTaggedServiceIds($name); + public function findTaggedServiceIds(string $name); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php index f18607914e60..add95a98b25e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RegisterEnvVarProcessorsPassTest.php @@ -75,7 +75,7 @@ public function testBadProcessor() class SimpleProcessor implements EnvVarProcessorInterface { - public function getEnv($prefix, $name, \Closure $getEnv) + public function getEnv(string $prefix, string $name, \Closure $getEnv) { return $getEnv($name); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index e5f08e4f62c2..ae170cdeaff6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -327,8 +327,8 @@ public function testGetAliases() $builder->register('bar', 'stdClass'); $this->assertFalse($builder->hasAlias('bar')); - $builder->set('foobar', 'stdClass'); - $builder->set('moo', 'stdClass'); + $builder->set('foobar', new \stdClass()); + $builder->set('moo', new \stdClass()); $this->assertCount(2, $builder->getAliases(), '->getAliases() does not return aliased services that have been overridden'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index e81bf5636fc8..a6d4cc24e753 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -187,7 +187,7 @@ public function testSetWithNullOnUninitializedPredefinedService() { $sc = new Container(); $sc->set('foo', new \stdClass()); - $sc->get('foo', null); + $sc->get('foo'); $sc->set('foo', null); $this->assertFalse($sc->has('foo'), '->set() with null service resets the service'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php index f093778143a5..f2b6ac339a59 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php @@ -28,18 +28,6 @@ public function testConstructor() $this->assertEquals(['foo'], $def->getArguments(), '__construct() takes an optional array of arguments as its second argument'); } - /** - * @group legacy - * @expectedDeprecation Passing an instance of Symfony\Component\DependencyInjection\Parameter as class name to Symfony\Component\DependencyInjection\Definition in deprecated in Symfony 4.4 and will result in a TypeError in 5.0. Please pass the string "%parameter%" instead. - */ - public function testConstructorWithParameter() - { - $parameter = new Parameter('parameter'); - - $def = new Definition($parameter); - $this->assertSame($parameter, $def->getClass(), '__construct() accepts Parameter instances'); - } - public function testSetGetFactory() { $def = new Definition(); @@ -62,28 +50,6 @@ public function testSetGetClass() $this->assertEquals('foo', $def->getClass(), '->getClass() returns the class name'); } - /** - * @group legacy - * @expectedDeprecation Passing an instance of Symfony\Component\DependencyInjection\Parameter as class name to Symfony\Component\DependencyInjection\Definition in deprecated in Symfony 4.4 and will result in a TypeError in 5.0. Please pass the string "%parameter%" instead. - */ - public function testSetGetClassWithParameter() - { - $def = new Definition(); - $parameter = new Parameter('parameter'); - $this->assertSame($parameter, $def->setClass($parameter)->getClass(), '->getClass() returns the parameterized class name'); - } - - /** - * @group legacy - * @expectedDeprecation The class name passed to Symfony\Component\DependencyInjection\Definition is expected to be a string. Passing a stdClass is deprecated in Symfony 4.4 and will result in a TypeError in 5.0. - */ - public function testSetGetClassWithObject() - { - $def = new Definition(); - $classObject = new \stdClass(); - $this->assertSame($classObject, $def->setClass($classObject)->getClass(), '->getClass() returns the parameterized class name'); - } - public function testSetGetDecoratedService() { $def = new Definition('stdClass'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 0b4764f6330d..4c7c8d2d0d9b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -1251,7 +1251,7 @@ public function testWither() class Rot13EnvVarProcessor implements EnvVarProcessorInterface { - public function getEnv($prefix, $name, \Closure $getEnv) + public function getEnv(string $prefix, string $name, \Closure $getEnv) { return str_rot13($getEnv($name)); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index e83b88ac82de..e25b933bf3f6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -59,10 +59,8 @@ protected function getTestService() return $this->services['test'] = new \stdClass(['only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end', 'new line' => 'string with '."\n".'new line']); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -73,14 +71,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index b1cc6ae03264..e72e3fba89df 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -63,10 +63,8 @@ protected function getTestService() return $this->services['test'] = new \stdClass(('wiz'.$this->targetDirs[1]), [('wiz'.$this->targetDirs[1]) => ($this->targetDirs[2].'/')]); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -77,14 +75,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 4151590d383b..3cbcd72fea8a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -74,10 +74,8 @@ protected function getServiceWithMethodCallAndFactoryService() return $instance; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -88,14 +86,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index 38622e77d96c..25a1aee5660f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -74,10 +74,8 @@ protected function getTestService() return $this->services['test'] = new ${($_ = $this->getEnv('FOO')) && false ?: "_"}($this->getEnv('Bar'), 'foo'.$this->getEnv('string:FOO').'baz', $this->getEnv('int:Baz')); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -88,14 +86,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index f7b357a3d348..d63b9afa6405 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -46,10 +46,8 @@ public function getRemovedIds() ]; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -60,14 +58,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index d8152cac9b0c..9d4ebbb5cc6d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -462,9 +462,8 @@ class ProjectServiceContainer extends Container return $instance; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; if (isset($this->buildParameters[$name])) { return $this->buildParameters[$name]; } @@ -479,9 +478,8 @@ class ProjectServiceContainer extends Container return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; if (isset($this->buildParameters[$name])) { return true; } @@ -489,7 +487,7 @@ class ProjectServiceContainer extends Container return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 716c4cc1e714..17fe9f6e0561 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -409,10 +409,8 @@ protected function getFactorySimpleService() return new \SimpleFactoryClass('foo'); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -423,14 +421,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php index ff1b42608c2c..19cbf849dae2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php @@ -67,10 +67,8 @@ protected function getBarService() return $instance; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -81,14 +79,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php index 2aa9d06c910f..85755dd690f3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php @@ -46,10 +46,8 @@ public function getRemovedIds() ]; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -60,14 +58,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php index bdc71de0b9f1..2ccaa26c1229 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_csv_env.php @@ -46,10 +46,8 @@ public function getRemovedIds() ]; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -60,14 +58,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php index 3e939b3a29e2..b106c73a7f38 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_default_env.php @@ -46,10 +46,8 @@ public function getRemovedIds() ]; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -60,14 +58,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php index 3c7934ad88a6..d222686d7132 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_env_in_id.php @@ -72,10 +72,8 @@ protected function getFooService() return $this->services['foo'] = new \stdClass(($this->privates['bar_%env(BAR)%'] ?? ($this->privates['bar_%env(BAR)%'] = new \stdClass())), ['baz_'.$this->getEnv('string:BAR') => new \stdClass()]); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -86,14 +84,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php index a33a9301a28d..cae00d4b6d0c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_errored_definition.php @@ -409,10 +409,8 @@ protected function getFactorySimpleService() return new \SimpleFactoryClass('foo'); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -423,14 +421,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php index 1f417b389684..36c01f1a7956 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php @@ -96,10 +96,8 @@ protected function getC2Service() return $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3()); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -110,14 +108,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php index 3bf21240936d..c6e129458b50 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_json_env.php @@ -46,10 +46,8 @@ public function getRemovedIds() ]; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -60,14 +58,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php index 7e50980728e3..4decb3949261 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_query_string_env.php @@ -46,10 +46,8 @@ public function getRemovedIds() ]; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -60,14 +58,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php index be92854b0cb9..bea37c5d2184 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php @@ -77,10 +77,8 @@ protected function getContainer_EnvVarProcessorsLocatorService() ]); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -91,14 +89,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php index e58f89cbda30..03651312a635 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_unsupported_characters.php @@ -81,10 +81,8 @@ protected function getFooohnoService() return $this->services['foo*/oh-no'] = new \FooClass(); } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -95,14 +93,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php index 3eb78e5d8b5b..58f624852381 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_url_env.php @@ -46,10 +46,8 @@ public function getRemovedIds() ]; } - public function getParameter($name) + public function getParameter(string $name) { - $name = (string) $name; - if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) { throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } @@ -60,14 +58,12 @@ public function getParameter($name) return $this->parameters[$name]; } - public function hasParameter($name) + public function hasParameter(string $name) { - $name = (string) $name; - return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters); } - public function setParameter($name, $value) + public function setParameter(string $name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy