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

A complete SQL command whose values are independent of parsing.

Fixed syntax is defined by the concrete value classes. Arguments are named fields, finite options are enums, and forwarding grammar rules are removed. No source string, parser node, token, or construction map is retained. Comments written before the command or after it belong to the statement, so they survive when the command is replaced.

Reconstructing a statement from its valuesdoctest
$statement = (new \SqlSemantics\Facade\Semantics(\SqlSemantics\Platform\Sqlite\Dialect::Sqlite))->analyze('SELECT 1');
    str_contains($statement->toString(), 'SELECT') // => true
Keeping a trailing comment while replacing the commanddoctest
$statement = (new \SqlSemantics\Facade\Semantics(\SqlSemantics\Platform\Sqlite\Dialect::Sqlite))->analyze('SELECT 1 -- audited');
    $statement->withCommand($statement->command)->toString() // => "SELECT 1 -- audited"

Constants§

public const BEFORE = 0

The comment position before the command.

public const AFTER = 1

The comment position after the command.

Properties§

public Command $command
public Comments $comments = new \SqlSemantics\Statement\Comments()

Methods§

public function __construct(
    public Command $command,
    public Comments $comments = new \SqlSemantics\Statement\Comments(),
)

Supplies the complete command value and the comments written around it.

Parameters

$commandCommand
$commentsCommentsComments at position BEFORE precede the command; those at AFTER follow it
Calls 7
public function withCommand(Command $command): self

Returns a statement containing the replacement command, preserving this statement.

Parameters

$commandCommand

Returns

self
Test cases 2
Calls 1
public function withComments(Comments $comments): self

Returns a statement with other comments around the same command.

Parameters

$commentsComments

Returns

self
Test cases 1
Calls 1

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
Constant reads 2
Type declarations 3