for example

require_once "../Request.php"; class Test { protected $token = ''; protected $botname = ''; protected Request $request; //// тут ошибка } 
  • one
    Looks like no. Apparently only in the arguments of the methods you can use - Alexey Shimansky

2 answers 2

Not. Not possible There is such a proposal for PHP 7.x but there is no approval for implementation yet. Read more here.

If you need to set a specific value for a property then use the class methods. for example

 public method setRequest( Request $request ) { $this->request = $request; } 

    If the goal is to get clues from the IDE, you can write this:

     /** * @var Request */ protected $request; ...