Skip to content

Commit

Permalink
simplify handling of scope arg of Closure::bind
Browse files Browse the repository at this point in the history
  • Loading branch information
schlndh committed Mar 23, 2024
1 parent e79770f commit b494706
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Analyser/NodeScopeResolver.php
Expand Up @@ -2457,18 +2457,12 @@ static function (): void {
if (isset($expr->getArgs()[2])) {
$argValue = $expr->getArgs()[2]->value;
$argValueType = $scope->getType($argValue);

$directClassNames = $argValueType->getObjectClassNames();
if (count($directClassNames) > 0) {
$scopeClasses = $directClassNames;
} else {
$scopeObjectType = $argValueType->getClassStringObjectType();
$thisType = $thisType !== null
// $thisType could be mixed, error, ...
? TypeCombinator::intersect($thisType, $scopeObjectType)
: $scopeObjectType;
$scopeClasses = $scopeObjectType->getObjectClassNames();
}
$scopeObjectType = $argValueType->getObjectTypeOrClassStringObjectType();
$thisType = $thisType !== null
// $thisType could be mixed, error, ...
? TypeCombinator::intersect($thisType, $scopeObjectType)
: $scopeObjectType;
$scopeClasses = $scopeObjectType->getObjectClassNames();
}
$closureBindScope = $scope->enterClosureBind($thisType, $nativeThisType, $scopeClasses);
}
Expand Down

0 comments on commit b494706

Please sign in to comment.