public static function getCodeSnippet(string $filePathAndName, int $lineNumber, bool $plaintext = false): string
    {
        if ($plaintext) {
            return static::getCodeSnippetPlaintext($filePathAndName, $lineNumber);
        }

        $codeSnippet = '<br />';
        if (@file_exists($filePathAndName)) {
            $phpFile = @file($filePathAndName);
            if (!is_array($phpFile)) {
                return $codeSnippet;
            }
            $filePaths = static::findProxyAndShortFilePath($filePathAndName);

            $codeSnippet = '<div class="Flow-Debug-CodeSnippet">';
            $filePathReal = $filePaths['proxy'] !== '' ? $filePaths['proxy'] : $filePaths['short'];
            $codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">' . $filePathReal . '</div>';
            if ($filePaths['proxy'] !== '') {
                $codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">Original File: ' . $filePaths['short'] . '</div>';
            }

            $codeSnippet .= '<div class="Flow-Debug-CodeSnippet-Code">';

            $startLine = ($lineNumber > 2) ? ($lineNumber - 2) : 1;
            $endLine = ($lineNumber < (count($phpFile) - 2)) ? ($lineNumber + 3) : count($phpFile) + 1;
            for ($line = $startLine; $line < $endLine; $line++) {
                $codeSnippet .= '<pre class="' . (($line === $lineNumber) ? 'Flow-Debug-CodeSnippet-Code-Highlighted' : '') . '">';
                $codeLine = str_replace("\t", ' ', $phpFile[$line - 1]);
                $codeSnippet .= sprintf('%05d', $line) . ': ';
                $codeSnippet .= htmlspecialchars($codeLine);
                $codeSnippet .= '</pre>';
            }
            $codeSnippet .= '</div></div>';
        }

        return $codeSnippet;
    }
public static function getCodeSnippet(string $filePathAndName, int $lineNumber, bool $plaintext = false): string
    {
        if ($plaintext) {
            return static::getCodeSnippetPlaintext($filePathAndName, $lineNumber);
        }

        $codeSnippet = '<br />';
        if (@file_exists($filePathAndName)) {
            $phpFile = @file($filePathAndName);
            if (!is_array($phpFile)) {
                return $codeSnippet;
            }
            $filePaths = static::findProxyAndShortFilePath($filePathAndName);

            $codeSnippet = '<div class="Flow-Debug-CodeSnippet">';
            $filePathReal = $filePaths['proxy'] !== '' ? $filePaths['proxy'] : $filePaths['short'];
            $codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">' . $filePathReal . '</div>';
            if ($filePaths['proxy'] !== '') {
                $codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">Original File: ' . $filePaths['short'] . '</div>';
            }

            $codeSnippet .= '<div class="Flow-Debug-CodeSnippet-Code">';

            $startLine = ($lineNumber > 2) ? ($lineNumber - 2) : 1;
            $endLine = ($lineNumber < (count($phpFile) - 2)) ? ($lineNumber + 3) : count($phpFile) + 1;
            for ($line = $startLine; $line < $endLine; $line++) {
                $codeSnippet .= '<pre class="' . (($line === $lineNumber) ? 'Flow-Debug-CodeSnippet-Code-Highlighted' : '') . '">';
                $codeLine = str_replace("\t", ' ', $phpFile[$line - 1]);
                $codeSnippet .= sprintf('%05d', $line) . ': ';
                $codeSnippet .= htmlspecialchars($codeLine);
                $codeSnippet .= '</pre>';
            }
            $codeSnippet .= '</div></div>';
        }

        return $codeSnippet;
    }
public static function getCodeSnippet ( string $ filePathAndName , int $ lineNumber , bool $ plaintext = false ) : string { if ( $ plaintext ) { return static :: getCodeSnippetPlaintext ( $ filePathAndName , $ lineNumber ) ; } $ codeSnippet = '<br />' ; if ( @ file_exists ( $ filePathAndName ) ) { $ phpFile = @ file ( $ filePathAndName ) ; if ( ! is_array ( $ phpFile ) ) { return $ codeSnippet ; } $ filePaths = static :: findProxyAndShortFilePath ( $ filePathAndName ) ; $ codeSnippet = '<div class="Flow-Debug-CodeSnippet">' ; $ filePathReal = $ filePaths [ 'proxy' ] !== '' ? $ filePaths [ 'proxy' ] : $ filePaths [ 'short' ] ; $ codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">' . $ filePathReal . '</div>' ; if ( $ filePaths [ 'proxy' ] !== '' ) { $ codeSnippet .= '<div class="Flow-Debug-CodeSnippet-File">Original File: ' . $ filePaths [ 'short' ] . '</div>' ; } $ codeSnippet .= '<div class="Flow-Debug-CodeSnippet-Code">' ; $ startLine = ( $ lineNumber > 2 ) ? ( $ lineNumber - 2 ) : 1 ; $ endLine = ( $ lineNumber < ( count ( $ phpFile ) - 2 ) ) ? ( $ lineNumber + 3 ) : count ( $ phpFile ) + 1 ; for ( $ line = $ startLine ; $ line < $ endLine ; $ line ++ ) { $ codeSnippet .= '<pre class="' . ( ( $ line === $ lineNumber ) ? 'Flow-Debug-CodeSnippet-Code-Highlighted' : '' ) . '">' ; $ codeLine = str_replace ( "\t" , ' ' , $ phpFile [ $ line - 1 ] ) ; $ codeSnippet .= sprintf ( '%05d' , $ line ) . ': ' ; $ codeSnippet .= htmlspecialchars ( $ codeLine ) ; $ codeSnippet .= '</pre>' ; } $ codeSnippet .= '</div></div>' ; } return $ codeSnippet ; }
Returns a code snippet from the specified file.

@param string $filePathAndName Absolute path and filename of the PHP file
@param integer $lineNumber Line number defining the center of the code snippet
@param boolean $plaintext
@return string The code snippet
Returns a code snippet from the specified file .