Skip to content

Commit c21fbb2

Browse files
committed
Add types to private/final/internal methods and constructors.
1 parent 22319a9 commit c21fbb2

33 files changed

+105
-87
lines changed

src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Test;
1313

14+
use Psr\Container\ContainerInterface;
1415
use Symfony\Component\DependencyInjection\Container;
1516
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
1617
use Symfony\Component\HttpKernel\KernelInterface;
@@ -34,7 +35,7 @@ public function __construct(KernelInterface $kernel, string $privateServicesLoca
3435
/**
3536
* {@inheritdoc}
3637
*/
37-
public function compile()
38+
public function compile(): void
3839
{
3940
$this->getPublicContainer()->compile();
4041
}
@@ -74,15 +75,15 @@ public function hasParameter($name): bool
7475
/**
7576
* {@inheritdoc}
7677
*/
77-
public function setParameter($name, $value)
78+
public function setParameter($name, $value): void
7879
{
7980
$this->getPublicContainer()->setParameter($name, $value);
8081
}
8182

8283
/**
8384
* {@inheritdoc}
8485
*/
85-
public function set($id, $service)
86+
public function set($id, $service): void
8687
{
8788
$this->getPublicContainer()->set($id, $service);
8889
}
@@ -114,7 +115,7 @@ public function initialized($id): bool
114115
/**
115116
* {@inheritdoc}
116117
*/
117-
public function reset()
118+
public function reset(): void
118119
{
119120
$this->getPublicContainer()->reset();
120121
}
@@ -135,7 +136,7 @@ public function getRemovedIds(): array
135136
return $this->getPublicContainer()->getRemovedIds();
136137
}
137138

138-
private function getPublicContainer()
139+
private function getPublicContainer(): Container
139140
{
140141
if (null === $container = $this->kernel->getContainer()) {
141142
throw new \LogicException('Cannot access the container on a non-booted kernel. Did you forget to boot it?');
@@ -144,7 +145,7 @@ private function getPublicContainer()
144145
return $container;
145146
}
146147

147-
private function getPrivateContainer()
148+
private function getPrivateContainer(): ContainerInterface
148149
{
149150
return $this->getPublicContainer()->get($this->privateServicesLocatorId);
150151
}

src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public function __construct($value, bool $trackUsage = true, int $type = 0, stri
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function getValues()
46+
public function getValues(): array
4747
{
4848
return [$this->value, $this->identifier, $this->used, $this->type, $this->file];
4949
}
5050

5151
/**
5252
* {@inheritdoc}
5353
*/
54-
public function setValues(array $values)
54+
public function setValues(array $values): void
5555
{
5656
if (5 === \count($values)) {
5757
list($this->value, $this->identifier, $this->used, $this->type, $this->file) = $values;

src/Symfony/Component/DependencyInjection/Argument/RewindableGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public function __construct(callable $generator, $count)
2828
$this->count = $count;
2929
}
3030

31-
public function getIterator()
31+
public function getIterator(): \Traversable
3232
{
3333
$g = $this->generator;
3434

3535
return $g();
3636
}
3737

38-
public function count()
38+
public function count(): int
3939
{
4040
if (\is_callable($count = $this->count)) {
4141
$this->count = $count();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ protected function getReflectionMethod(Definition $definition, $method)
192192
return $r;
193193
}
194194

195-
private function getExpressionLanguage()
195+
private function getExpressionLanguage(): ExpressionLanguage
196196
{
197197
if (null === $this->expressionLanguage) {
198198
if (!class_exists(ExpressionLanguage::class)) {
199199
throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
200200
}
201201

202202
$providers = $this->container->getExpressionLanguageProviders();
203-
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
203+
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function (string $arg): string {
204204
if ('""' === substr_replace($arg, '', 1, -1)) {
205205
$id = stripcslashes(substr($arg, 1, -1));
206206
$this->inExpression = true;

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ protected function processValue($value, $isRoot = false)
8181
}
8282
}
8383

84+
/**
85+
* @return mixed
86+
*/
8487
private function doProcessValue($value, bool $isRoot = false)
8588
{
8689
if ($value instanceof TypedReference) {
@@ -311,7 +314,7 @@ private function getAutowiredReference(TypedReference $reference): ?TypedReferen
311314
/**
312315
* Populates the list of available types.
313316
*/
314-
private function populateAvailableTypes(ContainerBuilder $container)
317+
private function populateAvailableTypes(ContainerBuilder $container): void
315318
{
316319
$this->types = [];
317320
$this->ambiguousServiceTypes = [];
@@ -324,7 +327,7 @@ private function populateAvailableTypes(ContainerBuilder $container)
324327
/**
325328
* Populates the list of available types for a given definition.
326329
*/
327-
private function populateAvailableType(ContainerBuilder $container, string $id, Definition $definition)
330+
private function populateAvailableType(ContainerBuilder $container, string $id, Definition $definition): void
328331
{
329332
// Never use abstract services
330333
if ($definition->isAbstract()) {
@@ -347,7 +350,7 @@ private function populateAvailableType(ContainerBuilder $container, string $id,
347350
/**
348351
* Associates a type and a service id if applicable.
349352
*/
350-
private function set(string $type, string $id)
353+
private function set(string $type, string $id): void
351354
{
352355
// is this already a type/class that is known to match multiple services?
353356
if (isset($this->ambiguousServiceTypes[$type])) {
@@ -371,7 +374,7 @@ private function set(string $type, string $id)
371374
$this->ambiguousServiceTypes[$type][] = $id;
372375
}
373376

374-
private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label)
377+
private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): callable
375378
{
376379
if (null === $this->typesClone->container) {
377380
$this->typesClone->container = new ContainerBuilder($this->container->getParameterBag());
@@ -386,7 +389,7 @@ private function createTypeNotFoundMessageCallback(TypedReference $reference, st
386389
})->bindTo($this->typesClone);
387390
}
388391

389-
private function createTypeNotFoundMessage(TypedReference $reference, string $label, string $currentId)
392+
private function createTypeNotFoundMessage(TypedReference $reference, string $label, string $currentId): string
390393
{
391394
if (!$r = $this->container->getReflectionClass($type = $reference->getType(), false)) {
392395
// either $type does not exist or a parent class does not exist
@@ -420,7 +423,7 @@ private function createTypeNotFoundMessage(TypedReference $reference, string $la
420423
return $message;
421424
}
422425

423-
private function createTypeAlternatives(ContainerBuilder $container, TypedReference $reference)
426+
private function createTypeAlternatives(ContainerBuilder $container, TypedReference $reference): string
424427
{
425428
// try suggesting available aliases first
426429
if ($message = $this->getAliasesSuggestionForType($container, $type = $reference->getType())) {
@@ -444,7 +447,7 @@ private function createTypeAlternatives(ContainerBuilder $container, TypedRefere
444447
return sprintf(' You should maybe alias this %s to %s.', class_exists($type, false) ? 'class' : 'interface', $message);
445448
}
446449

447-
private function getAliasesSuggestionForType(ContainerBuilder $container, string $type)
450+
private function getAliasesSuggestionForType(ContainerBuilder $container, string $type): ?string
448451
{
449452
$aliases = [];
450453
foreach (class_parents($type) + class_implements($type) as $parent) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function process(ContainerBuilder $container)
5151
*
5252
* @throws ServiceCircularReferenceException when a circular reference is found
5353
*/
54-
private function checkOutEdges(array $edges)
54+
private function checkOutEdges(array $edges): void
5555
{
5656
foreach ($edges as $edge) {
5757
$node = $edge->getDestNode();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BE
6565
/**
6666
* @final
6767
*/
68-
public function log(CompilerPassInterface $pass, string $message)
68+
public function log(CompilerPassInterface $pass, string $message): void
6969
{
7070
if (false !== strpos($message, "\n")) {
7171
$message = str_replace("\n", "\n".\get_class($pass).': ', trim($message));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function __construct(parent $parameterBag)
113113
$this->mergeEnvPlaceholders($parameterBag);
114114
}
115115

116-
public function freezeAfterProcessing(Extension $extension, ContainerBuilder $container)
116+
public function freezeAfterProcessing(Extension $extension, ContainerBuilder $container): void
117117
{
118118
if (!$config = $extension->getProcessedConfigs()) {
119119
// Extension::processConfiguration() wasn't called, we cannot know how configs were merged
@@ -175,15 +175,15 @@ public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig:
175175
/**
176176
* {@inheritdoc}
177177
*/
178-
public function registerExtension(ExtensionInterface $extension)
178+
public function registerExtension(ExtensionInterface $extension): void
179179
{
180180
throw new LogicException(sprintf('You cannot register extension "%s" from "%s". Extensions must be registered before the container is compiled.', \get_class($extension), $this->extensionClass));
181181
}
182182

183183
/**
184184
* {@inheritdoc}
185185
*/
186-
public function compile(bool $resolveEnvPlaceholders = false)
186+
public function compile(bool $resolveEnvPlaceholders = false): void
187187
{
188188
throw new LogicException(sprintf('Cannot compile the container in extension "%s".', $this->extensionClass));
189189
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function process(ContainerBuilder $container)
6060
}
6161
}
6262

63-
private static function validateProvidedTypes($types, $class)
63+
private static function validateProvidedTypes(string $types, string $class): array
6464
{
6565
$types = explode('|', $types);
6666

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ protected function processValue($value, $isRoot = false)
205205
return parent::processValue($value, $isRoot);
206206
}
207207

208+
/**
209+
* @return mixed
210+
*/
208211
private function getBindingValue(BoundArgument $binding)
209212
{
210213
list($bindingValue, $bindingId) = $binding->getValues();

0 commit comments

Comments
 (0)