-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
[Downgrade PHP 7.0] Move Throwable out of type hints #1602
Conversation
This is a first part of work to be able to use latest Tracy on PHP 5.6. I need it for selfoss RSS reader, which still targets PHP 5.6 through 8.1. I also want to migrate |
rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php
Show resolved
Hide resolved
Hi, thanks for the new rule. I wonder if |
The issue is that it is not a straightforward renaming. Especially when we want the resulting code to support both PHP 5 and PHP 7. (I am not even sure if we should make it part of downgrade set.) Though maybe we could have something like |
I see. In that way custom rule might be a way to go 👍 |
eab6b55
to
2ac627c
Compare
* @param \Throwable|null $anything | ||
* @return \Throwable|null |
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.
This does not preserve formatting (changes ?\Throwable
to \Throwable|null
. But that is probably fine.
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.
that's actually fine https://phpstan.org/r/5c17f3ca-4b93-44e4-9597-b21bb9b784c5 , improvement maybe in separate PR.
public function getRuleDefinition(): RuleDefinition | ||
{ | ||
return new RuleDefinition( | ||
'Remove `Throwable` return type, add a `@return Throwable` tag instead', |
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.
Reading the docs again, we need to mention that it does params too.
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.
And it looks like the examples are not tested since I based this on DowngradeSelfTypeDeclarationRector
and it does not have the documentation comment either.
rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php
Outdated
Show resolved
Hide resolved
rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php
Outdated
Show resolved
Hide resolved
It is only available on PHP 7.0+: https://www.php.net/manual/en/class.throwable.php
Thank you @jtojnar |
It is only available on PHP 7.0+:
https://www.php.net/manual/en/class.throwable.php