protected function clarifyException(
        ViewSource $source,
        CompileException $exception
    ): CompileException {
        if (empty($exception->getToken())) {
            //Unable to locate
            return $exception;
        }

        //We will need only first tag line
        $target = explode("\n", $exception->getToken()[HtmlTokenizer::TOKEN_CONTENT])[0];

        //Let's try to locate place where exception was used
        $lines = explode("\n", $source->getCode());

        foreach ($lines as $number => $line) {
            if (strpos($line, $target) !== false) {
                //We found where token were used (!!)
                $exception->setLocation(
                    $source->getFilename(),
                    $number + 1
                );

                break;
            }
        }

        return $exception;
    }
protected function clarifyException(
        ViewSource $source,
        CompileException $exception
    ): CompileException {
        if (empty($exception->getToken())) {
            //Unable to locate
            return $exception;
        }

        //We will need only first tag line
        $target = explode("\n", $exception->getToken()[HtmlTokenizer::TOKEN_CONTENT])[0];

        //Let's try to locate place where exception was used
        $lines = explode("\n", $source->getCode());

        foreach ($lines as $number => $line) {
            if (strpos($line, $target) !== false) {
                //We found where token were used (!!)
                $exception->setLocation(
                    $source->getFilename(),
                    $number + 1
                );

                break;
            }
        }

        return $exception;
    }
protected function clarifyException ( ViewSource $ source , CompileException $ exception ) : CompileException { if ( empty ( $ exception -> getToken ( ) ) ) { //Unable to locate return $ exception ; } //We will need only first tag line $ target = explode ( "\n" , $ exception -> getToken ( ) [ HtmlTokenizer :: TOKEN_CONTENT ] ) [ 0 ] ; //Let's try to locate place where exception was used $ lines = explode ( "\n" , $ source -> getCode ( ) ) ; foreach ( $ lines as $ number => $ line ) { if ( strpos ( $ line , $ target ) !== false ) { //We found where token were used (!!) $ exception -> setLocation ( $ source -> getFilename ( ) , $ number + 1 ) ; break ; } } return $ exception ; }
Clarify exception with it's actual location.

@param ViewSource       $source
@param CompileException $exception

@return CompileException
Clarify exception with it s actual location .