-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
ReturnNeverTypeRector: use @return never
for php7.x support
#296
Conversation
...ts/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/parent_protected.php.inc
Outdated
Show resolved
Hide resolved
packages/PHPStanStaticTypeMapper/TypeMapper/NeverTypeMapper.php
Outdated
Show resolved
Hide resolved
rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/config/configured_rule.php
Outdated
Show resolved
Hide resolved
@TomasVotruba this should be good to go |
packages/BetterPhpDocParser/PhpDocManipulator/PhpDocTypeChanger.php
Outdated
Show resolved
Hide resolved
rules/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector.php
Outdated
Show resolved
Hide resolved
/** | ||
* @return never | ||
*/ | ||
public function run() | ||
{ | ||
throw new InvalidException(); | ||
} |
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 one has lover priority, code samples should promote the highest PHP availble, if they're using native PHP feature. E.g. TypedPropertyRector uses native types, even though @var
is possible too. But that was not the reason for making the rule. The original "why" should be respected
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.
E.g. TypedPropertyRector uses native types, even though
@var
is possible too. But that was not the reason for making the rule. The original "why" should be respected
so you mean when running this rector on php8 it should add :never
but when running on php7.x it should add @return never
, right?
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.
Yes, the PHP version is configurable in config for the test case
rebased and green, which meens #306 fixed the underlying problem we saw initially. 👍 going back to the open issue:
is there another rector which I can take inspiration from, on how to separate the test-fixtures by php version? |
Yes, look for files |
just separated the PHP7.2 tests from the PHP8.1+ tests. two remaining problems:
feedback welcome |
/** | ||
* @param ClassMethod|Function_ $node | ||
*/ | ||
private function shouldSkip($node):bool { |
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.
extracted a shouldSkip()
to reduce refactor()
complexity
@TomasVotruba all green now after rebase ƪ(˘⌣˘)ʃ |
Thank you, looks good 🙂 👍 |
this PR changes the
ReturnNeverTypeRector
to use@return never
which can safely be used on php7.xas discussed in rectorphp/rector#6283 (comment)