final class Unary
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A prefix operation over one operand.

Rule: SQLITE-UNARY-001. The facts follow SQLITE-OPERATOR-RESULT-001; the operand is a single value (SQLITE-ROW-VALUE-USE-001). The operand must keep its place without parentheses (SQLITE-PRECEDENCE-001): it may not start with an operator weaker than the prefix operator. Source: https://sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes. Status: Implemented.

Reading the operand of a negationdoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT -a FROM t');
    $query->statement->columns[0]->expression->operand->name->value // => 'a'
Refusing an operand that the prefix operator would not cover when writtendoctest
$sum = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 + 2')->statement->columns[0]->expression;
    new \SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary(\SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\UnaryOperator::Minus, $sum) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public UnaryOperator $operator
public Scalar $operand

Methods§

public function __construct(public UnaryOperator $operator, public Scalar $operand)

Parameters

$operatorUnaryOperatorThe operator
$operandScalarThe operand
Calls 6
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operand and the result of the operator.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 5
public function render(Output $out): void

Writes the operator before the operand.

Parameters

$outOutput
Calls 4

Test cases 12§

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 9

Relations§

Instantiated in 2
Type checks 6