Есть класс
class ContentHandler{
private $context;
public function __constructor(AppContext $context){
if($context == null) echo 'BEGINNULL2_';
$this->context = $context;
if($this->context == null) echo 'BEGINNULL3_';
}
public function getContext():AppContext{
return $this->context;
}
public function parse($resource, $isContent = false){
if($this->getContext() == null) echo 'NULL0_';
return $this->deployModules($content);
}
}
Получаю ошибку
Fatal error: Uncaught TypeError: Return value of ContentHandler::getContext() must be an instance of AppContext, null returned in /Library/WebServer/Documents/ingine2/classes/ContentHandler.php:14
AppContext обычный класс
class AppContext {
private $headers;
private $params;
private $session;
private $dbConn;
private $requestCookies;
private $responseCookies;
public function __construct($headers, $params, $cookies, $dbConn){
$this->headers = $headers;
$this->params = $params;
// nice urls
// qs contains trailing nice url except first /resourcename/
if(strlen($this->getParam('qs'))) {
$qsparams = explode('/',$this->getParam('qs'));
for($i=0;$i<count($qsparams);$i+=2)
$this->params[$qsparams[$i]] = $qsparams[$i+1];
}
$this->requestCookies = $cookies;
$this->dbConn = $dbConn;
$this->session = []; // TODO initiate and restore session
}
public function getParam($paramName){
return (isset($this->params[$paramName])?$this->params[$paramName]:false);
}
public function getHeader($headerName){
return (isset($this->headers[$headerName])?$this->headers[$headerName]:false);
}
public function getCookie($cookieName){
return $this->requestCookies[$cookieName];
}
public function setCookie($cookieName, $value){
return $this->responseCookies[$cookieName] = $value;
}
public function getSessionParam($paramName){
return $this->session[$paramName];
}
public function setSessionParam($paramName, $value){
$this->session[$paramName] = $value;
}
}