Skip to content

Commit

Permalink
De-duplicate isAnonymous check (#3782)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed May 9, 2023
1 parent e6fd263 commit 376f6cb
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,10 @@ private function resolveClassOrInterfaceScope(
bool $isScopeRefreshing
): MutatingScope {
$className = $this->resolveClassName($classLike);
$isAnonymous = $this->classAnalyzer->isAnonymousClass($classLike);

// is anonymous class? - not possible to enter it since PHPStan 0.12.33, see https://github.com/phpstan/phpstan-src/commit/e87fb0ec26f9c8552bbeef26a868b1e5d8185e91
if ($classLike instanceof Class_ && $this->classAnalyzer->isAnonymousClass($classLike)) {
if ($classLike instanceof Class_ && $isAnonymous) {
$classReflection = $this->reflectionProvider->getAnonymousClassReflection($classLike, $mutatingScope);
} elseif (! $this->reflectionProvider->hasClass($className)) {
return $mutatingScope;
Expand All @@ -397,7 +398,7 @@ private function resolveClassOrInterfaceScope(
}

// on refresh, remove entered class avoid entering the class again
if ($isScopeRefreshing && $mutatingScope->isInClass() && ! $classReflection->isAnonymous()) {
if ($isScopeRefreshing && $mutatingScope->isInClass() && ! $isAnonymous) {
$context = $this->privatesAccessor->getPrivateProperty($mutatingScope, 'context');
$this->privatesAccessor->setPrivateProperty($context, 'classReflection', null);
}
Expand Down

0 comments on commit 376f6cb

Please sign in to comment.