classSqlCommentProfile
final class SqlCommentProfile
How one dialect writes a comment.
A comment runs either to the end of the line or between a pair of delimiters, and dialects differ in what spells each, in whether a prefix only comments out the line when whitespace follows it, and in whether one block comment may hold another.
Methods§
public function __construct(
list<string> $lineCommentPrefixes,
list<string> $whitespaceDelimitedLineCommentPrefixes,
array<string, string> $blockCommentPairs,
private bool $nestedBlockComments,
LexicalDelimiters $delimiters = new \ZtdQuery\Sql\LexicalDelimiters(),
)Parameters
$lineCommentPrefixes | list<string> | Prefixes that start a comment running to the end of the line |
$whitespaceDelimitedLineCommentPrefixes | list<string> | Prefixes that do so only when whitespace follows |
$blockCommentPairs | array<string, string> | Opening delimiter => the one that closes the comment |
$nestedBlockComments | bool | Whether a block comment may contain another |
$delimiters | LexicalDelimiters | Refuses lexical data a scanner could not use |
Throws
InvalidDefinitionException When a delimiter is emptyTest cases 5
SqlCommentProfileTest::testBlockCommentAtAnswersNothingWhereNoCommentOpenscoversSqlCommentProfileTest::testBlockCommentAtAnswersTheDelimitersThatOpenAndCloseOnecoversSqlCommentProfileTest::testStartsLineCommentSeesEveryPrefixTheDialectDeclarescoversSqlCommentProfileTest::testStartsLineCommentTakesAPrefixThatNeedsWhitespaceOnlyWhereWhitespaceFollowscoversSqlCommentProfileTest::testSupportsNestedBlockCommentsSaysWhatTheDialectDeclaredcovers
Calls 3
- new LexicalDelimiters line 43
- method-call LexicalDelimiters::nonEmpty() line 45
- method-call LexicalDelimiters::pairs() line 49
public function startsLineComment(string $sql, int $offset): boolReports whether a comment running to the end of the line starts here.
Parameters
$sql | string | Statement being scanned |
$offset | int | Position to look at |
Returns
bool True when one starts thereTest cases 2
Called from 1
public function blockCommentAt(
string $sql,
int $offset,
): array{non-empty-string, non-empty-string}|nullAnswers the block comment delimiters starting here, if any.
Parameters
$sql | string | Statement being scanned |
$offset | int | Position to look at |
Returns
array{non-empty-string, non-empty-string}|null The opening and closing delimiters, or null when no comment starts thereTest cases 2
Called from 1
public function supportsNestedBlockComments(): boolReports whether a block comment may contain another.
Returns
bool True when the dialect nests themPrivate surface 4§
Implementation details, listed for orientation only.
private list<non-empty-string> $lineCommentPrefixesprivate list<non-empty-string> $whitespaceDelimitedLineCommentPrefixesprivate array<non-empty-string, non-empty-string> $blockCommentPairsprivate bool $nestedBlockCommentsTest cases 16§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
SqlCommentProfileTest::testBlockCommentAtAnswersNothingWhereNoCommentOpenscoversSqlCommentProfileTest::testBlockCommentAtAnswersTheDelimitersThatOpenAndCloseOnecoversSqlCommentProfileTest::testStartsLineCommentSeesEveryPrefixTheDialectDeclarescoversSqlCommentProfileTest::testStartsLineCommentTakesAPrefixThatNeedsWhitespaceOnlyWhereWhitespaceFollowscoversSqlCommentProfileTest::testSupportsNestedBlockCommentsSaysWhatTheDialectDeclaredcovers
Other tests reaching this symbol 11
FakeSqlLexerProfiles::commentscallsSqlBlockCommentReaderTestcallsSqlDelimitedReaderTestcallsSqlParameterReaderTestcallsSqlTriviaReaderTestcallsSqlWordReaderTestcallsSqlIdentifierComponentTestcallsSqlKeywordSequenceTestcallsSqlLexerProfileTestcallsSqlTokenScannerTestcallsSqlTokenStreamTestcalls
Relations§
Instantiated in 1
Method calls 3
- method-call ZtdQuery\Sql\SqlLexerProfile::startsLineComment() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:87
- method-call ZtdQuery\Sql\SqlLexerProfile::blockCommentAt() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:100
- method-call ZtdQuery\Sql\SqlLexerProfile::supportsNestedBlockComments() packages/ztd-query-core/src/Sql/SqlLexerProfile.php:110