From 10874ba67487980ed08c85aa6ca74a22604f2b9f Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 29 Jul 2023 09:34:40 +0200 Subject: [PATCH] Prevent unnecessary work in MutatingScope --- src/Analyser/MutatingScope.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 1bf8a5b1c5..8f3a85e1c6 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -763,14 +763,14 @@ private function resolveType(string $exprString, Expr $node): Type $node instanceof Node\Expr\BinaryOp\BooleanAnd || $node instanceof Node\Expr\BinaryOp\LogicalAnd ) { - $noopCallback = static function (): void { - }; - $leftResult = $this->nodeScopeResolver->processExprNode($node->left, $this, $noopCallback, ExpressionContext::createDeep()); $leftBooleanType = $this->getType($node->left)->toBoolean(); if ($leftBooleanType->isFalse()->yes()) { return new ConstantBooleanType(false); } + $noopCallback = static function (): void { + }; + $leftResult = $this->nodeScopeResolver->processExprNode($node->left, $this, $noopCallback, ExpressionContext::createDeep()); $rightBooleanType = $leftResult->getTruthyScope()->getType($node->right)->toBoolean(); if ($rightBooleanType->isFalse()->yes()) { @@ -791,14 +791,14 @@ private function resolveType(string $exprString, Expr $node): Type $node instanceof Node\Expr\BinaryOp\BooleanOr || $node instanceof Node\Expr\BinaryOp\LogicalOr ) { - $noopCallback = static function (): void { - }; - $leftResult = $this->nodeScopeResolver->processExprNode($node->left, $this, $noopCallback, ExpressionContext::createDeep()); $leftBooleanType = $this->getType($node->left)->toBoolean(); if ($leftBooleanType->isTrue()->yes()) { return new ConstantBooleanType(true); } + $noopCallback = static function (): void { + }; + $leftResult = $this->nodeScopeResolver->processExprNode($node->left, $this, $noopCallback, ExpressionContext::createDeep()); $rightBooleanType = $leftResult->getFalseyScope()->getType($node->right)->toBoolean(); if ($rightBooleanType->isTrue()->yes()) {