-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Include throw statements to AddErrorCodeToExceptionRector
- Loading branch information
1 parent
7193380
commit 9236944
Showing
3 changed files
with
73 additions
and
4 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
36 changes: 36 additions & 0 deletions
36
...deQuality/General/AddErrorCodeToExceptionRector/AddErrorCodeToExceptionRectorPhp8Test.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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\CodeQuality\General\AddErrorCodeToExceptionRector; | ||
|
||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Rector\ValueObject\PhpVersionFeature; | ||
|
||
final class AddErrorCodeToExceptionRectorPhp8Test extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
if (PHP_VERSION_ID < PhpVersionFeature::MATCH_EXPRESSION) { | ||
$this->markTestSkipped('Do not execute'); | ||
} | ||
|
||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return \Iterator<array<string>> | ||
*/ | ||
public static function provideData(): \Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/FixturePhp8'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/Rector/CodeQuality/General/AddErrorCodeToExceptionRector/FixturePhp8/fixture.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 Ssch\TYPO3Rector\Tests\Rector\CodeQuality\General\AddErrorCodeToExceptionRector\FixturePhp8; | ||
|
||
class CustomException | ||
{ | ||
public function returnMatch() | ||
{ | ||
return match (true) { | ||
default => throw new \InvalidArgumentException('Invalid'), | ||
}; | ||
} | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
namespace Ssch\TYPO3Rector\Tests\Rector\CodeQuality\General\AddErrorCodeToExceptionRector\FixturePhp8; | ||
|
||
class CustomException | ||
{ | ||
public function returnMatch() | ||
{ | ||
return match (true) { | ||
default => throw new \InvalidArgumentException('Invalid', 1729021897), | ||
}; | ||
} | ||
} | ||
?> |