Skip to content

Commit 49c527c

Browse files
committed
Engine: fixed CompileException sourceLine on PHP7
1 parent 86ec0a1 commit 49c527c

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/Latte/Engine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ private function loadTemplate($name)
222222
throw $e->setSource($code, $error['line'], $name . ' (compiled)');
223223
}
224224
} catch (\ParseError $e) {
225-
$e = new CompileException('Error in template: ' . $e->getMessage(), 0, $e);
226-
throw $e->setSource($code, $e->getLine(), $name . ' (compiled)');
225+
$compileException = new CompileException('Error in template: ' . $e->getMessage(), 0, $e);
226+
throw $compileException->setSource($code, $e->getLine(), $name . ' (compiled)');
227227
}
228228
return $code;
229229
}

tests/Latte/Engine.parseError.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ Assert::exception(function () {
1616
$latte->render('{php * }');
1717
}, 'Latte\CompileException', "Error in template: syntax error, unexpected '*'");
1818

19-
Assert::exception(function () {
19+
$e = Assert::exception(function () {
2020
$latte = new Latte\Engine;
2121
$latte->setTempDirectory(TEMP_DIR);
2222
$latte->setLoader(new Latte\Loaders\StringLoader);
2323
$latte->render('{php * * }');
2424
}, 'Latte\CompileException', "Error in template: syntax error, unexpected '*'");
25+
Assert::same(13, $e->sourceLine);
2526

2627
if (PHP_VERSION_ID < 50400) {
2728
die(0); // otherwise PHP exits with code 255

0 commit comments

Comments
 (0)