Skip to content

Commit 2d88c40

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: skip tests that do not work with ICU 71.1 [DependencyInjection] Fix dumping containers with null-referenced services [Routing] Fix removing aliases pointing to removed route in RouteCollection::remove() [VarExporter] Fix lazy ghost trait when using nullsafe operator [Routing] Fix conflicting FQCN aliases with route name Fix legacy class palceholder definitions for static analysis
2 parents cf91dc4 + e3e3d5f commit 2d88c40

File tree

9 files changed

+92
-7
lines changed

9 files changed

+92
-7
lines changed

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Form\Exception\LogicException;
1616
use Symfony\Component\Form\FormError;
1717
use Symfony\Component\Form\FormInterface;
18+
use Symfony\Component\Intl\Intl;
1819
use Symfony\Component\Intl\Util\IntlTestHelper;
1920
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
2021

@@ -92,6 +93,10 @@ public function testSubmitFromSingleTextDateTime()
9293
// we test against "de_DE", so we need the full implementation
9394
IntlTestHelper::requireFullIntl($this, false);
9495

96+
if ('71.1' === Intl::getIcuVersion()) {
97+
$this->markTestSkipped('Skipping test due to a bug in ICU 71.1.');
98+
}
99+
95100
\Locale::setDefault('de_DE');
96101

97102
$form = $this->factory->create(static::TESTED_TYPE, null, [
@@ -114,6 +119,10 @@ public function testSubmitFromSingleTextDateTimeImmutable()
114119
// we test against "de_DE", so we need the full implementation
115120
IntlTestHelper::requireFullIntl($this, false);
116121

122+
if ('71.1' === Intl::getIcuVersion()) {
123+
$this->markTestSkipped('Skipping test due to a bug in ICU 71.1.');
124+
}
125+
117126
\Locale::setDefault('de_DE');
118127

119128
$form = $this->factory->create(static::TESTED_TYPE, null, [
@@ -137,6 +146,10 @@ public function testSubmitFromSingleTextString()
137146
// we test against "de_DE", so we need the full implementation
138147
IntlTestHelper::requireFullIntl($this, false);
139148

149+
if ('71.1' === Intl::getIcuVersion()) {
150+
$this->markTestSkipped('Skipping test due to a bug in ICU 71.1.');
151+
}
152+
140153
\Locale::setDefault('de_DE');
141154

142155
$form = $this->factory->create(static::TESTED_TYPE, null, [
@@ -159,6 +172,10 @@ public function testSubmitFromSingleTextTimestamp()
159172
// we test against "de_DE", so we need the full implementation
160173
IntlTestHelper::requireFullIntl($this, false);
161174

175+
if ('71.1' === Intl::getIcuVersion()) {
176+
$this->markTestSkipped('Skipping test due to a bug in ICU 71.1.');
177+
}
178+
162179
\Locale::setDefault('de_DE');
163180

164181
$form = $this->factory->create(static::TESTED_TYPE, null, [
@@ -183,6 +200,10 @@ public function testSubmitFromSingleTextRaw()
183200
// we test against "de_DE", so we need the full implementation
184201
IntlTestHelper::requireFullIntl($this, false);
185202

203+
if ('71.1' === Intl::getIcuVersion()) {
204+
$this->markTestSkipped('Skipping test due to a bug in ICU 71.1.');
205+
}
206+
186207
\Locale::setDefault('de_DE');
187208

188209
$form = $this->factory->create(static::TESTED_TYPE, null, [

src/Symfony/Component/Routing/Loader/AttributeClassLoader.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ public function load(mixed $class, string $type = null): RouteCollection
101101

102102
if (1 === $collection->count() - \count($routeNamesBefore)) {
103103
$newRouteName = current(array_diff(array_keys($collection->all()), $routeNamesBefore));
104-
$collection->addAlias(sprintf('%s::%s', $class->name, $method->name), $newRouteName);
104+
if ($newRouteName !== $aliasName = sprintf('%s::%s', $class->name, $method->name)) {
105+
$collection->addAlias($aliasName, $newRouteName);
106+
}
105107
}
106108
}
107109
if (0 === $collection->count() && $class->hasMethod('__invoke')) {
@@ -112,8 +114,14 @@ public function load(mixed $class, string $type = null): RouteCollection
112114
}
113115
}
114116
if ($fqcnAlias && 1 === $collection->count()) {
115-
$collection->addAlias($class->name, $invokeRouteName = key($collection->all()));
116-
$collection->addAlias(sprintf('%s::__invoke', $class->name), $invokeRouteName);
117+
$invokeRouteName = key($collection->all());
118+
if ($invokeRouteName !== $class->name) {
119+
$collection->addAlias($class->name, $invokeRouteName);
120+
}
121+
122+
if ($invokeRouteName !== $aliasName = sprintf('%s::__invoke', $class->name)) {
123+
$collection->addAlias($aliasName, $invokeRouteName);
124+
}
117125
}
118126

119127
return $collection;

src/Symfony/Component/Routing/RouteCollection.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,15 @@ public function get(string $name): ?Route
142142
*/
143143
public function remove(string|array $name): void
144144
{
145-
foreach ((array) $name as $n) {
146-
unset($this->routes[$n], $this->priorities[$n], $this->aliases[$n]);
145+
$names = (array) $name;
146+
foreach ($names as $n) {
147+
unset($this->routes[$n], $this->priorities[$n]);
148+
}
149+
150+
foreach ($this->aliases as $k => $alias) {
151+
if (\in_array($alias->getId(), $names, true)) {
152+
unset($this->aliases[$k]);
153+
}
147154
}
148155
}
149156

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures;
4+
5+
use Symfony\Component\Routing\Attribute\Route;
6+
7+
/**
8+
* @Route("/foobarccc", name="Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\InvokableFQCNAliasConflictController")
9+
*/
10+
class InvokableFQCNAliasConflictController
11+
{
12+
public function __invoke()
13+
{
14+
}
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures;
4+
5+
use Symfony\Component\Routing\Attribute\Route;
6+
7+
#[Route(path: '/foobarccc', name: self::class)]
8+
class InvokableFQCNAliasConflictController
9+
{
10+
public function __invoke()
11+
{
12+
}
13+
}

src/Symfony/Component/Routing/Tests/Loader/AttributeClassLoaderTestCase.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ public function testInvokableControllerLoader()
9999
$this->assertEquals(new Alias('lol'), $routes->getAlias('Symfony\Component\Routing\Tests\Fixtures\AttributeFixtures\InvokableController::__invoke'));
100100
}
101101

102+
public function testInvokableFQCNAliasConflictController()
103+
{
104+
$routes = $this->loader->load($this->getNamespace().'\InvokableFQCNAliasConflictController');
105+
$this->assertCount(1, $routes);
106+
$this->assertEquals('/foobarccc', $routes->get($this->getNamespace().'\InvokableFQCNAliasConflictController')->getPath());
107+
$this->assertNull($routes->getAlias($this->getNamespace().'\InvokableFQCNAliasConflictController'));
108+
$this->assertEquals(new Alias($this->getNamespace().'\InvokableFQCNAliasConflictController'), $routes->getAlias($this->getNamespace().'\InvokableFQCNAliasConflictController::__invoke'));
109+
}
110+
102111
public function testInvokableMethodControllerLoader()
103112
{
104113
$routes = $this->loader->load(InvokableMethodController::class);

src/Symfony/Component/Routing/Tests/RouteCollectionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,13 @@ public function testRemove()
225225
$collection1->add('bar', $bar = new Route('/bar'));
226226
$collection->addCollection($collection1);
227227
$collection->add('last', $last = new Route('/last'));
228+
$collection->addAlias('ccc_my_custom_alias', 'foo');
228229

229230
$collection->remove('foo');
230231
$this->assertSame(['bar' => $bar, 'last' => $last], $collection->all(), '->remove() can remove a single route');
231232
$collection->remove(['bar', 'last']);
232233
$this->assertSame([], $collection->all(), '->remove() accepts an array and can remove multiple routes at once');
234+
$this->assertNull($collection->getAlias('ccc_my_custom_alias'));
233235
}
234236

235237
public function testSetHost()

src/Symfony/Component/VarExporter/LazyGhostTrait.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ public function &__get($name): mixed
108108
if ($state && (null === $scope || isset($propertyScopes["\0$scope\0$name"]))) {
109109
if (LazyObjectState::STATUS_INITIALIZED_FULL === $state->status) {
110110
// Work around php/php-src#12695
111-
$property = $propertyScopes[null === $scope ? $name : "\0$scope\0$name"][3]
112-
?? (Hydrator::$propertyScopes[$this::class] = Hydrator::getPropertyScopes($this::class))[3];
111+
$property = null === $scope ? $name : "\0$scope\0$name";
112+
$property = $propertyScopes[$property][3]
113+
?? Hydrator::$propertyScopes[$this::class][$property][3] = new \ReflectionProperty($scope ?? $class, $name);
113114
} else {
114115
$property = null;
115116
}

src/Symfony/Component/VarExporter/Tests/Fixtures/LazyGhost/ChildMagicClass.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,14 @@ class ChildMagicClass extends MagicClass implements LazyObjectInterface
1818
{
1919
use LazyGhostTrait;
2020

21+
private const LAZY_OBJECT_PROPERTY_SCOPES = [
22+
"\0".self::class."\0".'data' => [self::class, 'data', null],
23+
"\0".self::class."\0".'lazyObjectState' => [self::class, 'lazyObjectState', null],
24+
"\0".parent::class."\0".'data' => [parent::class, 'data', null],
25+
'cloneCounter' => [self::class, 'cloneCounter', null],
26+
'data' => [self::class, 'data', null],
27+
'lazyObjectState' => [self::class, 'lazyObjectState', null],
28+
];
29+
2130
private int $data = 123;
2231
}

0 commit comments

Comments
 (0)