yii2 icon indicating copy to clipboard operation
yii2 copied to clipboard

Added PHPDoc type hinting for request and response properties of yii\base\Controller derived classes

Open PowerGamer1 opened this issue 1 year ago • 5 comments

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.

PowerGamer1 avatar Oct 15 '23 09:10 PowerGamer1

@property annotations are generated by release script, so this changes may be overwritten.

rob006 avatar Oct 15 '23 16:10 rob006

@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?

PowerGamer1 avatar Oct 16 '23 08:10 PowerGamer1

It generates @property tags based on available getters and setters, so they're in sync.

rob006 avatar Oct 16 '23 09:10 rob006

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.

PowerGamer1 avatar Oct 16 '23 10:10 PowerGamer1

https://github.com/yiisoft/yii2/blob/master/build/controllers/PhpDocController.php this one. It is running for years on each release.

samdark avatar Oct 19 '23 17:10 samdark