Skip to content

Commit

Permalink
Updated Rector to commit de0dda8f29453b36bcfa3728cf26662fb634fcd1
Browse files Browse the repository at this point in the history
rectorphp/rector-src@de0dda8 Compare type directly in CleanupUnneededNullsafeOperatorRector (#6086)
  • Loading branch information
TomasVotruba committed Jun 30, 2024
1 parent 91f015b commit 33f4d6d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PHPStan\Type\ObjectType;
use Rector\Rector\AbstractRector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\TypeDeclaration\TypeAnalyzer\ReturnStrictTypeAnalyzer;
use Rector\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
Expand Down Expand Up @@ -84,12 +84,8 @@ public function refactor(Node $node) : ?Node
if (!$node->var instanceof FuncCall && !$node->var instanceof MethodCall && !$node->var instanceof StaticCall) {
return null;
}
$returnNode = $this->returnStrictTypeAnalyzer->resolveMethodCallReturnNode($node->var);
if (!$returnNode instanceof Node) {
return null;
}
$type = $this->getType($returnNode);
if (!$type instanceof FullyQualifiedObjectType) {
$returnType = $this->returnStrictTypeAnalyzer->resolveMethodCallReturnType($node->var);
if (!$returnType instanceof ObjectType) {
return null;
}
return new MethodCall($node->var, $node->name, $node->args);
Expand Down
14 changes: 12 additions & 2 deletions rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ public function collectStrictReturnTypes(array $returns, Scope $scope) : array
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $call
*/
public function resolveMethodCallReturnNode($call) : ?Node
{
$returnType = $this->resolveMethodCallReturnType($call);
if (!$returnType instanceof Type) {
return null;
}
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN);
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $call
*/
public function resolveMethodCallReturnType($call) : ?Type
{
$methodReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($call);
if ($methodReflection === null) {
Expand All @@ -114,8 +125,7 @@ public function resolveMethodCallReturnNode($call) : ?Node
if ($returnType instanceof MixedType) {
return null;
}
$returnType = $this->normalizeStaticType($call, $returnType);
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN);
return $this->normalizeStaticType($call, $returnType);
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\FuncCall $call
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '296a2b2fbbe8d41393cc470eb97ec1c3ac5423cd';
public const PACKAGE_VERSION = 'de0dda8f29453b36bcfa3728cf26662fb634fcd1';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-06-30 12:55:24';
public const RELEASE_DATE = '2024-06-30 19:47:13';
/**
* @var int
*/
Expand Down

0 comments on commit 33f4d6d

Please sign in to comment.