8000 [DependencyInjection] Fix testServiceSubscriber for PHP 8.1 · symfony/symfony@a5be196 · GitHub
[go: up one dir, main page]

Skip to content

Commit a5be196

Browse files
[DependencyInjection] Fix testServiceSubscriber for PHP 8.1
1 parent a4dee4a commit a5be196

File tree

2 files changed

+116
-1
lines changed

2 files changed

+116
-1
lines changed

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,11 @@ public function process(ContainerBuilder $container)
950950

951951
$dumper = new PhpDumper($container);
952952

953-
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_subscriber.php', $dumper->dump());
953+
if (80100 <= \PHP_VERSION_ID) {
954+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_subscriber_php81.php', $dumper->dump());
955+
} else {
956+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_subscriber.php', $dumper->dump());
957+
}
954958
}
955959

956960
public function testPrivateWithIgnoreOnInvalidReference()
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
4+
use Symfony\Component\DependencyInjection\ContainerInterface;
5+
use Symfony\Component\DependencyInjection\Container;
6+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
7+
use Symfony\Component\DependencyInjection\Exception\LogicException;
8+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
9+
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
10+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
11+
12+
/**
13+
* This class has been auto-generated
14+
* by the Symfony Dependency Injection Component.
15+
*
16+
* @final
17+
*/
18+
class ProjectServiceContainer extends Container
19+
{
20+
private $parameters = [];
21+
private $getService;
22+
23+
public function __construct()
24+
{
25+
$this->getService = \Closure::fromCallable([$this, 'getService']);
26+
$this->services = $this->privates = [];
27+
$this->methodMap = [
28+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => 'getTestServiceSubscriberService',
29+
'foo_service' => 'getFooServiceService',
30+
'late_alias' => 'getLateAliasService',
31+
];
32+
$this->aliases = [
33+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestDefinition1' => 'late_alias',
34+
];
35+
}
36+
37+
public function compile(): void
38+
{
39+
throw new LogicException('You cannot compile a dumped container that was already compiled.');
40+
}
41+
42+
public function isCompiled(): bool
43+
{
44+
return true;
45+
}
46+
47+
public function getRemovedIds(): array
48+
{
49+
return [
50+
'.service_locator.Txga9_U' => true,
51+
'.service_locator.Txga9_U.foo_service' => true,
52+
'Psr\\Container\\ContainerInterface' => true,
53+
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
54+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => true,
55+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestDefinition1' => true,
56+
'late_alias' => true,
57+
];
58+
}
59+
60+
/**
61+
* Gets the public 'Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber' shared service.
62+
*
63+
* @return \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber
64+
*/
65+
protected function getTestServiceSubscriberService()
66+
{
67+
return $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber();
68+
}
69+
70+
/**
71+
* Gets the public 'foo_service' shared autowired service.
72+
*
73+
* @return \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber
74+
*/
75+
protected function getFooServiceService()
76+
{
77+
return $this->services['foo_service'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestServiceSubscriber((new \Symfony\Component\DependencyInjection\Argument\ServiceLocator($this->getService, [
78+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => ['privates', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'getCustomDefinitionService', false],
79+
'Symfony\ 57AE \Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false],
80+
'bar' => ['services', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber', 'getTestServiceSubscriberService', false],
81+
'baz' => ['privates', 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition', 'getCustomDefinitionService', false],
82+
'late_alias' => ['services', 'late_alias', 'getLateAliasService', false],
83+
], [
84+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
85+
'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestServiceSubscriber',
86+
'bar' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
87+
'baz' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition',
88+
'late_alias' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\TestDefinition1',
89+
]))->withContext('foo_service', $this));
90+
}
91+
92+
/**
93+
* Gets the public 'late_alias' shared service.
94+
*
95+
* @return \Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1
96+
*/
97+
protected function getLateAliasService()
98+
{
99+
return $this->services['late_alias'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\TestDefinition1();
100+
}
101+
102+
/**
103+
* Gets the private 'Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition' shared service.
104+
*
105+
* @return \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition
106+
*/
107+
protected function getCustomDefinitionService()
108+
{
109+
return $this->privates['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\CustomDefinition'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition();
110+
}
111+
}

0 commit comments

Comments
 (0)
0