Skip to content

Commit b4a585a

Browse files
Merge branch '4.4' into 5.1
* 4.4: CS fix [travis] use PHP 8.0 to patch return types and run deps=low Update sl_SI translations Don't trigger deprecation for deprecated aliases pointing to deprecated definitions [HttpFoundation] use atomic writes in MockFileSessionStorage [DI] fix param annotation [Config] Add \Symfony\Component\Config\Loader::load() return type Simplify PHP CS Fixer config Rename normalize param
2 parents 51fe616 + 72a5b41 commit b4a585a

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

Compiler/ResolveReferencesToAliasesPass.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ private function getDefinitionId(string $id, ContainerBuilder $container): strin
6262
$alias = $container->getAlias($id);
6363

6464
if ($alias->isDeprecated()) {
65-
$deprecation = $alias->getDeprecation($id);
66-
trigger_deprecation($deprecation['package'], $deprecation['version'], rtrim($deprecation['message'], '. ').'. It is being referenced by the "%s" '.($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), $this->currentId);
65+
$referencingDefinition = $container->hasDefinition($this->currentId) ? $container->getDefinition($this->currentId) : $container->getAlias($this->currentId);
66+
if (!$referencingDefinition->isDeprecated()) {
67+
$deprecation = $alias->getDeprecation($id);
68+
trigger_deprecation($deprecation['package'], $deprecation['version'], rtrim($deprecation['message'], '. ').'. It is being referenced by the "%s" '.($container->hasDefinition($this->currentId) ? 'service.' : 'alias.'), $this->currentId);
69+
}
6770
}
6871

6972
$seen = [];

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private function isUsingShortSyntax(array $service): bool
316316
/**
317317
* Parses a definition.
318318
*
319-
* @param array|string $service
319+
* @param array|string|null $service
320320
*
321321
* @throws InvalidArgumentException When tags are invalid
322322
*/

Tests/Compiler/ResolveReferencesToAliasesPassTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,44 @@ public function testDeprecationNoticeWhenReferencedByDefinition()
126126
$this->process($container);
127127
}
128128

129+
public function testNoDeprecationNoticeWhenReferencedByDeprecatedAlias()
130+
{
131+
$container = new ContainerBuilder();
132+
133+
$container->register('foo', 'stdClass');
134+
135+
$aliasDeprecated = new Alias('foo');
136+
$aliasDeprecated->setDeprecated(true);
137+
$container->setAlias('deprecated_foo_alias', $aliasDeprecated);
138+
139+
$alias = new Alias('deprecated_foo_alias');
140+
$alias->setDeprecated(true);
141+
$container->setAlias('alias', $alias);
142+
143+
$this->process($container);
144+
$this->addToAssertionCount(1);
145+
}
146+
147+
public function testNoDeprecationNoticeWhenReferencedByDeprecatedDefinition()
148+
{
149+
$container = new ContainerBuilder();
150+
151+
$container->register('foo', 'stdClass');
152+
153+
$aliasDeprecated = new Alias('foo');
154+
$aliasDeprecated->setDeprecated(true);
155+
$container->setAlias('foo_aliased', $aliasDeprecated);
156+
157+
$container
158+
->register('definition')
159+
->setDeprecated(true)
160+
->setArguments([new Reference('foo_aliased')])
161+
;
162+
163+
$this->process($container);
164+
$this->addToAssertionCount(1);
165+
}
166+
129167
protected function process(ContainerBuilder $container)
130168
{
131169
$pass = new ResolveReferencesToAliasesPass();

Tests/Loader/GlobFileLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ class GlobFileLoaderWithoutImport extends GlobFileLoader
4040
{
4141
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null, $exclude = null)
4242
{
43+
return null;
4344
}
4445
}

0 commit comments

Comments
 (0)