mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-08 20:22:24 +00:00
[CodingStyle] Handle more than one method contains try catch on CatchExceptionNameMatchingTypeRector (#1706)
* Add failing test fixture for CatchExceptionNameMatchingTypeRector # Failing Test for CatchExceptionNameMatchingTypeRector Based on https://getrector.org/demo/1ec7a611-571e-6c18-8335-c5ffee726af7 * Closes #1705 Co-authored-by: Zing <zingimmick@outlook.com>
This commit is contained in:
parent
672b339ebd
commit
2934929fac
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector\Fixture;
|
||||
|
||||
use Throwable;
|
||||
|
||||
final class MoreThanOneMethodContainsTryCatch
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
try {
|
||||
} catch (Throwable $exception) {
|
||||
}
|
||||
}
|
||||
|
||||
public function more()
|
||||
{
|
||||
try {
|
||||
} catch (Throwable $exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector\Fixture;
|
||||
|
||||
use Throwable;
|
||||
|
||||
final class MoreThanOneMethodContainsTryCatch
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
try {
|
||||
} catch (Throwable $throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
public function more()
|
||||
{
|
||||
try {
|
||||
} catch (Throwable $throwable) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector\Fixture;
|
||||
|
||||
use Throwable;
|
||||
|
||||
final class MoreThanOneTryCatch
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
try {
|
||||
} catch (Throwable $exception) {
|
||||
}
|
||||
try {
|
||||
} catch (Throwable $exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector\Fixture;
|
||||
|
||||
use Throwable;
|
||||
|
||||
final class MoreThanOneTryCatch
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
try {
|
||||
} catch (Throwable $throwable) {
|
||||
}
|
||||
try {
|
||||
} catch (Throwable $throwable) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -113,7 +113,7 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
$newVariable = new Variable($newVariableName);
|
||||
$isFoundInPrevious = (bool) $this->betterNodeFinder->findFirstPrevious(
|
||||
$isFoundInPrevious = (bool) $this->betterNodeFinder->findFirstPreviousOfNode(
|
||||
$node,
|
||||
fn (Node $n): bool => $this->nodeComparator->areNodesEqual($n, $newVariable)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user