Skip to content

Commit

Permalink
[TypeDeclaration] Remove findParentType() on SilentVoidResolver (#4203)
Browse files Browse the repository at this point in the history
* [TypeDeclaration] Remove findParentType() on SilentVoidResolver

* increase kernel cache key
  • Loading branch information
samsonasik committed Jun 12, 2023
1 parent d90d321 commit b56b0c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@
use PhpParser\Node\Expr\Yield_;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Interface_;
use PhpParser\Node\Stmt\Return_;
use PhpParser\Node\Stmt\Switch_;
use PhpParser\Node\Stmt\Throw_;
use PhpParser\Node\Stmt\TryCatch;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\Reflection\ReflectionResolver;

final class SilentVoidResolver
{
public function __construct(
private readonly BetterNodeFinder $betterNodeFinder,
private readonly ReflectionResolver $reflectionResolver
) {
}

public function hasExclusiveVoid(ClassMethod | Closure | Function_ $functionLike): bool
{
$classLike = $this->betterNodeFinder->findParentType($functionLike, ClassLike::class);
if ($classLike instanceof Interface_) {
$classReflection = $this->reflectionResolver->resolveClassReflection($functionLike);
if ($classReflection instanceof ClassReflection && $classReflection->isInterface()) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/RectorKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class RectorKernel
/**
* @var string
*/
private const CACHE_KEY = 'v113';
private const CACHE_KEY = 'v114';

private ContainerInterface|null $container = null;

Expand Down

0 comments on commit b56b0c2

Please sign in to comment.