From: Fabien Potencier Date: Thu, 8 Nov 2012 09:22:28 +0000 (+0100) Subject: merged branch char101/fix-debug-lineno (PR #894) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=818f9c7e020c05dca8d46ff9bd016a7acb26db32;p=web%2Fkonrad%2Ftwig.git merged branch char101/fix-debug-lineno (PR #894) This PR was squashed before being merged into the master branch (closes #894). Commits ------- 7c5854b Fix twig error lineno off by 2 Discussion ---------- Fix twig error lineno off by 2 It seems to me that the lineno reported by Twig_Error is off by 2 from the real lineno in the generated PHP source For example: ``` {% if true %} Yes {% endif %} ``` ```php parent = false; $this->blocks = array( ); } protected function doDisplay(array $context, array $blocks = array()) { // line 1 if (true) { // <- this is line 19 // line 2 echo "Yes // <- this is line 21 "; } } public function getTemplateName() { return null; } public function isTraitable() { return false; } public function getDebugInfo() { return array ( 19 => 2, 17 => 1,); // <- should be return array ( 21 => 2, 19 => 1,); } } ``` --------------------------------------------------------------------------- by char101 at 2012-11-08T08:23:57Z Since `$compiler->addDebugInfo()` is called first before writing the node content, usually the number of lines in the PHP code is less than 2 (1 for the // lineno comment, and 1 for the generated content) than the line where the node content is written. --- 818f9c7e020c05dca8d46ff9bd016a7acb26db32