-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AddVoidReturnTypeWhereNoReturnRector: fix never type handling (#4918)
* AddVoidReturnTypeWhereNoReturnRector: added failling tests * fix * use native type * fix PHPStan * fix * Update rules-tests/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Fixture/exception.php.inc Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com> * Update rules-tests/TypeDeclaration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Fixture/exception.php.inc Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com> --------- Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
- Loading branch information
1 parent
eca01b3
commit aee4200
Showing
5 changed files
with
82 additions
and
24 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...aration/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Fixture/exception.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use Rector\Core\Exception\ShouldNotHappenException; | ||
|
||
final class ThrowsException | ||
{ | ||
public function getValues() | ||
{ | ||
throw new ShouldNotHappenException(); | ||
} | ||
} | ||
----- | ||
<?php | ||
|
||
use Rector\Core\Exception\ShouldNotHappenException; | ||
|
||
final class ThrowsException | ||
{ | ||
public function getValues(): void | ||
{ | ||
throw new ShouldNotHappenException(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...tion/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Fixture/never_method.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector\Fixture; | ||
|
||
final class ExitMethod | ||
{ | ||
protected function getValues() | ||
{ | ||
exit(); | ||
} | ||
} | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector\Fixture; | ||
|
||
final class ExitMethod | ||
{ | ||
protected function getValues(): void | ||
{ | ||
exit(); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
...on/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Fixture/skip_exception.php.inc
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
...ion/Rector/ClassMethod/AddVoidReturnTypeWhereNoReturnRector/Fixture/throws_method.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector\Fixture; | ||
|
||
final class ThrowsMethod | ||
{ | ||
protected function getValues() | ||
{ | ||
if (rand(0,1)) { | ||
throw new \Exception(); | ||
} | ||
|
||
echo 'hello world'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector\Fixture; | ||
|
||
final class ThrowsMethod | ||
{ | ||
protected function getValues(): void | ||
{ | ||
if (rand(0,1)) { | ||
throw new \Exception(); | ||
} | ||
|
||
echo 'hello world'; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters