@@ -36,6 +36,7 @@ class Alias
3636 protected $ classType = 'class ' ;
3737 protected $ short ;
3838 protected $ namespace = '__root ' ;
39+ protected $ parentClass ;
3940 protected $ root = null ;
4041 protected $ classes = [];
4142 protected $ methods = [];
@@ -87,6 +88,7 @@ public function __construct($config, $alias, $facade, $magicMethods = [], $inter
8788 $ this ->detectNamespace ();
8889 $ this ->detectClassType ();
8990 $ this ->detectExtendsNamespace ();
91+ $ this ->detectParentClass ();
9092
9193 if (!empty ($ this ->namespace )) {
9294 try {
@@ -171,6 +173,25 @@ public function getExtendsNamespace()
171173 return $ this ->extendsNamespace ;
172174 }
173175
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+
174195 /**
175196 * Get the Alias by which this class is called
176197 *
@@ -268,6 +289,18 @@ protected function detectExtendsNamespace()
268289 }
269290 }
270291
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+
271304 /**
272305 * Detect the class type
273306 */
0 commit comments