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

$lineCommentPrefixeslist<string>Prefixes that start a comment running to the end of the line
$whitespaceDelimitedLineCommentPrefixeslist<string>Prefixes that do so only when whitespace follows
$blockCommentPairsarray<string, string>Opening delimiter => the one that closes the comment
$nestedBlockCommentsboolWhether a block comment may contain another
$delimitersLexicalDelimitersRefuses lexical data a scanner could not use

Throws

InvalidDefinitionException When a delimiter is empty
Test cases 5
Calls 3
public function startsLineComment(string $sql, int $offset): bool

Reports whether a comment running to the end of the line starts here.

Parameters

$sqlstringStatement being scanned
$offsetintPosition to look at

Returns

bool True when one starts there
Test cases 2
Called from 1
Calls 3
public function blockCommentAt(
    string $sql,
    int $offset,
): array{non-empty-string, non-empty-string}|null

Answers the block comment delimiters starting here, if any.

Parameters

$sqlstringStatement being scanned
$offsetintPosition to look at

Returns

array{non-empty-string, non-empty-string}|null The opening and closing delimiters, or null when no comment starts there
Test cases 2
Called from 1
Calls 2
public function supportsNestedBlockComments(): bool

Reports whether a block comment may contain another.

Returns

bool True when the dialect nests them
Test cases 1
Called from 1

Private surface 4§

Implementation details, listed for orientation only.

private list<non-empty-string> $lineCommentPrefixes
private list<non-empty-string> $whitespaceDelimitedLineCommentPrefixes
private array<non-empty-string, non-empty-string> $blockCommentPairs
private bool $nestedBlockComments

Test cases 16§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 5
Other tests reaching this symbol 11

Relations§

Instantiated in 1
Method calls 3
Type declarations 1