File tree Expand file tree Collapse file tree
rules-tests/TypeDeclaration/TypeGuardedClasses
rules/TypeDeclaration/Rector/ClassMethod Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \TypeDeclaration \TypeGuardedClasses \Fixture ;
4+
5+ trait SkipGuardedTrait
6+ {
7+ public function resolveItem ($ item )
8+ {
9+ return $ item ['name ' ];
10+ }
11+ }
Original file line number Diff line number Diff line change 77use Rector \Config \RectorConfig ;
88use Rector \Tests \TypeDeclaration \TypeGuardedClasses \Source \GuardedRepository ;
99use Rector \TypeDeclaration \Rector \ClassMethod \AddReturnTypeDeclarationRector ;
10+ use Rector \TypeDeclaration \Rector \ClassMethod \StrictArrayParamDimFetchRector ;
1011use Rector \TypeDeclaration \ValueObject \AddReturnTypeDeclaration ;
1112
1213return static function (RectorConfig $ rectorConfig ): void {
13- $ rectorConfig ->typeGuardedClasses ([GuardedRepository::class]);
14+ $ rectorConfig ->typeGuardedClasses ([
15+ GuardedRepository::class,
16+ 'Rector\Tests\TypeDeclaration\TypeGuardedClasses\Fixture\SkipGuardedTrait ' ,
17+ ]);
18+
19+ $ rectorConfig ->rule (StrictArrayParamDimFetchRector::class);
1420
1521 $ rectorConfig ->ruleWithConfiguration (AddReturnTypeDeclarationRector::class, [
1622 new AddReturnTypeDeclaration (
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ public function refactor(Node $node): ?Node
9595 return null ;
9696 }
9797
98+ if ($ node instanceof ClassMethod && $ this ->parentClassMethodTypeOverrideGuard ->isTypeGuardedClass ($ node )) {
99+ return null ;
100+ }
101+
98102 foreach ($ node ->getParams () as $ param ) {
99103 if ($ param ->type instanceof Node) {
100104 continue ;
You can’t perform that action at this time.
0 commit comments