classSqlParameterProfile
final class SqlParameterProfile
How one dialect writes a placeholder for a value the driver will bind.
A placeholder is written either by position or by name, and a dialect decides what spells each, what may join a name that is spelled in parts, what a name may carry after it, and what a prefix is not a placeholder after, because the same character often spells an operator as well.
Methods§
public function __construct(
list<string> $positionalParameterPatterns,
array<string, list<string>> $namedParameterSeparators,
array<string, string> $namedParameterSuffixPatterns,
array<string, list<string>> $namedParameterForbiddenPredecessors,
private LexicalPattern $patterns = new \ZtdQuery\Sql\LexicalPattern(),
LexicalDelimiters $delimiters = new \ZtdQuery\Sql\LexicalDelimiters(),
)Parameters
$positionalParameterPatterns | list<string> | Patterns a positional parameter is written as |
$namedParameterSeparators | array<string, list<string>> | Parameter prefix => what may separate it from its name |
$namedParameterSuffixPatterns | array<string, string> | Parameter prefix => pattern for what may follow its name |
$namedParameterForbiddenPredecessors | array<string, list<string>> | Parameter prefix => what it is not a parameter after |
$patterns | LexicalPattern | Reads a regular expression against a position |
$delimiters | LexicalDelimiters | Refuses lexical data a scanner could not use |
Throws
InvalidDefinitionException When a delimiter is empty or a pattern is unreadableTest cases 5
SqlParameterProfileTest::testNamedParameterPrefixAtAnswersNothingAfterWhatTheDialectForbidscoversSqlParameterProfileTest::testNamedParameterPrefixAtAnswersThePrefixAPlaceholderIsWrittenWithcoversSqlParameterProfileTest::testParameterNameSeparatorAtAnswersWhatJoinsAPrefixToItsNamecoversSqlParameterProfileTest::testParameterSuffixLengthMeasuresWhatAPlaceholderCarriesAfterItsNamecoversSqlParameterProfileTest::testPositionalParameterLengthAtMeasuresTheFirstPatternThatMatchescovers
Calls 5
- new LexicalPattern line 48
- new LexicalDelimiters line 49
- method-call LexicalDelimiters::validPatterns() line 51
- method-call LexicalDelimiters::perPrefixLists() line 52
- method-call LexicalDelimiters::perPrefixPatterns() line 53
public function positionalParameterLengthAt(string $sql, int $offset): intAnswers how long the positional parameter starting here is.
Parameters
$sql | string | Statement being scanned |
$offset | int | Position to look at |
Returns
int Its length, or zero when none starts thereTest cases 1
Called from 1
Calls 2
- method-call LexicalPattern::matchAt() line 70
- function-call
strlenline 72
public function namedParameterPrefixAt(string $sql, int $offset): string|nullAnswers the prefix of the named parameter starting here, if any.
A prefix is not always a parameter: some dialects write the same character as part of an operator, and what comes before it is what tells them apart.
Parameters
$sql | string | Statement being scanned |
$offset | int | Position to look at |
Returns
string|null The prefix, or null when no parameter starts thereTest cases 2
Called from 1
public function parameterNameSeparatorAt(string $prefix, string $sql, int $offset): string|nullAnswers what separates a parameter prefix from its name here, if anything.
Parameters
$prefix | string | Prefix the parameter was written with |
$sql | string | Statement being scanned |
$offset | int | Position to look at |
Returns
string|null The separator, or null when none is written thereTest cases 1
Called from 1
public function parameterSuffixLength(string $prefix, string $sql, int $offset): intAnswers how much a parameter written with this prefix carries after its name.
Parameters
$prefix | string | Prefix the parameter was written with |
$sql | string | Statement being scanned |
$offset | int | Position to look at |
Returns
int How long it is, or zero when nothing followsTest cases 1
Called from 1
Calls 2
- method-call LexicalPattern::matchAt() line 141
- function-call
strlenline 143
Private surface 5§
Implementation details, listed for orientation only.
private list<non-empty-string> $positionalParameterPatternsprivate array<non-empty-string, list<non-empty-string>> $namedParameterSeparatorsprivate array<non-empty-string, non-empty-string> $namedParameterSuffixPatternsprivate array<non-empty-string, list<non-empty-string>> $namedParameterForbiddenPredecessorsprivate LexicalPattern $patterns = new \ZtdQuery\Sql\LexicalPattern()Test cases 16§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
SqlParameterProfileTest::testNamedParameterPrefixAtAnswersNothingAfterWhatTheDialectForbidscoversSqlParameterProfileTest::testNamedParameterPrefixAtAnswersThePrefixAPlaceholderIsWrittenWithcoversSqlParameterProfileTest::testParameterNameSeparatorAtAnswersWhatJoinsAPrefixToItsNamecoversSqlParameterProfileTest::testParameterSuffixLengthMeasuresWhatAPlaceholderCarriesAfterItsNamecoversSqlParameterProfileTest::testPositionalParameterLengthAtMeasuresTheFirstPatternThatMatchescovers
Other tests reaching this symbol 11
FakeSqlLexerProfiles::parameterscallsSqlBlockCommentReaderTestcallsSqlDelimitedReaderTestcallsSqlParameterReaderTestcallsSqlTriviaReaderTestcallsSqlWordReaderTestcallsSqlIdentifierComponentTestcallsSqlKeywordSequenceTestcallsSqlLexerProfileTestcallsSqlTokenScannerTestcallsSqlTokenStreamTestcalls
Relations§
Instantiated in 1
Method calls 4
- method-call ZtdQuery\Sql\SqlLexerProfile::positionalParameterLengthAt() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:197
- method-call ZtdQuery\Sql\SqlLexerProfile::namedParameterPrefixAt() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:210
- method-call ZtdQuery\Sql\SqlLexerProfile::parameterNameSeparatorAt() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:224
- method-call ZtdQuery\Sql\SqlLexerProfile::parameterSuffixLength() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:238