8000 Add types to private/final/internal methods and constructors. · symfony/symfony@def0ac7 · GitHub
[go: up one dir, main page]

Skip to content

Commit def0ac7

Browse files
committed
Add types to private/final/internal methods and constructors.
1 parent afad962 commit def0ac7

23 files changed

+59
-36
lines changed

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

Lines changed: 3 additions & 2 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;
@@ -137,7 +138,7 @@ public function getRemovedIds(): array
137138
return $this->getPublicContainer()->getRemovedIds();
138139
}
139140

140-
private function getPublicContainer()
141+
private function getPublicContainer(): Container
141142
{
142143
if (null === $container = $this->kernel->getContainer()) {
143144
throw new \LogicException('Cannot access the container on a non-booted kernel. Did you forget to boot it?');
@@ -146,7 +147,7 @@ private function getPublicContainer()
146147
return $container;
147148
}
148149

149-
private function getPrivateContainer()
150+
private function getPrivateContainer(): ContainerInterface
150151
{
151152
return $this->getPublicContainer()->get($this->privateServicesLocatorId);
152153
}

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: 7 additions & 4 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) {
@@ -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/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();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ResolveHotPathPass extends AbstractRecursivePass
2626
private $tagName;
2727
private $resolvedIds = [];
2828

29-
public function __construct($tagName = 'container.hot_path')
29+
public function __construct(string $tagName = 'container.hot_path')
3030
{
3131
$this->tagName = $tagName;
3232
}

src/Symfony/Compone 2851 nt/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function process(ContainerBuilder $container)
4444
}
4545
}
4646

47-
private function processDefinition(ContainerBuilder $container, string $id, Definition $definition)
47+
private function processDefinition(ContainerBuilder $container, string $id, Definition $definition): Definition
4848
{
4949
$instanceofConditionals = $definition->getInstanceofConditionals();
5050
$autoconfiguredInstanceof = $definition->isAutoconfigured() ? $container->getAutoconfiguredInstanceof() : [];
@@ -144,7 +144,7 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
144144
return $definition;
145145
}
146146

147-
private function mergeConditionals(array $autoconfiguredInstanceof, array $instanceofConditionals, ContainerBuilder $container)
147+
private function mergeConditionals(array $autoconfiguredInstanceof, array $instanceofConditionals, ContainerBuilder $container): array
148148
{
149149
// make each value an array of ChildDefinition
150150
$conditionals = array_map(function ($childDef) { return [$childDef]; }, $autoconfiguredInstanceof);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public function process(ContainerBuilder $container)
5151
/**
5252
* Processes arguments to determine invalid references.
5353
*
54+
* @return mixed
55+
*
5456
* @throws RuntimeException When an invalid reference is found
5557
*/
5658
private function processValue($value, int $rootLevel = 0, int $level = 0)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ protected function processValue($value, $isRoot = false)
8888

8989
/**
9090
* @param Reference[] $refMap
91-
* @param string|null $callerId
9291
*/
93-
public static function register(ContainerBuilder $container, array $refMap, $callerId = null): Reference
92+
public static function register(ContainerBuilder $container, array $refMap, string $callerId = null): Reference
9493
{
9594
foreach ($refMap as $id => $ref) {
9695
if (!$ref instanceof Reference) {

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,14 @@ protected function getEnv($name)
422422
}
423423

424424
/**
425+
* @param string|false $registry
426+
* @param string|bool $load
427+
*
428+
* @return mixed
429+
*
425430
* @internal
426431
*/
427-
final protected function getService($registry, $id, $method, $load)
432+
final protected function getService($registry, string $id, ?string $method, $load)
428433
{
429434
if ('service_container' === $id) {
430435
return $this;

0 commit comments

Comments
 (0)
0