php - Code completion in injected classes -



php - Code completion in injected classes -

here sample code want get, in user class no codecompletion (for $this->app) in phpsotrm. how alter code enable code completion? want avoid global.

namespace myapp class app { public $pdo = "my pdo"; public function __construct() { $this->user=new user($this); $this->test=new test($this); echo $this->user->getpdo(); //"my pdo" echo $this->test->getuserpdo(); //"my pdo" } } class user { private $app=null; public function __construct($app) { $this->app=$app; } public function getpdo() { homecoming $this->app->pdo; //no code completion } } class test { private $app=null; public function __construct($app) { $this->app=$app; } public function getuserpdo() { homecoming $this->app->user->getpdo; //no code completion } }

there's plenty of info on how accomplish this. need add together phpdoc describing property type.

class user { /** * @var app */ private $app=null; /** * @param app $app */ public function __construct($app) { $this->app = $app; } /** * @return pdo */ public function getpdo() { homecoming $this->app->pdo; } }

if properties implemented via magic getters / setters, can utilize same principles on class itself.

/** * @property app $app * @method pdo getpdo() */ class user { // …

php phpstorm

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -