Skip to content

Commit a7a28a2

Browse files
authored
[CodeQuality] Skip docblock based type on AddReturnTypeToDependedRector (#530)
* [CodeQuality] Skip docblock based type on AddReturnTypeToDependedRector * add test * try pin rector hash * rollback pin hash
1 parent d76a45a commit a7a28a2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\Class_\AddReturnTypeToDependedRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class SkipDocblockBasedType extends TestCase
8+
{
9+
/**
10+
* @param int $someValue
11+
*/
12+
public function test($someValue)
13+
{
14+
return $someValue;
15+
}
16+
}

rules/CodeQuality/Rector/Class_/AddReturnTypeToDependedRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function refactor(Node $node): ?Node
112112
$soleReturnExpr = $returns[0]->expr;
113113

114114
// does return a type?
115-
$returnedExprType = $this->getType($soleReturnExpr);
115+
$returnedExprType = $this->nodeTypeResolver->getNativeType($soleReturnExpr);
116116
$returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnedExprType, TypeKind::RETURN);
117117

118118
if (! $returnType instanceof Node) {

0 commit comments

Comments
 (0)