NotionCommotion Posted February 23, 2019 Share Posted February 23, 2019 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 More sharing options...
requinix Posted February 24, 2019 Share Posted February 24, 2019 Not like that, no. use PrimaryTopic\SubTopic\SubSubTopic\ParentClass; class ChildClass1 extends ParentClass { Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.