问题
In Netbeans and phpStorm, this works as expected:
public function someMethod() {
$objectA = uberEnterprisyFactory('someclassA');
/* @var $objectA TheClassA */
// $objectA-> (autocomplete for TheClassA is displayed, good)
This does not:
public function someMethod() {
$this->objectA = uberEnterprisyFactory('somemodelA');
/* @var $this->objectA TheClassA */
// $this->objectA-> (no autocomplete here, not good, $this->objectA is inferred to be null)
How can I sugest type of $this->someThing
to Netbeans and/or phpStorm?
回答1:
Use the following PHPDoc annotation:
class MyClass {
/** * @var MyPropertyClass */ private $myProperty
}
来源:https://stackoverflow.com/questions/8750156/phpdoc-suggesting-type-for-this-somefield