src/Service/Misc/File.php
public function readSourcecode($filePath, $highlight, $readFrom, $readTo)
    {
        $result = '';

        // Read the file into our cache array. We may need to reed this file a
        // few times.
        $content = $this->getFileContentsArray($filePath);

        if ($readFrom < 0) {
             $readFrom = 0;
        }

        if (isset($content[$readFrom]) === false) {
            // We can not even start reading this file!
            // Return empty string.
            return '';
        }

        if ($readTo < 0) {
            $readTo = 0;
        }

        if (isset($content[$readTo]) === false) {
            // We can not read this far, set it to the last line.
            $readTo = count($content) - 1;
        }

        for ($currentLineNo = $readFrom; $currentLineNo <= $readTo; ++$currentLineNo) {
            // Add it to the result.
            $realLineNo = $currentLineNo + 1;

            if ($currentLineNo === $highlight) {
                $result .= $this->pool->render->renderBacktraceSourceLine(
                    'highlight',
                    $realLineNo,
                    $this->pool->encodingService->encodeString($content[$currentLineNo], true)
                );
            } else {
                $result .= $this->pool->render->renderBacktraceSourceLine(
                    'source',
                    $realLineNo,
                    $this->pool->encodingService->encodeString($content[$currentLineNo], true)
                );
            }
        }

        return $result;
    }
public function readSourcecode($filePath, $highlight, $readFrom, $readTo)
    {
        $result = '';

        // Read the file into our cache array. We may need to reed this file a
        // few times.
        $content = $this->getFileContentsArray($filePath);

        if ($readFrom < 0) {
             $readFrom = 0;
        }

        if (isset($content[$readFrom]) === false) {
            // We can not even start reading this file!
            // Return empty string.
            return '';
        }

        if ($readTo < 0) {
            $readTo = 0;
        }

        if (isset($content[$readTo]) === false) {
            // We can not read this far, set it to the last line.
            $readTo = count($content) - 1;
        }

        for ($currentLineNo = $readFrom; $currentLineNo <= $readTo; ++$currentLineNo) {
            // Add it to the result.
            $realLineNo = $currentLineNo + 1;

            if ($currentLineNo === $highlight) {
                $result .= $this->pool->render->renderBacktraceSourceLine(
                    'highlight',
                    $realLineNo,
                    $this->pool->encodingService->encodeString($content[$currentLineNo], true)
                );
            } else {
                $result .= $this->pool->render->renderBacktraceSourceLine(
                    'source',
                    $realLineNo,
                    $this->pool->encodingService->encodeString($content[$currentLineNo], true)
                );
            }
        }

        return $result;
    }
public function readSourcecode ( $ filePath , $ highlight , $ readFrom , $ readTo ) { $ result = '' ; // Read the file into our cache array. We may need to reed this file a // few times. $ content = $ this -> getFileContentsArray ( $ filePath ) ; if ( $ readFrom < 0 ) { $ readFrom = 0 ; } if ( isset ( $ content [ $ readFrom ] ) === false ) { // We can not even start reading this file! // Return empty string. return '' ; } if ( $ readTo < 0 ) { $ readTo = 0 ; } if ( isset ( $ content [ $ readTo ] ) === false ) { // We can not read this far, set it to the last line. $ readTo = count ( $ content ) - 1 ; } for ( $ currentLineNo = $ readFrom ; $ currentLineNo <= $ readTo ; ++ $ currentLineNo ) { // Add it to the result. $ realLineNo = $ currentLineNo + 1 ; if ( $ currentLineNo === $ highlight ) { $ result .= $ this -> pool -> render -> renderBacktraceSourceLine ( 'highlight' , $ realLineNo , $ this -> pool -> encodingService -> encodeString ( $ content [ $ currentLineNo ] , true ) ) ; } else { $ result .= $ this -> pool -> render -> renderBacktraceSourceLine ( 'source' , $ realLineNo , $ this -> pool -> encodingService -> encodeString ( $ content [ $ currentLineNo ] , true ) ) ; } } return $ result ; }
Reads sourcecode from files, for the backtrace.

@param string $filePath
Path to the file you want to read.
@param int $highlight
The line number you want to highlight
@param int $readFrom
The start line.
@param int $readTo
The end line.

@return string
The source code, HTML formatted.
Reads sourcecode from files for the backtrace .