Home  >  Article  >  Backend Development  >  laravel - When developing Yii2 or other PHP frameworks, how to write comments for the framework non-intrusively?

laravel - When developing Yii2 or other PHP frameworks, how to write comments for the framework non-intrusively?

WBOY
WBOYOriginal
2016-08-22 11:45:40899browse

Many components or properties in the Yii2 framework are dynamically loaded through configuration files.
This results in many third-party components being unable to use the IDE's automatic completion and type checking.
For exampleYii::$app->user->getIdentity() should return the User model I defined in the configuration file.
But there is no way for the IDE to identify this configuration. As a result, in many methods, if the parameter type is restricted like public function verify(User $user), the IDE will report an error.
The Laraverl framework has tools like ide-helper to help the IDE identify the framework. I wonder if there is any way to solve this problem in Yii2?

Reply content:

Many components or properties in the Yii2 framework are dynamically loaded through configuration files.
This results in many third-party components being unable to use the IDE's automatic completion and type checking.
For exampleYii::$app->user->getIdentity() should return the User model I defined in the configuration file.
But the IDE has no way to identify this configuration, which leads to many methods like public function verify(User $user)limiting the parameter type IDE will report an error.
The Laraverl framework has tools like ide-helper to help the IDE identify the framework. I wonder if there is any way to solve this problem in Yii2?

There is already a solution. The author can refer to this phpstorm yii2 tip

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn