classSqlSymbolProfile
final class SqlSymbolProfile
How one dialect spells what is written plainly.
Which characters may spell an identifier, how far a number runs, what nests, what brackets, and what ends a statement or separates a list are all asked here, because they are the shapes a scanner tells apart without knowing what any of them mean.
Methods§
public function __construct(
private string $numericLiteralPattern,
private string $identifierStartPattern,
private string $identifierPartPattern,
array{string, string}|null $bracketPair,
array{string, string} $nestingPair,
private string $statementDelimiter,
private string $listDelimiter,
private LexicalPattern $patterns = new \ZtdQuery\Sql\LexicalPattern(),
)Parameters
$numericLiteralPattern | string | Pattern a number is written as |
$identifierStartPattern | string | Pattern the first character of an identifier matches |
$identifierPartPattern | string | Pattern every later character of an identifier matches |
$bracketPair | array{string, string}|null | Opening and closing bracket, or null where the dialect has none |
$nestingPair | array{string, string} | Opening and closing delimiter that nest |
$statementDelimiter | string | Single character that ends a statement |
$listDelimiter | string | Single character that separates list items |
$patterns | LexicalPattern | Reads a regular expression against a position |
Throws
InvalidDefinitionException When a pattern is unreadable, a delimiter is empty, or a single-character delimiter is not one characterTest cases 9
SqlSymbolProfileTest::testIsBracketClosingAnswersWhatTheDialectClosesABracketWithcoversSqlSymbolProfileTest::testIsBracketOpeningAnswersFalseWhereTheDialectBracketsNothingcoversSqlSymbolProfileTest::testIsIdentifierPartAnswersWhatMayCarryANamecoversSqlSymbolProfileTest::testIsIdentifierStartAnswersWhatMayOpenANamecoversSqlSymbolProfileTest::testIsNestingClosingAnswersWhatTheDialectClosesANestingWithcoversSqlSymbolProfileTest::testIsNestingOpeningAnswersWhatTheDialectNestsWithcoversSqlSymbolProfileTest::testIsStatementDelimiterAnswersWhatEndsAStatementcoversSqlSymbolProfileTest::testListDelimiterAnswersWhatSeparatesListItemscoversSqlSymbolProfileTest::testNumberLengthAtMeasuresAsFarAsTheDialectSpellsANumbercovers
Calls 4
- new LexicalPattern line 46
- method-call LexicalPattern::assertValid() line 48
- new InvalidDefinitionException line 52
- function-call
strlenline 61
public function numberLengthAt(string $sql, int $offset): intAnswers how long the number starting here is.
Parameters
$sql | string | Statement being scanned |
$offset | int | Position to look at |
Returns
int Its length, or zero when no number starts thereCalled from 1
Calls 2
- method-call LexicalPattern::matchAt() line 76
- function-call
strlenline 78
public function isIdentifierStart(string $character): boolReports whether an identifier may begin with this character.
Parameters
$character | string | Character to test |
Returns
bool True when it mayTest cases 1
Called from 1
Calls 1
- method-call LexicalPattern::matchesCharacter() line 90
public function isIdentifierPart(string $character): boolReports whether an identifier may continue with this character.
Parameters
$character | string | Character to test |
Returns
bool True when it mayTest cases 1
Called from 2
Calls 1
- method-call LexicalPattern::matchesCharacter() line 102
public function isBracketOpening(string $character): boolReports whether this character opens a bracket.
Parameters
$character | string | Character to test |
Returns
bool True when it does, and false where the dialect brackets nothingTest cases 1
Called from 1
public function isBracketClosing(string $character): boolReports whether this character closes a bracket.
Parameters
$character | string | Character to test |
Returns
bool True when it does, and false where the dialect brackets nothingTest cases 1
Called from 1
public function isNestingOpening(string $character): boolReports whether this character opens a nesting.
Parameters
$character | string | Character to test |
Returns
bool True when it doesTest cases 1
Called from 1
public function isNestingClosing(string $character): boolReports whether this character closes a nesting.
Parameters
$character | string | Character to test |
Returns
bool True when it doesTest cases 1
Called from 1
public function isStatementDelimiter(string $symbol): boolReports whether this symbol ends a statement.
Parameters
$symbol | string | Symbol to test |
Returns
bool True when it doesTest cases 1
public function listDelimiter(): stringAnswers the character that separates list items.
Returns
string The separatorTest cases 1
Called from 1
Private surface 8§
Implementation details, listed for orientation only.
private array{non-empty-string, non-empty-string}|null $bracketPairprivate array{non-empty-string, non-empty-string} $nestingPairprivate string $numericLiteralPatternprivate string $identifierStartPatternprivate string $identifierPartPatternprivate string $statementDelimiterprivate string $listDelimiterprivate LexicalPattern $patterns = new \ZtdQuery\Sql\LexicalPattern()Test cases 21§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
SqlSymbolProfileTest::testIsBracketClosingAnswersWhatTheDialectClosesABracketWithcoversSqlSymbolProfileTest::testIsBracketOpeningAnswersFalseWhereTheDialectBracketsNothingcoversSqlSymbolProfileTest::testIsIdentifierPartAnswersWhatMayCarryANamecoversSqlSymbolProfileTest::testIsIdentifierStartAnswersWhatMayOpenANamecoversSqlSymbolProfileTest::testIsNestingClosingAnswersWhatTheDialectClosesANestingWithcoversSqlSymbolProfileTest::testIsNestingOpeningAnswersWhatTheDialectNestsWithcoversSqlSymbolProfileTest::testIsStatementDelimiterAnswersWhatEndsAStatementcoversSqlSymbolProfileTest::testListDelimiterAnswersWhatSeparatesListItemscoversSqlSymbolProfileTest::testNumberLengthAtMeasuresAsFarAsTheDialectSpellsANumbercovers
Other tests reaching this symbol 12
FakeSqlLexerProfiles::symbolscallsSqlQuoteProfileTestcallsSqlBlockCommentReaderTestcallsSqlDelimitedReaderTestcallsSqlParameterReaderTestcallsSqlTriviaReaderTestcallsSqlWordReaderTestcallsSqlIdentifierComponentTestcallsSqlKeywordSequenceTestcallsSqlLexerProfileTestcallsSqlTokenScannerTestcallsSqlTokenStreamTestcalls
Relations§
Instantiated in 1
Method calls 10
- method-call ZtdQuery\Sql\Profile\SqlQuoteProfile::stringUsesBackslashEscapes() packages/ztd-query-core/src/Sql/Profile/SqlQuoteProfile.php:174
- method-call ZtdQuery\Sql\SqlLexerProfile::numberLengthAt() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:251
- method-call ZtdQuery\Sql\SqlLexerProfile::isIdentifierStart() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:263
- method-call ZtdQuery\Sql\SqlLexerProfile::isIdentifierPart() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:275
- method-call ZtdQuery\Sql\SqlLexerProfile::isBracketOpening() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:287
- method-call ZtdQuery\Sql\SqlLexerProfile::isBracketClosing() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:299
- method-call ZtdQuery\Sql\SqlLexerProfile::isNestingOpening() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:311
- method-call ZtdQuery\Sql\SqlLexerProfile::isNestingClosing() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:323
- method-call ZtdQuery\Sql\SqlLexerProfile::isStatementDelimiter() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:335
- method-call ZtdQuery\Sql\SqlLexerProfile::listDelimiter() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:345