Skip to content

Commit 5d49a9a

Browse files
committed
PhpWriter: removed short ternary deprecation notice
1 parent 8aaae45 commit 5d49a9a

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/Latte/Compiler/PhpWriter.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,33 +253,24 @@ public function replaceFunctionsPass(MacroTokens $tokens): MacroTokens
253253
public function shortTernaryPass(MacroTokens $tokens): MacroTokens
254254
{
255255
$res = new MacroTokens;
256-
$inTernary = $tmp = [];
257-
$errors = 0;
256+
$inTernary = [];
258257
while ($tokens->nextToken()) {
259-
if ($tokens->isCurrent('?') && $tokens->isNext() && !$tokens->isNext(':', ',', ')', ']', '|')) {
258+
if ($tokens->isCurrent('?') && $tokens->isNext() && !$tokens->isNext(':', ',', ')', ']', '|', '[')) {
260259
$inTernary[] = $tokens->depth;
261-
$tmp[] = $tokens->isNext('[');
262260

263261
} elseif ($tokens->isCurrent(':')) {
264262
array_pop($inTernary);
265-
array_pop($tmp);
266263

267264
} elseif ($tokens->isCurrent(',', ')', ']', '|') && end($inTernary) === $tokens->depth + $tokens->isCurrent(')', ']')) {
268265
$res->append(' : null');
269266
array_pop($inTernary);
270-
$errors += array_pop($tmp);
271267
}
272268
$res->append($tokens->currentToken());
273269
}
274270

275271
if ($inTernary) {
276-
$errors += array_pop($tmp);
277272
$res->append(' : null');
278273
}
279-
if ($errors) {
280-
$tokens->reset();
281-
trigger_error('Short ternary operator requires braces around array: ' . $tokens->joinAll(), E_USER_DEPRECATED);
282-
}
283274
return $res;
284275
}
285276

0 commit comments

Comments
 (0)