How to explicitly declare var member type in php class

If I can explicitly declare the type of the var member (esp. Another class as a member), then their IDE (for example, Dreamweaver) can know the member.

class PHPClass(){ OtherClass $member_var; } 
+6
source share
2 answers

The only way is to use this documentation:

 class MyClass { /** * @var OtherClass This is my other class */ private $other; } 
+12
source

You cannot do this in PHP, but you can get closer using the hinting type :

 class PHPClass { protected $member_var; public function __construct(OtherClass $member) { $this->member_var = $member; } } 

I do not know if this will help you in Dreamweaver.

+5
source

Source: https://habr.com/ru/post/914537/


All Articles