I have this code:
class X{
}
class Y{
private $x;
public function printx(){
echo $this->x;
}
}
PHPStorm hints on private $x:
Missing property's type declaration
But when I wrote type private X $x;, error in runtime:
Parse error: syntax error, unexpected 'X' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Completed code is:
class X{
}
class Y{
private X $x;
public function printx(){
echo $this->x;
}
}
My PHP version is 7.3.6. Where is the problem? How to set type of class member?
Thanks