8000 [DependencyInjection] Add type-hints to interfaces and implementations. · symfony/symfony@68f9f27 · GitHub
[go: up one dir, main page]

Skip to content

Commit 68f9f27

Browse files
committed
[DependencyInjection] Add type-hints to interfaces and implementations.
1 parent f03bf95 commit 68f9f27

Some content is hidden

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

51 files changed

+195
-441
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 & 7 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
}
@@ -141,10 +141,9 @@ public function setParameter($name, $value)
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.
143143
*
144-
* @param string $id The service identifier
145144
* @param object $service The service instance
146145
*/
147-
public function set($id, $service)
146+
public function set(string $id, $service)
148147
{
149148
// Runs the internal initializer; used by the dumped container to include always-needed files
150149
if (isset($this->privates['service_container']) && $this->privates['service_container'] instanceof \Closure) {
@@ -218,7 +217,7 @@ public function has($id)
218217
*
219218
* @see Reference
220219
*/
221-
public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
220+
public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
222221
{
223222
return $this->services[$id]
224223
?? $this->services[$id = $this->aliases[$id] ?? $id]
@@ -285,7 +284,7 @@ private function make(string $id, int $invalidBehavior)
285284
*
286285
* @return bool true if service has already been initialized, false otherwise
287286
*/
288-
public function initialized($id)
287+
public function initialized(string $id)
289288
{
290289
if (isset($this->aliases[$id])) {
291290
$id = $this->aliases[$id];

0 commit comments

Comments
 (0)
0