classSourceCode
final class SourceCode
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
The analyzed PHP source, with numbered lines and the database calls marked.
Constants§
public const CONTEXT = 8The lines shown before and after a call on its statement page.
Methods§
public function __construct(?HtmlText $text = null)public function excerpt(ReportSite $site, CatalogEntry $entry): stringA call's surrounding code, linked to the complete file at the same line.
Parameters
$site | ReportSite | |
$entry | CatalogEntry |
Returns
stringTest cases 3
Called from 1
Calls 9
- method-call ReportSite::catalog() line 38
- function-call
maxline 42 - class-const SourceCode::CONTEXT() line 42
- function-call
array_sliceline 44 - method-call SourceCode::split() line 44
- method-call ReportSite::filePage() line 45
- method-call HtmlText::escape() line 48
- method-call HtmlText::link() line 49
- method-call SourceCode::lines() line 50
public function file(ReportSite $site, string $file): stringA file's complete source, including files that could not be parsed.
Parameters
$site | ReportSite | |
$file | string |
Returns
stringTest cases 1
Called from 1
Calls 4
- method-call ReportSite::catalog() line 58
- method-call ReportSite::index() line 63
- method-call SourceCode::lines() line 68
- method-call SourceCode::split() line 68
public function lines(
list<string> $lines,
int $first,
list<int> $calls,
string $target = '',
): stringSource lines with their original indentation, escaped before embedding.
Parameters
$lines | list<string> | |
$first | int | |
$calls | list<int> | The line numbers to highlight |
$target | string | The full source page, or empty for links within this page |
Returns
stringTest cases 1
Called from 2
Calls 3
- function-call
array_fill_keysline 81 - method-call HtmlText::escape() line 85
- function-call
implodeline 89
public function split(string $source): list<string>Lines split using PHP's newline conventions, retaining a trailing empty line.
Parameters
$source | string |
Returns
list<string>Test cases 1
Called from 2
Private surface 1§
Implementation details, listed for orientation only.
private HtmlText $textTest cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
SourceCodeTest::testExcerptClipsAtTheStartAndEndOfTheFilecallsSourceCodeTest::testExcerptOmitsUnavailableSourceWithoutReadingTheFilesystemcallsSourceCodeTest::testExcerptShowsContextAndLinksToTheHighlightedCallInTheFullFilecallsSourceCodeTest::testFileIncludesAllLinesAndMarksEveryCallcallsSourceCodeTest::testLinesEscapesMarkupQuotesAndInvalidUtf8WithoutDroppingTheSourcecallsSourceCodeTest::testSplitPreservesEmptyLinesAndRecognizesPhpNewlinescalls
Other tests reaching this symbol 3
HtmlReporterTestcallsFilePageTestcallsStatementPageTestcalls