This post is due to some difficulty I am having extending a class defined in a first namespace from a second namespace. Based on this post :
PHP how to import all classes from another namespace
I tried this :
File NameSpace1 :
<?php
namespace FirstNS;
class baseObject
{
public $baseVar = 1;
public function baseFun() {}
}
?>
File NameSpace2 :
<?php
namespace SecondNS;
use FirstNS;
class extendedObject extends FirstNS\baseObject {
public $extendedVar = 1;
public function extendedFun() {
}
}
?>
However $this in extendedFun can only access $extendedVar and extendedFun, not $baseVar and baseFun. I have also tried use FirstNS as ClassFromFirstNS; and class extendedObject extends ClassFromFirstNS however $baseVar and baseFun are still not accessible via $this. The information at http://www.php.net/manual/en/language.namespaces.rationale.php, http://www.php.net/manual/en/language.namespaces.definition.php and http://www.php.net/manual/en/language.namespaces.importing.php also did not seem to directly address this case.
$object = new baseObject()or$object = new extendedObject()?