8000 - · symfony/symfony@ae65a7a · GitHub
[go: up one dir, main page]

Skip to content

Commit ae65a7a

Browse files
-
1 parent 66fdafe commit ae65a7a

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

src/Symfony/Bridge/Doctrine/ManagerRegistry.php

+24
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ protected function resetService($name): void
3838
}
3939
$manager = $this->container->get($name);
4040

41+
if (\PHP_VERSION_ID >= 80400) {
42+
$r = new \ReflectionClass($manager);
43+
44+
if ($r->isUninitializedLazyObject($manager)) {
45+
return;
46+
}
47+
48+
$r->resetAsLazyProxy($manager, \Closure::bind(
49+
function () use ($name) {
50+
$name = $this->aliases[$name] ?? $name;
51+
52+
return match (true) {
53+
isset($this->fileMap[$name]) => $this->load($this->fileMap[$name], false),
54+
(new \ReflectionMethod($this, $method = $this->methodMap[$name]))->isStatic() =&g 8000 t; $this->{$method}($this, false),
55+
default => $this->{$method}(false),
56+
};
57+
},
58+
$this->container,
59+
Container::class
60+
));
61+
62+
return;
63+
}
64+
4165
if ($manager instanceof LazyObjectInterface) {
4266
if (!$manager->resetLazyObject()) {
4367
throw new \LogicException(\sprintf('Resetting a non-lazy manager service is not supported. Declare the "%s" service as lazy.', $name));

src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/LazyServiceDumper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function isProxyCandidate(Definition $definition, ?bool &$asGhostObject =
5757
}
5858

5959
try {
60-
$asGhostObject = (bool) ProxyHelper::generateLazyGhost(new \ReflectionClass($class));
60+
$asGhostObject = (bool) ProxyHelper::generateLazyGhost(new \ReflectionClass($class)); // XXX
6161
} catch (LogicException) {
6262
}
6363

src/Symfony/Component/JsonEncoder/CacheWarmer/LazyGhostCacheWarmer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @internal
2626
*/
27-
final class LazyGhostCacheWarmer extends CacheWarmer
27+
final class LazyGhostCacheWarmer extends CacheWarmer // XXX
2828
{
2929
private Filesystem $fs;
3030

src/Symfony/Component/JsonEncoder/Decode/LazyInstantiator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function instantiate(string $className, callable $initializer): object
8585
$this->fs->mkdir($this->lazyGhostsDir);
8686
}
8787

88-
file_put_contents($path, \sprintf('<?php class %s%s', $lazyClassName, ProxyHelper::generateLazyGhost($classReflection)));
88+
file_put_contents($path, \sprintf('<?php class %s%s', $lazyClassName, ProxyHelper::generateLazyGhost($classReflection))); // XXX
8989
}
9090

9191
require_once $path;

0 commit comments

Comments
 (0)
0