Skip to content

Commit e8d9c35

Browse files
Merge branch '5.3' into 5.4
* 5.3: Backport type fixes fix annot Backport type fixes Fix CS Avoid triggering the autoloader in Deprecation::isLegacy() fix markdown markup Backport type fixes uzb translation [DependencyInjection] Fix doc blocks [DependencyInjection] Turn $defaultDeprecationTemplate into a constant [GHA] restore phpunit-bridge job rethrow caught exception [Form] better form doc types to support static analysis
2 parents 5ac6476 + 4fcfbd5 commit e8d9c35

19 files changed

+50
-115
lines changed

Alias.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
class Alias
1717
{
18+
private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.';
19+
1820
private $id;
1921
private $public;
2022
private $deprecation = [];
2123

22-
private static $defaultDeprecationTemplate = 'The "%alias_id%" service alias is deprecated. You should stop using it, as it will be removed in the future.';
23-
2424
public function __construct(string $id, bool $public = false)
2525
{
2626
$this->id = $id;
@@ -117,7 +117,7 @@ public function setDeprecated(/* string $package, string $version, string $messa
117117
}
118118
}
119119

120-
$this->deprecation = $status ? ['package' => $package, 'version' => $version, 'message' => $message ?: self::$defaultDeprecationTemplate] : [];
120+
$this->deprecation = $status ? ['package' => $package, 'version' => $version, 'message' => $message ?: self::DEFAULT_DEPRECATION_TEMPLATE] : [];
121121

122122
return $this;
123123
}

Argument/ServiceLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(\Closure $factory, array $serviceMap, array $service
3737
*
3838
* @return mixed
3939
*/
40-
public function get($id)
40+
public function get(string $id)
4141
{
4242
return isset($this->serviceMap[$id]) ? ($this->factory)(...$this->serviceMap[$id]) : parent::get($id);
4343
}

ChildDefinition.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ public function getParent()
4444
/**
4545
* Sets the Definition to inherit from.
4646
*
47-
* @param string $parent
48-
*
4947
* @return $this
5048
*/
51-
public function setParent($parent)
49+
public function setParent(string $parent)
5250
{
5351
$this->parent = $parent;
5452

Compiler/AutowirePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ private function set(string $type, string $id)
408408
$this->ambiguousServiceTypes[$type][] = $id;
409409
}
410410

411-
private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): callable
411+
private function createTypeNotFoundMessageCallback(TypedReference $reference, string $label): \Closure
412412
{
413413
if (null === $this->typesClone->container) {
414414
$this->typesClone->container = new ContainerBuilder($this->container->getParameterBag());

Compiler/ServiceReferenceGraph.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15+
use Symfony\Component\DependencyInjection\Reference;
1516

1617
/**
1718
* This is a directed graph of your services.
@@ -73,7 +74,7 @@ public function clear()
7374
/**
7475
* Connects 2 nodes together in the Graph.
7576
*/
76-
public function connect(?string $sourceId, $sourceValue, ?string $destId, $destValue = null, $reference = null, bool $lazy = false, bool $weak = false, bool $byConstructor = false)
77+
public function connect(?string $sourceId, $sourceValue, ?string $destId, $destValue = null, Reference $reference = null, bool $lazy = false, bool $weak = false, bool $byConstructor = false)
7778
{
7879
if (null === $sourceId || null === $destId) {
7980
return;

Config/ContainerParametersResource.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ public function __construct(array $parameters)
3232
$this->parameters = $parameters;
3333
}
3434

35-
/**
36-
* {@inheritdoc}
37-
*/
3835
public function __toString(): string
3936
{
4037
return 'container_parameters_'.md5(serialize($this->parameters));

Container.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public function getParameterBag()
107107
/**
108108
* Gets a parameter.
109109
*
110-
* @param string $name The parameter name
111-
*
112-
* @return array|bool|float|int|string|null The parameter value
110+
* @return mixed
113111
*
114112
* @throws InvalidArgumentException if the parameter is not defined
115113
*/
@@ -119,10 +117,6 @@ public function getParameter(string $name)
119117
}
120118

121119
/**
122-
* Checks if a parameter exists.
123-
*
124-
* @param string $name The parameter name
125-
*
126120
* @return bool The presence of parameter in container
127121
*/
128122
public function hasParameter(string $name)
@@ -210,9 +204,6 @@ public function has(string $id)
210204
/**
211205
* Gets a service.
212206
*
213-
* @param string $id The service identifier
214-
* @param int $invalidBehavior The behavior when the service does not exist
215-
*
216207
* @return object|null The associated service
217208
*
218209
* @throws ServiceCircularReferenceException When a circular reference is detected
@@ -286,8 +277,6 @@ private function make(string $id, int $invalidBehavior)
286277
/**
287278
* Returns true if the given service has actually been initialized.
288279
*
289-
* @param string $id The service identifier
290-
*
291280
* @return bool true if service has already been initialized, false otherwise
292281
*/
293282
public function initialized(string $id)
@@ -345,45 +334,39 @@ public function getRemovedIds()
345334
/**
346335
* Camelizes a string.
347336
*
348-
* @param string $id A string to camelize
349-
*
350337
* @return string The camelized string
351338
*/
352-
public static function camelize($id)
339+
public static function camelize(string $id)
353340
{
354341
return strtr(ucwords(strtr($id, ['_' => ' ', '.' => '_ ', '\\' => '_ '])), [' ' => '']);
355342
}
356343

357344
/**
358345
* A string to underscore.
359346
*
360-
* @param string $id The string to underscore
361-
*
362347
* @return string The underscored string
363348
*/
364-
public static function underscore($id)
349+
public static function underscore(string $id)
365350
{
366351
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], str_replace('_', '.', $id)));
367352
}
368353

369354
/**
370355
* Creates a service by requiring its factory file.
371356
*/
372-
protected function load($file)
357+
protected function load(string $file)
373358
{
374359
return require $file;
375360
}
376361

377362
/**
378363
* Fetches a variable from the environment.
379364
*
380-
* @param string $name The name of the environment variable
381-
*
382365
* @return mixed The value to use for the provided environment variable name
383366
*
384367
* @throws EnvNotFoundException When the environment variable is not found and has no default value
385368
*/
386-
protected function getEnv($name)
369+
protected function getEnv(string $name)
387370
{
388371
if (isset($this->resolving[$envName = "env($name)"])) {
389372
throw new ParameterCircularReferenceException(array_keys($this->resolving));

ContainerBuilder.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,6 @@ public function has(string $id)
524524
}
525525

526526
/**
527-
* Gets a service.
528-
*
529-
* @param string $id The service identifier
530-
* @param int $invalidBehavior The behavior when the service does not exist
531-
*
532527
* @return object|null The associated service
533528
*
534529
* @throws InvalidArgumentException when no definitions are available
@@ -842,11 +837,6 @@ public function setAlias(string $alias, $id)
842837
return $this->aliasDefinitions[$alias] = $id;
843838
}
844839

845-
/**
846-
* Removes an alias.
847-
*
848-
* @param string $alias The alias to remove
849-
*/
850840
public function removeAlias(string $alias)
851841
{
852842
if (isset($this->aliasDefinitions[$alias])) {
@@ -856,8 +846,6 @@ public function removeAlias(string $alias)
856846
}
857847

858848
/**
859-
* Returns true if an alias exists under the given identifier.
860-
*
861849
* @return bool true if the alias exists, false otherwise
862850
*/
863851
public function hasAlias(string $id)
@@ -866,8 +854,6 @@ public function hasAlias(string $id)
866854
}
867855

868856
/**
869-
* Gets all defined aliases.
870-
*
871857
* @return Alias[] An array of aliases
872858
*/
873859
public function getAliases()
@@ -876,8 +862,6 @@ public function getAliases()
876862
}
877863

878864
/**
879-
* Gets an alias.
880-
*
881865
* @return Alias An Alias instance
882866
*
883867
* @throws InvalidArgumentException if the alias does not exist
@@ -1586,7 +1570,7 @@ public static function hash($value)
15861570
/**
15871571
* {@inheritdoc}
15881572
*/
1589-
protected function getEnv($name)
1573+
protected function getEnv(string $name)
15901574
{
15911575
$value = parent::getEnv($name);
15921576
$bag = $this->getParameterBag();
@@ -1615,7 +1599,7 @@ protected function getEnv($name)
16151599
}
16161600
}
16171601

1618-
private function callMethod($service, array $call, array &$inlineServices)
1602+
private function callMethod(object $service, array $call, array &$inlineServices)
16191603
{
16201604
foreach (self::getServiceConditionals($call[1]) as $s) {
16211605
if (!$this->has($s)) {

ContainerInterface.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ public function set(string $id, ?object $service);
5151
public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
5252

5353
/**
54-
* Returns true if the given service is defined.
55-
*
56-
* @param string $id The service identifier
57-
*
5854
* @return bool true if the service is defined, false otherwise
5955
*/
6056
public function has(string $id);
@@ -67,22 +63,14 @@ public function has(string $id);
6763
public function initialized(string $id);
6864

6965
/**
70-
* Gets a parameter.
71-
*
72-
* @param string $name The parameter name
73-
*
74-
* @return array|bool|float|int|string|null The parameter value
66+
* @return mixed
7567
*
7668
* @throws InvalidArgumentException if the parameter is not defined
7769
*/
7870
public function getParameter(string $name);
7971

8072
/**
81-
* Checks if a parameter exists.
82-
*
83-
* @param string $name The parameter name
84-
*
85-
* @return bool The presence of parameter in container
73+
* @return bool
8674
*/
8775
public function hasParameter(string $name);
8876

Definition.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
class Definition
2424
{
25+
private const DEFAULT_DEPRECATION_TEMPLATE = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.';
26+
2527
private $class;
2628
private $file;
2729
private $factory;
@@ -45,8 +47,6 @@ class Definition
4547

4648
protected $arguments = [];
4749

48-
private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.';
49-
5050
/**
5151
* @internal
5252
*
@@ -743,7 +743,7 @@ public function setDeprecated(/* string $package, string $version, string $messa
743743
}
744744

745745
$this->changes['deprecated'] = true;
746-
$this->deprecation = $status ? ['package' => $package, 'version' => $version, 'message' => $message ?: self::$defaultDeprecationTemplate] : [];
746+
$this->deprecation = $status ? ['package' => $package, 'version' => $version, 'message' => $message ?: self::DEFAULT_DEPRECATION_TEMPLATE] : [];
747747

748748
return $this;
749749
}
@@ -790,7 +790,7 @@ public function getDeprecation(string $id): array
790790
/**
791791
* Sets a configurator to call after the service is fully initialized.
792792
*
793-
* @param string|array|Reference $configurator A PHP function, reference or an array containing a class/Reference and a method to call
793+
* @param string|array|Reference|null $configurator A PHP function, reference or an array containing a class/Reference and a method to call
794794
*
795795
* @return $this
796796
*/

Exception/ParameterNotFoundException.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class ParameterNotFoundException extends InvalidArgumentException implements Not
2727
private $nonNestedAlternative;
2828

2929
/**
30-
* @param string $key The requested parameter key
31-
* @param string $sourceId The service id that references the non-existent parameter
32-
* @param string $sourceKey The parameter key that references the non-existent parameter
33-
* @param \Throwable $previous The previous exception
34-
* @param string[] $alternatives Some parameter name alternatives
35-
* @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters
30+
* @param string $key The requested parameter key
31+
* @param string|null $sourceId The service id that references the non-existent parameter
32+
* @param string|null $sourceKey The parameter key that references the non-existent parameter
33+
* @param \Throwable|null $previous The previous exception
34+
* @param string[] $alternatives Some parameter name alternatives
35+
* @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters
3636
*/
3737
public function __construct(string $key, string $sourceId = null, string $sourceKey = null, \Throwable $previous = null, array $alternatives = [], string $nonNestedAlternative = null)
3838
{
@@ -84,14 +84,14 @@ public function getSourceKey()
8484
return $this->sourceKey;
8585
}
8686

87-
public function setSourceId($sourceId)
87+
public function setSourceId(?string $sourceId)
8888
{
8989
$this->sourceId = $sourceId;
9090

9191
$this->updateRepr();
9292
}
9393

94-
public function setSourceKey($sourceKey)
94+
public function setSourceKey(?string $sourceKey)
9595
{
9696
$this->sourceKey = $sourceKey;
9797

Loader/Configurator/ServiceConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ServiceConfigurator extends AbstractServiceConfigurator
4747
private $path;
4848
private $destructed = false;
4949

50-
public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, $id, array $defaultTags, string $path = null)
50+
public function __construct(ContainerBuilder $container, array $instanceof, bool $allowParent, ServicesConfigurator $parent, Definition $definition, ?string $id, array $defaultTags, string $path = null)
5151
{
5252
$this->container = $container;
5353
$this->instanceof = $instanceof;

0 commit comments

Comments
 (0)