File tree Expand file tree Collapse file tree
rules-tests/CodeQuality/Rector/Class_/TypeWillReturnCallableArrowFunctionRector/Fixture
rules/CodeQuality/Rector/Class_ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \Class_ \TypeWillReturnCallableArrowFunctionRector \Fixture ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use Rector \PHPUnit \Tests \CodeQuality \Rector \Class_ \TypeWillReturnCallableArrowFunctionRector \Source \SomeMockedClass ;
7+
8+ final class SkipAlreadyReturnTyped extends TestCase
9+ {
10+ public function test ($ value ): void
11+ {
12+ $ this ->createMock (SomeMockedClass::class)
13+ ->method ('nativeObject ' )
14+ ->willReturnCallback (fn (object $ object ): \stdClass => $ value );
15+ }
16+ }
17+
18+ ?>
Original file line number Diff line number Diff line change @@ -239,14 +239,16 @@ public function refactor(Node $node): ?Class_
239239 $ hasChanged = true ;
240240 }
241241
242- $ returnTypeNode = $ this ->staticTypeMapper ->mapPHPStanTypeToPhpParserNode (
243- $ parameterTypesAndReturnType ->getReturnType (),
244- TypeKind::RETURN
245- );
242+ if (! $ innerArg ->returnType instanceof Node) {
243+ $ returnTypeNode = $ this ->staticTypeMapper ->mapPHPStanTypeToPhpParserNode (
244+ $ parameterTypesAndReturnType ->getReturnType (),
245+ TypeKind::RETURN
246+ );
246247
247- if ($ returnTypeNode instanceof Node) {
248- $ innerArg ->returnType = $ returnTypeNode ;
249- $ hasChanged = true ;
248+ if ($ returnTypeNode instanceof Node) {
249+ $ innerArg ->returnType = $ returnTypeNode ;
250+ $ hasChanged = true ;
251+ }
250252 }
251253 });
252254
You can’t perform that action at this time.
0 commit comments