PHPDoc e ligação tardia (estática ou dinâmica)
maioria dos IDEs PHP depende do phpdoc para obter dicas sobre o tipo de uma expressão. No entanto, uso frequentemente esse padrão, que não parece ser coberto:
class Control {
private $label = '';
/** @return ??? */
public static function Make(){ return new static(); }
/** @return ??? */
public function WithLabel($value){ $this->label = $value; return $this; }
/** @return void */
public function Render(){ /* ... */ }
}
class Textbox extends Control {
private $text = '';
/** @return ??? */
public function WithText($text){ $this->width = $text; return $this; }
}
Agora eu posso usar as classes assim:
Textbox::Make() // <-- late static binding, returns Textbox
->WithLabel('foo') // <-- late dynamic binding, returns Textbox
->WithText('bar') // <-- normal binding, returns Textbox
->Render();
Existe alguma maneira de substituir os '???' por algo para que as informações de digitação estejam corretas?