-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51401aa
commit 7fc055c
Showing
18 changed files
with
448 additions
and
3 deletions.
There are no files selected for viewing
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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
$services->set(ReturnNeverTypeRector::class); | ||
}; |
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
29 changes: 29 additions & 0 deletions
29
...s-tests/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/die_some.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,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; | ||
} | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
...-tests/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/exit_some.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,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; | ||
} | ||
} | ||
|
||
?> |
31 changes: 31 additions & 0 deletions
31
...sts/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/improve_void.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,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
use Rector\Core\Exception\ShouldNotHappenException; | ||
|
||
final class ImproveVoid | ||
{ | ||
public function run(): void | ||
{ | ||
throw new ShouldNotHappenException(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
use Rector\Core\Exception\ShouldNotHappenException; | ||
|
||
final class ImproveVoid | ||
{ | ||
public function run(): never | ||
{ | ||
throw new ShouldNotHappenException(); | ||
} | ||
} | ||
|
||
?> |
9 changes: 9 additions & 0 deletions
9
...ypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/skip_nested_value.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,9 @@ | ||
<?php | ||
|
||
function run($key) | ||
{ | ||
if ($key) { | ||
echo 100; | ||
exit; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...peDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/skip_never_already.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,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
final class SkipNeverAlready | ||
{ | ||
public function run(): never | ||
{ | ||
throw new InvalidException(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...eclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/skip_parent_protected.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,16 @@ | ||
<?php | ||
|
||
use Rector\Core\Exception\ShouldNotHappenException; | ||
|
||
final class SkipParentProtected implements SomeInterfaceWithReturnType | ||
{ | ||
public function run() | ||
{ | ||
throw new ShouldNotHappenException(); | ||
} | ||
} | ||
|
||
interface SomeInterfaceWithReturnType | ||
{ | ||
public function run(): void; | ||
} |
11 changes: 11 additions & 0 deletions
11
...ests/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/skip_return.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,11 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
final class SkipReturn | ||
{ | ||
public function run() | ||
{ | ||
return; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...tests/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/skip_yield.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,12 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
final class SkipYield | ||
{ | ||
public function run() | ||
{ | ||
yield 1; | ||
exit(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...tests/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/some_class.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,27 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
final class SomeClass | ||
{ | ||
public function run() | ||
{ | ||
throw new InvalidException(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
final class SomeClass | ||
{ | ||
public function run(): never | ||
{ | ||
throw new InvalidException(); | ||
} | ||
} | ||
|
||
?> |
33 changes: 33 additions & 0 deletions
33
...ts/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/ReturnNeverTypeRectorTest.php
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class ReturnNeverTypeRectorTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...tests/TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/config/configured_rule.php
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Core\Configuration\Option; | ||
use Rector\Core\ValueObject\PhpVersion; | ||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_81); | ||
|
||
$services = $containerConfigurator->services(); | ||
$services->set(ReturnNeverTypeRector::class); | ||
}; |
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
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
Oops, something went wrong.