Skip to content

Commit

Permalink
Updated Rector to commit db213ee986c942d58e397b3713564349541e8de5
Browse files Browse the repository at this point in the history
rectorphp/rector-src@db213ee [PHPStan] Handle PHPStan internal ShouldNotHappenException on FamilyRelationsAnalyzer and PHPStanNodeScopeResolver (#5885)
  • Loading branch information
TomasVotruba committed May 16, 2024
1 parent 6cf7059 commit 6372b90
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
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 = '6a5f6c53f3637b23b4488cab81ec90a0d1bef053';
public const PACKAGE_VERSION = 'db213ee986c942d58e397b3713564349541e8de5';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-05-16 18:42:05';
public const RELEASE_DATE = '2024-05-16 19:48:22';
/**
* @var int
*/
Expand Down
3 changes: 2 additions & 1 deletion src/FamilyTree/Reflection/FamilyRelationsAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPStan\Broker\ClassNotFoundException;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\ShouldNotHappenException;
use Rector\Caching\Cache;
use Rector\Caching\Enum\CacheKey;
use Rector\NodeNameResolver\NodeNameResolver;
Expand Down Expand Up @@ -123,7 +124,7 @@ private function loadClasses() : void
foreach ($classNamesCache as $classNameCache) {
try {
$this->reflectionProvider->getClass($classNameCache);
} catch (ClassNotFoundException $exception) {
} catch (ClassNotFoundException|ShouldNotHappenException $exception) {
}
}
}
Expand Down
17 changes: 3 additions & 14 deletions src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
use Rector\PHPStan\NodeVisitor\ExprScopeFromStmtNodeVisitor;
use Rector\PHPStan\NodeVisitor\WrappedNodeRestoringNodeVisitor;
use Rector\Util\Reflection\PrivatesAccessor;
use Throwable;
use RectorPrefix202405\Webmozart\Assert\Assert;
/**
* @inspired by https://github.com/silverstripe/silverstripe-upgrader/blob/532182b23e854d02e0b27e68ebc394f436de0682/src/UpgradeRule/PHP/Visitor/PHPStanScopeVisitor.php
Expand Down Expand Up @@ -111,10 +110,6 @@ final class PHPStanNodeScopeResolver
* @var bool
*/
private $hasUnreachableStatementNode = \false;
/**
* @var string
*/
private const PHPSTAN_INTERNAL_ERROR_MESSAGE = 'Internal error.';
/**
* @param ScopeResolverNodeVisitorInterface[] $nodeVisitors
*/
Expand Down Expand Up @@ -236,10 +231,7 @@ private function nodeScopeResolverProcessNodes(array $stmts, MutatingScope $muta
{
try {
$this->nodeScopeResolver->processNodes($stmts, $mutatingScope, $nodeCallback);
} catch (Throwable $throwable) {
if ($throwable->getMessage() !== self::PHPSTAN_INTERNAL_ERROR_MESSAGE) {
throw $throwable;
}
} catch (\PHPStan\ShouldNotHappenException $exception) {
}
}
private function processCallike(CallLike $callLike, MutatingScope $mutatingScope) : void
Expand Down Expand Up @@ -368,12 +360,9 @@ private function resolveClassOrInterfaceScope($classLike, MutatingScope $mutatin
$this->privatesAccessor->setPrivateProperty($context, 'classReflection', null);
try {
return $mutatingScope->enterClass($classReflection);
} catch (Throwable $throwable) {
if ($throwable->getMessage() !== self::PHPSTAN_INTERNAL_ERROR_MESSAGE) {
throw $throwable;
}
return $mutatingScope;
} catch (\PHPStan\ShouldNotHappenException $exception) {
}
return $mutatingScope;
}
/**
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Enum_ $classLike
Expand Down

0 comments on commit 6372b90

Please sign in to comment.