Hey guys I'm having an issue that I think is because due to namespaces, I have my parent class TheParent
where I do some stuff, add it to $this
then extend to a child class expecting that $this
will carry over, but everything inside except what is explicitly mentioned in the parents constructor seems to vanish (the $timeout = 10
) I'm trying to figure out where I borked this code at, and if anyone could explain it to me why this is not working like I would think it should?
Namespace Services;
Class TheParent
{
public function __construct($timeout = 10, array $options = array())
{
$this->setAuth($options)->setTimeout($timeout);
}
// other methods that put information into $this
public function useRest()
{
require_once 'RestAggregator.php'
$this->message = REST::getInstance();
header('Content-Type: text/plain');
print_r($this); die;
}
}
Namespace Services;
Class REST Extends TheParent
{
private static $instance = NULL;
private $messages = array();
public function __construct()
{
$this->messages = self::getDataMessages();
}
public static function getInstance()
{
if(! isset(REST::$instance))
{
REST::$instance = New REST();
}
return REST::$instance;
}
protected function getDataMessages()
{
return REST::$instance->messages = array(
'foo' => '4',
'bar' => '5',
'baz' => '6',
);
}
}
This is the rest object returned, you would THINK that I would also have data from TheParent
which is where things like _appKey
etcetera have already been defined before being passed to REST
Services\REST Object
(
[type] =>
[messages:Services\REST:private] => Array
(
)
[groups:Services\REST:private] => Array
(
)
[_following:protected] =>
[_sent:protected] =>
[_private:protected] =>
[_received:protected] =>
[_appKey:protected] =>
[_appSecret:protected] =>
[_authToken:protected] =>
[_authSecret:protected] =>
[_authCode:protected] =>
[_redirectUri:protected] =>
[_smAuth:protected] =>
[_accessToken:protected] =>
[_tigerToken:protected] =>
[_data:protected] =>
[_timeout:protected] => 10
[_cookieJar:protected] =>
[dbh] =>
[opts] => Array
(
)
)