classSqlParameterReader
final class SqlParameterReader
Reads a placeholder standing in for a value the driver will bind.
A placeholder is written either by position, where the whole of it is one run of bytes the profile measures, or by name, where a prefix is followed by a name that may itself be spelled in parts. Which prefixes, separators and suffixes a dialect allows are all asked of the profile.
Methods§
public function readAt(string $sql, int $offset, SqlLexerProfile $profile): SqlLexeme|nullAnswers what placeholder 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 placeholder read there, or null when none starts thereTest cases 6
SqlParameterReaderTest::testReadAtAnswersNothingForAPrefixThatNoNameFollowscovers and callsSqlParameterReaderTest::testReadAtAnswersNothingWhereNoPlaceholderBeginscovers and callsSqlParameterReaderTest::testReadAtReadsAPlaceholderNameSpelledInPartsAsOneLexemecovers and callsSqlParameterReaderTest::testReadAtReadsAPlaceholderWrittenByNamecovers and callsSqlParameterReaderTest::testReadAtReadsAPlaceholderWrittenByPositionAsFarAsTheDialectSpellsItcovers and callsSqlParameterReaderTest::testReadAtReadsTheSuffixTheDialectAllowsAPlaceholderToCarrycovers and calls
Called from 1
Calls 8
- method-call SqlLexerProfile::positionalParameterLengthAt() line 31
- new SqlLexeme line 33
- class-const SqlTokenKind::Parameter() line 33
- method-call SqlLexerProfile::namedParameterPrefixAt() line 36
- method-call SqlLexerProfile::isIdentifierStart() line 37
- function-call
strlenline 37 - method-call SqlParameterReader::endOfName() line 41
- method-call SqlLexerProfile::parameterSuffixLength() line 45
public function endOfName(
string $sql,
int $offset,
string $prefix,
SqlLexerProfile $profile,
): intAnswers where the name of a placeholder ends.
A name may be spelled in parts, joined by whatever the dialect allows; a separator only joins when a further name follows it, so a trailing one is left to be read as something else.
Parameters
$sql | string | The statement, as written |
$offset | int | Where the name starts |
$prefix | string | The prefix the placeholder was written with |
$profile | SqlLexerProfile | What the dialect spells things with |
Returns
int The offset just past the nameTest cases 5
SqlParameterReaderTest::testEndOfNameStopsAtASeparatorNoFurtherNameFollowscovers and callsSqlParameterReaderTest::testEndOfNameStopsAtTheEndOfTheStatementcovers and callsSqlParameterReaderTest::testReadAtReadsAPlaceholderNameSpelledInPartsAsOneLexemecoversSqlParameterReaderTest::testReadAtReadsAPlaceholderWrittenByNamecoversSqlParameterReaderTest::testReadAtReadsTheSuffixTheDialectAllowsAPlaceholderToCarrycovers
Called from 1
Calls 4
- function-call
strlenline 65 - method-call SqlLexerProfile::isIdentifierPart() line 67
- method-call SqlLexerProfile::parameterNameSeparatorAt() line 71
- method-call SqlLexerProfile::isIdentifierStart() line 73
Test cases 12§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
SqlParameterReaderTest::testEndOfNameStopsAtASeparatorNoFurtherNameFollowscovers and callsSqlParameterReaderTest::testEndOfNameStopsAtTheEndOfTheStatementcovers and callsSqlParameterReaderTest::testReadAtAnswersNothingForAPrefixThatNoNameFollowscovers and callsSqlParameterReaderTest::testReadAtAnswersNothingWhereNoPlaceholderBeginscovers and callsSqlParameterReaderTest::testReadAtReadsAPlaceholderNameSpelledInPartsAsOneLexemecovers and callsSqlParameterReaderTest::testReadAtReadsAPlaceholderWrittenByNamecovers and callsSqlParameterReaderTest::testReadAtReadsAPlaceholderWrittenByPositionAsFarAsTheDialectSpellsItcovers and callsSqlParameterReaderTest::testReadAtReadsTheSuffixTheDialectAllowsAPlaceholderToCarrycovers and calls
Other tests reaching this symbol 4
SqlIdentifierComponentTestcallsSqlKeywordSequenceTestcallsSqlTokenScannerTestcallsSqlTokenStreamTestcalls