Jump to content

Accessing parent's namespace


NotionCommotion

Recommended Posts

Is it possible to have a class access another class it its parent directory without using a fully qualified name?  While the following script is not valid, it is how I would have thought it would be done should it be possible.  If it is not possible, I expect there is a good reason why one would not want to do so, and would appreciate your thoughts why that is so.  Thanks

// src/PrimaryTopic/SubTopic/SubSubTopic/ParentClass.php
namespace PrimaryTopic\SubTopic\SubSubTopic;
class ParentClass {}

// src/PrimaryTopic/SubTopic/SubSubTopic/Child/ChildClass1.php
namespace PrimaryTopic\SubTopic\SubSubTopic\Child;
class ChildClass1 extends ..\ParentClass {}

// src/PrimaryTopic/SubTopic/SubSubTopic/Child/ChildClass2.php
namespace PrimaryTopic\SubTopic\SubSubTopic\Child;
class ChildClass2 extends ..\ParentClass {}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.