final class Comments
    uses Assertion
Public API: explicitly declared with @visibility public.

The comments written before the symbols of one SQL value, by symbol position.

A position counts the symbols of a value's SQL form from zero, fixed words and fields alike, so a comment stays with the symbol it was written before when other fields are replaced. Every comment keeps its delimiters, and a line comment ends before its line break. When the lexer reads the body of an executable comment as SQL, its opening and closing delimiters are kept as separate comments around the values they enclose.

Placing a comment before the second symbol of a valuedoctest
$comments = new \SqlSemantics\Statement\Comments([1 => ['-- audited']]);
    $comments->before(1) // => ['-- audited']
Adding a comment to an existing positiondoctest
(new \SqlSemantics\Statement\Comments())->with(0, '-- first', '-- second')->before(0) // => ['-- first', '-- second']

Methods§

public function __construct(private array<int, list<string>> $texts = [])

Supplies the comments by the position of the symbol each precedes.

Parameters

$textsarray<int, list<string>>Comments in writing order, by symbol position
Calls 3
public function positions(): list<int>

Lists the symbol positions that have comments, in ascending order.

Returns

list<int>
Test cases 2
Called from 1
Calls 2
public function with(int $position, string ...$comments): self

Returns a copy with more comments written before the symbol at a position.

Parameters

$positionint
$commentsstring

Returns

self
Test cases 1
Calls 3

Private surface 2§

Implementation details, listed for orientation only.

private const COMMENT = '~\A(?:/\*.*|\*/|--[^\r\n]*|#[^\r\n]*)\z~sD'
private array<int, list<string>> $texts = []

Test cases 7§

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

Dedicated tests 3
Other tests reaching this symbol 4

Relations§

Instantiated in 6394
Method calls 2
Type checks 1
Type declarations 12784