@@ -148,45 +148,17 @@ private function populateAvailableType($id, Definition $definition)
148
148
$ this ->types [$ type ] = $ id ;
149
149
}
150
150
151
- // Cannot use reflection if the class isn't set
152
- if (!$ definition ->getClass ()) {
151
+ if (!$ reflectionClass = $ this ->getReflectionClass ($ id , $ definition )) {
153
152
return ;
154
153
}
155
154
156
- if ($ reflectionClass = $ this ->getReflectionClass ($ id , $ definition )) {
157
- $ this ->extractInterfaces ($ id , $ reflectionClass );
158
- $ this ->extractAncestors ($ id , $ reflectionClass );
159
- }
160
- }
161
-
162
- /**
163
- * Extracts the list of all interfaces implemented by a class.
164
- *
165
- * @param string $id
166
- * @param \ReflectionClass $reflectionClass
167
- */
168
- private function extractInterfaces ($ id , \ReflectionClass $ reflectionClass )
169
- {
170
- foreach ($ reflectionClass ->getInterfaces () as $ interfaceName => $ reflectionInterface ) {
171
- $ this ->set ($ interfaceName , $ id );
172
-
173
- $ this ->extractInterfaces ($ id , $ reflectionInterface );
155
+ foreach ($ reflectionClass ->getInterfaces () as $ reflectionInterface ) {
156
+ $ this ->set ($ reflectionInterface ->name , $ id );
174
157
}
175
- }
176
-
177
- /**
178
- * Extracts all inherited types of a class.
179
- *
180
- * @param string $id
181
- * @param \ReflectionClass $reflectionClass
182
- */
183
- private function extractAncestors ($ id , \ReflectionClass $ reflectionClass )
184
- {
185
- $ this ->set ($ reflectionClass ->name , $ id );
186
158
187
- if ( $ reflectionParentClass = $ reflectionClass -> getParentClass ()) {
188
- $ this ->extractAncestors ( $ id , $ reflectionParentClass );
189
- }
159
+ do {
160
+ $ this ->set ( $ reflectionClass -> name , $ id );
161
+ } while ( $ reflectionClass = $ reflectionClass -> getParentClass ());
190
162
}
191
163
192
164
/**
@@ -256,6 +228,7 @@ private function getReflectionClass($id, Definition $definition)
256
228
return $ this ->reflectionClasses [$ id ];
257
229
}
258
230
231
+ // Cannot use reflection if the class isn't set
259
232
if (!$ class = $ definition ->getClass ()) {
260
233
return ;
261
234
}
0 commit comments