嘿伙计们,我有一个问题,我认为是因为名称空间的原因,我有我的父类TheParent
,我在其中做一些事情,将它添加到$this
然后扩展到一个子类,期望它$this
会继承,但是除了明确的内容之外的所有内容父母构造函数中提到的似乎消失了($timeout = 10
)我试图弄清楚我在哪里编写了这段代码,如果有人可以向我解释为什么这不像我认为的那样工作?
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',
);
}
}
这是返回的其余对象,您会认为我还会有数据,TheParent
其中_appKey
在传递给之前已经定义了诸如此类的东西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
(
)
)