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

Calling __construct() from __construct() is legit #8868

Closed
mvorisek opened this issue Feb 9, 2023 · 2 comments
Closed

Calling __construct() from __construct() is legit #8868

mvorisek opened this issue Feb 9, 2023 · 2 comments

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Feb 9, 2023

Feature request

https://phpstan.org/r/98db148b-7483-4b67-aac4-6adf615b803f

when $this->__construct() is called from self::__construct(), there is nothing wrong and this patten is usual when the data needs to be modified first and the whole method "restarted"

currently it is reported with bleading edge & strict rules only

the rule itself should stay when $this->__construct() is called NOT from `self::__construct()

@mvorisek
Copy link
Contributor Author

mvorisek commented Feb 9, 2023

/cc @muno92 as you originally authored it in phpstan/phpstan-src#1208

@ondrejmirtes
Copy link
Member

This is turned on only in strict-rules.

From the README: "Extra strict and opinionated rules for PHPStan"

My opinion is that you should never call __construct like that.

@phpstan phpstan locked as resolved and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants