Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PowerGamer1
Copy link
Contributor

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.

@rob006
Copy link
Contributor

rob006 commented Oct 15, 2023

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

@PowerGamer1
Copy link
Contributor Author

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

@rob006
Copy link
Contributor

rob006 commented Oct 16, 2023

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

@PowerGamer1
Copy link
Contributor Author

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.

@samdark
Copy link
Member

samdark commented Oct 19, 2023

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

@samdark samdark added this to the 2.0.50 milestone Oct 19, 2023
@samdark samdark removed this from the 2.0.50 milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants