Skip to content
Permalink
Browse files

bug #33525 [DI] fix Preloader (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[DI] fix Preloader

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/32032/files#r322150801
| License       | MIT
| Doc PR        | -

Commits
-------

4cc8641 [DI] fix Preloader
  • Loading branch information...
fabpot committed Sep 10, 2019
2 parents 3f0cf49 + 4cc8641 commit 1c3d4094904211555cddc4c279d41f55556393c0
Showing with 9 additions and 8 deletions.
  1. +9 −8 src/Symfony/Component/DependencyInjection/Dumper/Preloader.php
@@ -38,8 +38,7 @@ public static function preload(array $classes)
$prev = $classes;
foreach ($classes as $c) {
if (!isset($preloaded[$c])) {
$preloaded[$c] = true;
self::doPreload($c);
self::doPreload($c, $preloaded);
}
}
$classes = array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
@@ -49,12 +48,14 @@ public static function preload(array $classes)
}
}
private static function doPreload(string $class)
private static function doPreload(string $class, array &$preloaded)
{
if (\in_array($class, ['self', 'static', 'parent'], true)) {
if (isset($preloaded[$class]) || \in_array($class, ['self', 'static', 'parent'], true)) {
return;
}
$preloaded[$class] = true;
try {
$r = new \ReflectionClass($class);
@@ -68,7 +69,7 @@ private static function doPreload(string $class)
if (\PHP_VERSION_ID >= 70400) {
foreach ($r->getProperties() as $p) {
if (($t = $p->getType()) && !$t->isBuiltin()) {
self::doPreload($t->getName());
self::doPreload($t->getName(), $preloaded);
}
}
}
@@ -79,17 +80,17 @@ private static function doPreload(string $class)
$c = $p->getDefaultValueConstantName();
if ($i = strpos($c, '::')) {
self::doPreload(substr($c, 0, $i));
self::doPreload(substr($c, 0, $i), $preloaded);
}
}
if (($t = $p->getType()) && !$t->isBuiltin()) {
self::doPreload($t->getName());
self::doPreload($t->getName(), $preloaded);
}
}
if (($t = $m->getReturnType()) && !$t->isBuiltin()) {
self::doPreload($t->getName());
self::doPreload($t->getName(), $preloaded);
}
}
} catch (\ReflectionException $e) {

0 comments on commit 1c3d409

Please sign in to comment.
You can’t perform that action at this time.