我正在从Eclipse切换到PhpStorm,并注意到我在这段代码中不会得到类型提示:
class Bar{
public function hintMe(){...}
}
class Foo{
private $bars = array();
/**
* @return Bar
*/
public function getBar($pos){
$this->bars[$x] = new Bar();
return $this->bars[$x];
}
}
$foo = new Foo();
$bar = $foo->getBar(2);
$bar->__hint-should-appear__
在Eclipse中,当键入$bar->
时,提示将处于活动状态,但在PhpStorm中不会。有什么想法为什么它不起作用吗?
尝试在"*"之前使用空格,如
class Foo{
/**
* @var Bar[]
*/
private $bars = array();
/**
* @param integer $pos
* @return Bar
*/
public function getBar($pos){
$this->bars[$x] = new Bar();
return $this->bars[$x];
}
}
$foo = new Foo();
$bar = $foo->getBar(2);