Skip to content

Commit 1b401f9

Browse files
committed
[DependencyInjection] Add type-hints to interfaces and implementations.
1 parent aac5765 commit 1b401f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+179
-357
lines changed

src/Symfony/Component/DependencyInjection/Alias.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ public function isPublic()
4444
/**
4545
* Sets if this Alias is public.
4646
*
47-
* @param bool $boolean If this Alias should be public
48-
*
4947
* @return $this
5048
*/
51-
public function setPublic($boolean)
49+
public function setPublic(bool $boolean)
5250
{
53-
$this->public = (bool) $boolean;
51+
$this->public = $boolean;
5452
$this->private = false;
5553

5654
return $this;
@@ -64,13 +62,11 @@ public function setPublic($boolean)
6462
* but triggers a deprecation notice when accessed from the container,
6563
* so that the alias can be made really private in 4.0.
6664
*
67-
* @param bool $boolean
68-
*
6965
* @return $this
7066
*/
71-
public function setPrivate($boolean)
67+
public function setPrivate(bool $boolean)
7268
{
73-
$this->private = (bool) $boolean;
69+
$this->private = $boolean;
7470

7571
return $this;
7672
}
@@ -96,7 +92,7 @@ public function isPrivate()
9692
*
9793
* @throws InvalidArgumentException when the message template is invalid
9894
*/
99-
public function setDeprecated($status = true, $template = null)
95+
public function setDeprecated(bool $status = true, string $template = null)
10096
{
10197
if (null !== $template) {
10298
if (preg_match('#[\r\n]|\*/#', $template)) {
@@ -110,7 +106,7 @@ public function setDeprecated($status = true, $template = null)
110106
$this->deprecationTemplate = $template;
111107
}
112108

113-
$this->deprecated = (bool) $status;
109+
$this->deprecated = $status;
114110

115111
return $this;
116112
}

src/Symfony/Component/DependencyInjection/ChildDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function replaceArgument($index, $value)
109109
/**
110110
* @internal
111111
*/
112-
public function setAutoconfigured($autoconfigured)
112+
public function setAutoconfigured(bool $autoconfigured)
113113
{
114114
throw new BadMethodCallException('A ChildDefinition cannot be autoconfigured.');
115115
}

src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function __construct(ExtensionInterface $extension, ParameterBagInterface
167167
/**
168168
* {@inheritdoc}
169169
*/
170-
public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
170+
public function addCompilerPass(CompilerPassInterface $pass, string $type = PassConfig::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
171171
{
172172
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));
173173
}

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function getParameterBag()
107107
*
108108
* @throws InvalidArgumentException if the parameter is not defined
109109
*/
110-
public function getParameter($name)
110+
public function getParameter(string $name)
111111
{
112112
return $this->parameterBag->get($name);
113113
}
@@ -119,7 +119,7 @@ public function getParameter($name)
119119
*
120120
* @return bool The presence of parameter in container
121121
*/
122-
public function hasParameter($name)
122+
public function hasParameter(string $name)
123123
{
124124
return $this->parameterBag->has($name);
125125
}
@@ -130,7 +130,7 @@ public function hasParameter($name)
130130
* @param string $name The parameter name
131131
* @param mixed $value The parameter value
132132
*/
133-
public function setParameter($name, $value)
133+
public function setParameter(string $name, $value)
134134
{
135135
$this->parameterBag->set($name, $value);
136136
}
@@ -140,11 +140,8 @@ public function setParameter($name, $value)
140140
*
141141
* Setting a synthetic service to null resets it: has() returns false and get()
142142
* behaves in the same way as if the service was never created.
143-
*
144-
* @param string $id The service identifier
145-
* @param object $service The service instance
146143
*/
147-
public function set($id, $service)
144+
public function set(string $id, ?object $service)
148145
{
149146
// Runs the internal initializer; used by the dumped container to include always-needed files
150147
if (isset($this->privates['service_container']) && $this->privates['service_container'] instanceof \Closure) {
@@ -218,7 +215,7 @@ public function has($id)
218215
*
219216
* @see Reference
220217
*/
221-
public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
218+
public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
222219
{
223220
return $this->services[$id]
224221
?? $this->services[$id = $this->aliases[$id] ?? $id]
@@ -285,7 +282,7 @@ private function make(string $id, int $invalidBehavior)
285282
*
286283
* @return bool true if service has already been initialized, false otherwise
287284
*/
288-
public function initialized($id)
285+
public function initialized(string $id)
289286
{
290287
if (isset($this->aliases[$id])) {
291288
$id = $this->aliases[$id];

0 commit comments

Comments
 (0)
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