yii2
yii2 copied to clipboard
Added PHPDoc type hinting for request and response properties of yii\base\Controller derived classes
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ❌ |
Breaks BC? | ❌ |
Fixed issues | See below |
class MyController extends \yii\web\Controller
{
public function f()
{
$this->request->cookieValidationKey = '123';
$this->response->content = '123';
}
}
In the example above the IDE (like PHPStorm) will rightfully complain that $this->request
is of class yii\base\Response
and does not have a member cookieValidationKey
. Same for response. This PR provides correct type hinting for IDE in PHPDoc comments.
@property
annotations are generated by release script, so this changes may be overwritten.
@property
annotations are generated by release script, so this changes may be overwritten.
What script? And why there is a script that messes up with manually written source code?
It generates @property
tags based on available getters and setters, so they're in sync.
It generates
@property
tags based on available getters and setters, so they're in sync.
Any script that touches MANUALLY written source code is a bad idea. A script that REMOVES manually written text from source code is much worse and must be getting rid of.
At most, a script can be used to provide diagnostic about potential problems with code style, etc, and not go and butcher what was written by a human.
https://github.com/yiisoft/yii2/blob/master/build/controllers/PhpDocController.php this one. It is running for years on each release.