Class Composition Hinting
Is there any way to get property/method hinting when using composition? Hinting has worked great so far but when I tried to test some code I noticed that it didn't give me any hinting from composition. The object has a lot of methods/properties so hinting would be really useful. Is there any option or way to get it to give me some hinting when using composition?
new main();
class main{
protected $buffer;
public function __construct(){
$this->startup();
$this->main();
}
protected function startup(){
$this->buffer = new pri\buffer();
}
public function main(){
$this->buffer->????
}
???? = one of the many methods/properties in my object
请先登录再写评论。
Hi there,
PHPDoc?
P.S.
@var is considered deprecated (as of PhpDocumentor v2) -- you can use @type instead (although @var still will be supported for a loooong time -- for compatibility reasons).
https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#824-var-deprecated
Found out what the problem was. If I put the "new object" in the constructor then PHPStorm reads it but if it is a method in the constructor it doesn't read it.
Works:
Doesn't Work:
public function __construct(){ $this->startup(); } protected function startup(){ $this->buffer = new pri\buffer(); }Property assignments in constructors have some extra special treatment compared to the same in other methods.
PHPDoc comments solves such "problems" regardless of where property assigment is located.