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

[TypeDeclaration] AddVoidReturnTypeWhereNoReturnRector turns @return never into less specific @return void #1553

Merged
merged 5 commits into from
Dec 23, 2021

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Dec 23, 2021

@staabm staabm changed the title added failling test AddVoidReturnTypeWhereNoReturnRector turns @return never into less specific @return void Dec 23, 2021
Comment on lines +16 to +41
/**
* @return never-return
*/
public function neverReturn()
{
header('Location: example.com');
exit();
}

/**
* @return never-returns
*/
public function neverReturns()
{
header('Location: example.com');
exit();
}

/**
* @return no-return
*/
public function noReturn()
{
header('Location: example.com');
exit();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems rector does not support all "aliases" of the bottom-type phpstan supports:

https://phpstan.org/writing-php-code/phpdoc-types#bottom-type

only @return never is turned into the NeverType ..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the latest commit

@staabm staabm marked this pull request as ready for review December 23, 2021 13:35
@staabm staabm changed the title AddVoidReturnTypeWhereNoReturnRector turns @return never into less specific @return void [StaticTypeMapper] AddVoidReturnTypeWhereNoReturnRector turns @return never into less specific @return void Dec 23, 2021
@staabm staabm changed the title [StaticTypeMapper] AddVoidReturnTypeWhereNoReturnRector turns @return never into less specific @return void [TypeDeclaration] AddVoidReturnTypeWhereNoReturnRector turns @return never into less specific @return void Dec 23, 2021
@@ -36,7 +36,7 @@ final class ScalarStringToTypeMapper
ResourceType::class => ['resource'],
CallableType::class => ['callback', 'callable'],
ObjectWithoutClassType::class => ['object'],
NeverType::class => ['never'],
NeverType::class => ['never', 'never-return', 'never-returns', 'no-return'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samsonasik samsonasik merged commit 39580db into rectorphp:main Dec 23, 2021
@samsonasik
Copy link
Member

Thank you @staabm

@staabm staabm deleted the never-void branch December 23, 2021 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants