classTrivia
final class Trivia
Restricted visibility: declared "@visibility SqlFormatter". Code outside that scope must not name this declaration.
Removes ordinary comments while retaining directives and executable comment bodies.
Properties§
public bool $executable = falseWhether the next token belongs to an executable comment body.
Methods§
public function __construct(private Closure(string, int, int, int, bool): bool $nesting)Parameters
$nesting | Closure(string, int, int, int, bool): bool | Block comment nesting rule |
public function clean(string $text): stringProcesses trivia in source order, including markers split across token boundaries.
Parameters
$text | string |
Returns
stringTest cases 3
Called from 2
Calls 6
- function-call
strlenline 35 - method-call Trivia::executablePart() line 37
- function-call
substrline 38 - method-call Trivia::blockEnd() line 39
- function-call
in_arrayline 40 - function-call
strcspnline 48
public function executablePart(string $text, int &$offset): stringCopies trivia inside executable SQL without confusing inner and outer comments.
Parameters
$text | string | |
$offset | int |
Returns
stringCalled from 1
Calls 3
- function-call
substrline 62 - method-call Trivia::blockEnd() line 63
- function-call
strcspnline 68
public function blockEnd(string $text, int $start): intFinds the end of a comment using the supplied nesting behavior.
Parameters
$text | string | |
$start | int |
Returns
intTest cases 1
Called from 2
Private surface 1§
Implementation details, listed for orientation only.
private Closure(string, int, int, int, bool): bool $nestingTest cases 20§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
TriviaTest::testBlockEndRespectsTheDialectNestingRulescallsTriviaTest::testCleanKeepsOnlyTopLevelDirectivescallsTriviaTest::testCleanRecognizesMysqlNestedVersionCommentscallsTriviaTest::testCleanRetainsExecutableMarkersAndBodyWhitespaceAcrossTokenscallsTriviaTest::testExecutablePartDoesNotCloseTheOuterCommentAtAnInnerCommentcalls
Other tests reaching this symbol 15
DocumentTestcallsGroupingTestcallsKeywordsTestcallsReductionsTestcallsRendererTestcallsRulesTestcallsSettingsTestcallsShapeTestcallsSpacingTestcallsVisitorTestcallsFormatterTestcallsFormatterTestcallsDialectTestcallsDialectTestcallsDialectTestcalls