Skip to content

Commit 7f214df

Browse files
committed
early return on and connections
1 parent e233aa1 commit 7f214df

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/Render.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function (array $matches) use ($variables): string {
177177

178178
$orBranches = [];
179179
foreach (explode(' or ', $matches['condition']) as $orLinkedCondition) {
180-
$andBranches = [];
180+
$andBranchTrue = true;
181181

182182
foreach (explode(' and ', $orLinkedCondition) as $condition) {
183183
if (!preg_match(
@@ -188,11 +188,12 @@ function (array $matches) use ($variables): string {
188188
throw new SyntaxErrorException("Invalid condition {$matches['condition']}");
189189
}
190190

191-
$andBranches[] = (
192-
!empty($conditionMatches['not']) xor $this->getValue($conditionMatches, $variables)
193-
);
191+
if(empty($conditionMatches['not']) xor $this->getValue($conditionMatches, $variables)) {
192+
$andBranchTrue = false;
193+
break;
194+
}
194195
}
195-
$orBranches[] = !in_array(false, $andBranches);
196+
$orBranches[] = $andBranchTrue;
196197
}
197198

198199
if (in_array(true, $orBranches)) {

0 commit comments

Comments
 (0)