@@ -38,8 +38,7 @@ public static function preload(array $classes)
38
38
$ prev = $ classes ;
39
39
foreach ($ classes as $ c ) {
40
40
if (!isset ($ preloaded [$ c ])) {
41
- $ preloaded [$ c ] = true ;
42
- self ::doPreload ($ c );
41
+ self ::doPreload ($ c , $ preloaded );
43
42
}
44
43
}
45
44
$ classes = array_merge (get_declared_classes (), get_declared_interfaces (), get_declared_traits ());
@@ -49,12 +48,14 @@ public static function preload(array $classes)
49
48
}
50
49
}
51
50
52
- private static function doPreload (string $ class )
51
+ private static function doPreload (string $ class, array & $ preloaded )
53
52
{
54
- if (\in_array ($ class , ['self ' , 'static ' , 'parent ' ], true )) {
53
+ if (isset ( $ preloaded [ $ class ]) || \in_array ($ class , ['self ' , 'static ' , 'parent ' ], true )) {
55
54
return ;
56
55
}
57
56
57
+ $ preloaded [$ class ] = true ;
58
+
58
59
try {
59
60
$ r = new \ReflectionClass ($ class );
60
61
@@ -68,7 +69,7 @@ private static function doPreload(string $class)
68
69
if (\PHP_VERSION_ID >= 70400 ) {
69
70
foreach ($ r ->getProperties () as $ p ) {
70
71
if (($ t = $ p ->getType ()) && !$ t ->isBuiltin ()) {
71
- self ::doPreload ($ t ->getName ());
72
+ self ::doPreload ($ t ->getName (), $ preloaded );
72
73
}
73
74
}
74
75
}
@@ -79,17 +80,17 @@ private static function doPreload(string $class)
79
80
$ c = $ p ->getDefaultValueConstantName ();
80
81
81
82
if ($ i = strpos ($ c , ':: ' )) {
82
- self ::doPreload (substr ($ c , 0 , $ i ));
83
+ self ::doPreload (substr ($ c , 0 , $ i ), $ preloaded );
83
84
}
84
85
}
85
86
86
87
if (($ t = $ p ->getType ()) && !$ t ->isBuiltin ()) {
87
- self ::doPreload ($ t ->getName ());
88
+ self ::doPreload ($ t ->getName (), $ preloaded );
88
89
}
89
90
}
90
91
91
92
if (($ t = $ m ->getReturnType ()) && !$ t ->isBuiltin ()) {
92
- self ::doPreload ($ t ->getName ());
93
+ self ::doPreload ($ t ->getName (), $ preloaded );
93
94
}
94
95
}
95
96
} catch (\ReflectionException $ e ) {
0 commit comments