-
-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Skip test methods with exception in ReturnNeverType…
…Rector, [php74] Skip conditinal assign in RestoreDefaultNullToNullableTypePropertyRector as most likely desired to assign or fail (#6430) * [TypeDeclaration] Skip test methods with exception in ReturnNeverTypeRector * [php74] Skip conditinal assign in RestoreDefaultNullToNullableTypePropertyRector as most likely desired to assign or fail
- Loading branch information
1 parent
db1a84c
commit 3ee5b72
Showing
9 changed files
with
116 additions
and
36 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
19 changes: 19 additions & 0 deletions
19
...ctor/Property/RestoreDefaultNullToNullableTypePropertyRector/Fixture/skip_checked.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,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector\Fixture; | ||
|
||
final class SkipChecked | ||
{ | ||
private ?string $name; | ||
|
||
public function __construct(array $items) | ||
{ | ||
foreach ($items as $item) { | ||
$this->name = $item; | ||
} | ||
|
||
if (! isset($this->item)) { | ||
throw new \InvalidArgumentException(); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...TypeDeclaration/Rector/ClassMethod/ReturnNeverTypeRector/Fixture/skip_test_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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture; | ||
|
||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class SkipTestMethod extends TestCase | ||
{ | ||
public function testSomething(): void | ||
{ | ||
$this->expectException(Exception::class); | ||
|
||
throw new \InvalidArgumentException(); | ||
} | ||
} |
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
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
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\NodeDecorator; | ||
|
||
use PhpParser\Node\Stmt\ClassMethod; | ||
use PhpParser\Node\Stmt\Expression; | ||
use Rector\NodeTypeResolver\Node\AttributeKey; | ||
|
||
final class StatementDepthAttributeDecorator | ||
{ | ||
/** | ||
* @param ClassMethod[] $classMethods | ||
*/ | ||
public static function decorateClassMethods(array $classMethods): void | ||
{ | ||
foreach ($classMethods as $classMethod) { | ||
foreach ((array) $classMethod->stmts as $methodStmt) { | ||
$methodStmt->setAttribute(AttributeKey::IS_FIRST_LEVEL_STATEMENT, true); | ||
|
||
if ($methodStmt instanceof Expression) { | ||
$methodStmt->expr->setAttribute(AttributeKey::IS_FIRST_LEVEL_STATEMENT, true); | ||
} | ||
} | ||
} | ||
} | ||
} |
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