@@ -36,6 +36,7 @@ class Alias
36
36
protected $ classType = 'class ' ;
37
37
protected $ short ;
38
38
protected $ namespace = '__root ' ;
39
+ protected $ parentClass ;
39
40
protected $ root = null ;
40
41
protected $ classes = [];
41
42
protected $ methods = [];
@@ -87,6 +88,7 @@ public function __construct($config, $alias, $facade, $magicMethods = [], $inter
87
88
$ this ->detectNamespace ();
88
89
$ this ->detectClassType ();
89
90
$ this ->detectExtendsNamespace ();
91
+ $ this ->detectParentClass ();
90
92
91
93
if (!empty ($ this ->namespace )) {
92
94
try {
@@ -171,6 +173,25 @@ public function getExtendsNamespace()
171
173
return $ this ->extendsNamespace ;
172
174
}
173
175
176
+ /**
177
+ * Get the parent class of the class which this alias extends
178
+ *
179
+ * @return null|string
180
+ */
181
+ public function getParentClass ()
182
+ {
183
+ return $ this ->parentClass ;
184
+ }
185
+
186
+ /**
187
+ * Check if this class should extend the parent class
188
+ */
189
+ public function shouldExtendParentClass ()
190
+ {
191
+ return $ this ->parentClass
192
+ && $ this ->getExtendsNamespace () !== '\\Illuminate \\Support \\Facades ' ;
193
+ }
194
+
174
195
/**
175
196
* Get the Alias by which this class is called
176
197
*
@@ -268,6 +289,18 @@ protected function detectExtendsNamespace()
268
289
}
269
290
}
270
291
292
+ /**
293
+ * Detect the parent class
294
+ */
295
+ protected function detectParentClass ()
296
+ {
297
+ $ reflection = new ReflectionClass ($ this ->root );
298
+
299
+ $ parentClass = $ reflection ->getParentClass ();
300
+
301
+ $ this ->parentClass = $ parentClass ? '\\' . $ parentClass ->getName () : null ;
302
+ }
303
+
271
304
/**
272
305
* Detect the class type
273
306
*/
0 commit comments