final class CreateCast
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

A request to define a cast between two types.

Rule: PG-CAST-001. Mirrors CreateCastStmt: source and target type, the function (or binary coercion, or I/O conversion) and the CoercionContext; no context means the cast is explicit only. The types and the function are looked up when the cast is created, so the statement records no facts beyond the type names. Source: https://www.postgresql.org/docs/17/sql-createcast.html. Status: Implemented.

Reading a binary-coercible implicit castdoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE CAST (int4 AS myint) WITHOUT FUNCTION AS IMPLICIT');
    [$operation->statement->method, $operation->statement->context] // => [\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Cast\CastConversion::Binary, \SqlSemantics\Platform\PostgreSql\Statement\Catalog\Cast\CastContext::Implicit]

Properties§

public TypeName $source
public TypeName $target
public CastContext|null $context = null

Methods§

public function __construct(
    public TypeName $source,
    public TypeName $target,
    public ObjectReference|CastConversion $method,
    public CastContext|null $context = null,
)

Parameters

$sourceTypeNameThe source type
$targetTypeNameThe target type
$methodObjectReference|CastConversionThe function, or how the cast converts without one
$contextCastContext|nullWhere the cast applies unwritten; null for explicit casts only
public function deriveStatement(Derivation $derivation): void

Derives the type names and the function signature.

Parameters

$derivationDerivation
Calls 2
public function render(Output $out): void

Writes the request.

Parameters

$outOutput
Calls 2

Test cases 1§

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

Dedicated tests 1

Relations§

Instantiated in 3