public function addDebugInfo(Twig_NodeInterface $node)
    {
        if ($node->getLine() != $this->lastLine) {
            $this->write(sprintf("// line %d\n", $node->getLine()));

            // when mbstring.func_overload is set to 2
            // mb_substr_count() replaces substr_count()
            // but they have different signatures!
            if (((int) ini_get('mbstring.func_overload')) & 2) {
                // this is much slower than the "right" version
                $this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
            } else {
                $this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
            }
            $this->sourceOffset = strlen($this->source);
            $this->debugInfo[$this->sourceLine] = $node->getLine();

            $this->lastLine = $node->getLine();
        }

        return $this;
    }
public function addDebugInfo(Twig_NodeInterface $node)
    {
        if ($node->getLine() != $this->lastLine) {
            $this->write(sprintf("// line %d\n", $node->getLine()));

            // when mbstring.func_overload is set to 2
            // mb_substr_count() replaces substr_count()
            // but they have different signatures!
            if (((int) ini_get('mbstring.func_overload')) & 2) {
                // this is much slower than the "right" version
                $this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
            } else {
                $this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
            }
            $this->sourceOffset = strlen($this->source);
            $this->debugInfo[$this->sourceLine] = $node->getLine();

            $this->lastLine = $node->getLine();
        }

        return $this;
    }
public function addDebugInfo ( Twig_NodeInterface $ node ) { if ( $ node -> getLine ( ) != $ this -> lastLine ) { $ this -> write ( sprintf ( "// line %d\n" , $ node -> getLine ( ) ) ) ; // when mbstring.func_overload is set to 2 // mb_substr_count() replaces substr_count() // but they have different signatures! if ( ( ( int ) ini_get ( 'mbstring.func_overload' ) ) & 2 ) { // this is much slower than the "right" version $ this -> sourceLine += mb_substr_count ( mb_substr ( $ this -> source , $ this -> sourceOffset ) , "\n" ) ; } else { $ this -> sourceLine += substr_count ( $ this -> source , "\n" , $ this -> sourceOffset ) ; } $ this -> sourceOffset = strlen ( $ this -> source ) ; $ this -> debugInfo [ $ this -> sourceLine ] = $ node -> getLine ( ) ; $ this -> lastLine = $ node -> getLine ( ) ; } return $ this ; }
Adds debugging information.

@param Twig_NodeInterface $node The related twig node

@return Twig_Compiler The current compiler instance
Adds debugging information .