-
Notifications
You must be signed in to change notification settings - Fork 534
More precise phpdocs in Container-Interface/Classes #759
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
Conversation
the phpdoc change is helpful to make phpstorm (and phpstan) aware of the type beeing returned by not sure such a phpdoc change is considered a BC break, as it leads to static-analysis time errors when implemented in downstream code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpstan reports
Method PHPStan\DependencyInjection\Nette\NetteContainer::getByType() should return T of object but returns object.
I dont know how to fix that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added the stub. now I get
Method PHPStan\DependencyInjection\Nette\NetteContainer::getByType() should return T of object but returns T of object.
which seems to be a phpstan bug?
btw: nette-di has newer releases and the latest 3.0.11 has a proper phpdoc for this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now I committed a workaround, which no longer requires the stubfile - since I was not able to resolve the error mentioned in the comment above.
I figured the problem regarding "should return T of object but returns T of object." should be solved in a separate PR...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dislike inline @var
when there can be a better solution: https://phpstan.org/writing-php-code/phpdocs-basics#inline-%40var
So I'd like the stub file much more. And this PR is fine, it's called "More precise phpdocs in Container".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I reverted the last 3 commits and we are back at the point
Method PHPStan\DependencyInjection\Nette\NetteContainer::getByType() should return T of object but returns T of object.
stubs/nette-di.stub
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot there's already an extension for this method: https://github.com/phpstan/phpstan-src/blob/master/build/PHPStan/Build/ServiceLocatorDynamicReturnTypeExtension.php
So we actually don't need a stub, but to fix this extension. I did it on master: 12973cd
So you can rebase your branch, remove the stub and any unrelated changes, and it should be fine, hopefully.
… not subtype of Throwable"
This reverts commit 3ba82ab592db3ee4c01821876756f71ea743a366.
This reverts commit 4dedd13ab90c0f2c94a98c31015f60d5b5323c36.
This reverts commit 3e2dbef35d8f62fb6135440d3e682777c0f7e6de.
This reverts commit f35aa82ec216d3a696213067ebd65acec9929601.
This reverts commit 011b586.
Looks like we're hitting some weird bug here. |
Alright, figured out a working version: 9384783 Thank you. |
thank for finishing and sorry for opening such a can of worms, for such a "small change". but I think its worth it. |
It is definitely :) |
No description provided.