classSqlTriviaReader
final class SqlTriviaReader
Reads what carries no meaning of its own: whitespace and comments.
These are kept rather than dropped so that a statement can be written back out exactly as it came in. A run of whitespace is one lexeme, and so is a whole comment, however long it runs.
Methods§
public function __construct(private SqlBlockCommentReader $blockComments = new \ZtdQuery\Sql\Reader\SqlBlockCommentReader())Creates the trivia reader from what reads a block comment.
Parameters
$blockComments | SqlBlockCommentReader | What reads a block comment |
Test cases 5
SqlTriviaReaderTest::testReadAtAnswersNothingWhereSomethingMeaningfulBeginscoversSqlTriviaReaderTest::testReadAtLeavesTheNewlineThatEndsALineCommentToBeReadAsWhitespacecoversSqlTriviaReaderTest::testReadAtReadsALineCommentToTheEndOfAStatementThatNeverBreaksTheLinecoversSqlTriviaReaderTest::testReadAtReadsAWholeBlockCommentAsOneLexemecoversSqlTriviaReaderTest::testReadAtReadsAWholeRunOfWhitespaceAsOneLexemecovers
Calls 1
public function readAt(string $sql, int $offset, SqlLexerProfile $profile): SqlLexeme|nullAnswers what trivia starts at an offset.
Parameters
$sql | string | The statement, as written |
$offset | int | Where to look |
$profile | SqlLexerProfile | What the dialect spells things with |
Returns
SqlLexeme|null The trivia read there, or null when none starts thereTest cases 5
SqlTriviaReaderTest::testReadAtAnswersNothingWhereSomethingMeaningfulBeginscovers and callsSqlTriviaReaderTest::testReadAtLeavesTheNewlineThatEndsALineCommentToBeReadAsWhitespacecovers and callsSqlTriviaReaderTest::testReadAtReadsALineCommentToTheEndOfAStatementThatNeverBreaksTheLinecovers and callsSqlTriviaReaderTest::testReadAtReadsAWholeBlockCommentAsOneLexemecovers and callsSqlTriviaReaderTest::testReadAtReadsAWholeRunOfWhitespaceAsOneLexemecovers and calls
Called from 1
Calls 8
- function-call
strlenline 40 - function-call
ctype_spaceline 41 - new SqlLexeme line 48
- class-const SqlTokenKind::Whitespace() line 48
- method-call SqlLexerProfile::startsLineComment() line 51
- function-call
strposline 52 - class-const SqlTokenKind::Comment() line 54
- method-call SqlBlockCommentReader::endAt() line 57
Private surface 1§
Implementation details, listed for orientation only.
private SqlBlockCommentReader $blockComments = new \ZtdQuery\Sql\Reader\SqlBlockCommentReader()Test cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
SqlTriviaReaderTest::testReadAtAnswersNothingWhereSomethingMeaningfulBeginscovers and callsSqlTriviaReaderTest::testReadAtLeavesTheNewlineThatEndsALineCommentToBeReadAsWhitespacecovers and callsSqlTriviaReaderTest::testReadAtReadsALineCommentToTheEndOfAStatementThatNeverBreaksTheLinecovers and callsSqlTriviaReaderTest::testReadAtReadsAWholeBlockCommentAsOneLexemecovers and callsSqlTriviaReaderTest::testReadAtReadsAWholeRunOfWhitespaceAsOneLexemecovers and calls
Other tests reaching this symbol 4
SqlIdentifierComponentTestcallsSqlKeywordSequenceTestcallsSqlTokenScannerTestcallsSqlTokenStreamTestcalls