classSqlDelimitedReader
final class SqlDelimitedReader
Reads what a pair of delimiters closes: strings and quoted identifiers.
Which byte opens a run, which one closes it, and whether a backslash escapes inside it are all the dialect's business, so they are asked of the profile. A dollar-quoted string is closed by the same tag that opened it and nothing inside it escapes, so it is read on its own terms.
Methods§
public function readAt(string $sql, int $offset, SqlLexerProfile $profile): SqlLexeme|nullAnswers what delimited run 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 run read there, or null when none starts thereTest cases 5
SqlDelimitedReaderTest::testReadAtAnswersNothingWhereNoDelimiterOpenscovers and callsSqlDelimitedReaderTest::testReadAtReadsADollarQuotedRunToTheEndOfAStatementThatNeverClosescovers and callsSqlDelimitedReaderTest::testReadAtReadsADollarQuotedRunUpToTheTagThatOpenedItcovers and callsSqlDelimitedReaderTest::testReadAtReadsAQuotedNameAsAnIdentifierRatherThanAStringcovers and callsSqlDelimitedReaderTest::testReadAtReadsAQuotedRunOfTextAsAStringcovers and calls
Called from 1
Calls 10
- method-call SqlLexerProfile::stringQuoteClosing() line 33
- method-call SqlLexerProfile::stringUsesBackslashEscapes() line 35
- new SqlLexeme line 37
- class-const SqlTokenKind::String() line 38
- method-call SqlDelimitedReader::endOfDelimited() line 39
- method-call SqlLexerProfile::identifierQuoteClosing() line 43
- class-const SqlTokenKind::QuotedIdentifier() line 46
- method-call SqlLexerProfile::dollarQuoteDelimiterAt() line 51
- function-call
strposline 56 - function-call
strlenline 56
public function endOfDelimited(
string $sql,
int $offset,
string $opening,
string $closing,
bool $backslashEscapes,
): intAnswers where a run closed by a delimiter ends.
A doubled closing delimiter is how SQL writes the delimiter itself, so it does not close the run. A run left unclosed at the end of the statement ends there, because there is nothing further to read.
Parameters
$sql | string | The statement, as written |
$offset | int | Where the opening delimiter is |
$opening | string | The delimiter that opened the run |
$closing | string | The delimiter that will close it |
$backslashEscapes | bool | Whether a backslash escapes the byte after it |
Returns
int The offset just past the closing delimiterTest cases 6
SqlDelimitedReaderTest::testEndOfDelimitedAnswersWhereTheClosingDelimiterLeftOffcovers and callsSqlDelimitedReaderTest::testEndOfDelimitedReadsPastADoubledDelimiterBecauseItWritesTheDelimitercovers and callsSqlDelimitedReaderTest::testEndOfDelimitedReadsPastAnEscapedDelimiterWhereBackslashesEscapecovers and callsSqlDelimitedReaderTest::testEndOfDelimitedStopsAtTheEndOfAStatementThatNeverClosedTheRuncovers and callsSqlDelimitedReaderTest::testReadAtReadsAQuotedNameAsAnIdentifierRatherThanAStringcoversSqlDelimitedReaderTest::testReadAtReadsAQuotedRunOfTextAsAStringcovers
Called from 2
Test cases 13§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
SqlDelimitedReaderTest::testEndOfDelimitedAnswersWhereTheClosingDelimiterLeftOffcovers and callsSqlDelimitedReaderTest::testEndOfDelimitedReadsPastADoubledDelimiterBecauseItWritesTheDelimitercovers and callsSqlDelimitedReaderTest::testEndOfDelimitedReadsPastAnEscapedDelimiterWhereBackslashesEscapecovers and callsSqlDelimitedReaderTest::testEndOfDelimitedStopsAtTheEndOfAStatementThatNeverClosedTheRuncovers and callsSqlDelimitedReaderTest::testReadAtAnswersNothingWhereNoDelimiterOpenscovers and callsSqlDelimitedReaderTest::testReadAtReadsADollarQuotedRunToTheEndOfAStatementThatNeverClosescovers and callsSqlDelimitedReaderTest::testReadAtReadsADollarQuotedRunUpToTheTagThatOpenedItcovers and callsSqlDelimitedReaderTest::testReadAtReadsAQuotedNameAsAnIdentifierRatherThanAStringcovers and callsSqlDelimitedReaderTest::testReadAtReadsAQuotedRunOfTextAsAStringcovers and calls
Other tests reaching this symbol 4
SqlIdentifierComponentTestcallsSqlKeywordSequenceTestcallsSqlTokenScannerTestcallsSqlTokenStreamTestcalls