Skip to content

Commit

Permalink
fixup! fixup! [PHP 8.1] Add ReturnNeverTypeRector
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 2, 2021
1 parent 8df1f7b commit dba460f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture;

final class DieSome
{
public function run()
{
echo 100;
die;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture;

final class DieSome
{
public function run(): never
{
echo 100;
die;
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture;

final class ExitSome
{
public function run()
{
echo 100;
exit;
}
}

?>
-----
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture;

final class ExitSome
{
public function run(): never
{
echo 100;
exit;
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public function refactor(Node $node): ?Node
return null;
}

$neverNodes = $this->betterNodeFinder->findInstancesOf($node, [Node\Expr\Throw_::class, Throw_::class]);
$neverNodes = $this->betterNodeFinder->findInstancesOf(
$node,
[Node\Expr\Throw_::class, Throw_::class, Node\Expr\Exit_::class]
);

$hasNeverFuncCall = $this->resolveHasNeverFuncCall($node);
if (count($neverNodes) === 0 && $hasNeverFuncCall === false) {
Expand Down

0 comments on commit dba460f

Please sign in to comment.