Skip to content

Internals Database Creator ColumnCreator

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

database\creator\ColumnCreator

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/database/creator/ColumnCreator.php · Snapshot 8411f4287706.

DatabaseManager delegates SQL generation to QueryBuilder, execution to IProvider, and result caching to ICache. Schema builders use MySQL DDL and the framework table registry.

Imports and dependencies

use database\creator\column\ColumnDefinition;
use database\creator\column\ColumnSQLBuilder;

ColumnCreator

Declaration and architectural role

class ColumnCreator

Source description (behavioral corrections are recorded in Known discrepancies):

ColumnCreator

Facade that exposes a fluent, readable API for defining database columns. Every static factory method returns a new instance pre-configured with the chosen SQL type. Modifier methods then chain onto that instance to add constraints, defaults, indexes, and foreign keys.

Internally, all state is accumulated into a ColumnDefinition value object and all SQL generation is delegated to ColumnSQLBuilder. ColumnCreator itself contains no SQL logic.

Usage:

ColumnCreator::INT('user_id', '11') ->unsigned() ->foreignKey('users', 'id', onDelete: 'CASCADE')

ColumnCreator::VARCHAR('slug', '255') ->unique() ->default('untitled')

ColumnCreator::DECIMAL('price', '10,2') ->unsigned() ->default('0.00')

ColumnCreator::ENUM('status', ['draft', 'published', 'archived']) ->default('draft')

Constants, enum cases, traits and properties

Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.

Member Declaration Purpose or source contract
$name private string $name = ''; Used by build(), getName(), make().
$type private string $type = ''; Used by build(), getType(), make().
$length private string $length = ''; Used by build(), make().
$nullable private bool $nullable = false; Used by nullable(), build().
$default private string $default = ''; Used by BOOLEAN(), default(), build().
$defaultAsDefined private bool $defaultAsDefined = false; Used by default(), build().
$autoIncrement private bool $autoIncrement = false; Used by autoIncrement(), build().
$unsigned private bool $unsigned = false; Used by unsigned(), build().
$index private string $index = ''; Used by primary(), unique(), index(), build().
$comment private string $comment = ''; Used by comment(), build().
$after private string $after = ''; Used by after(), build().
$enumValues private array $enumValues = []; Used by ENUM(), SET(), build().
$fkTable private ?string $fkTable = null; Used by foreignKey(), build().
$fkColumn private ?string $fkColumn = null; Used by foreignKey(), build().
$onDelete private ?string $onDelete = null; Used by foreignKey(), build().
$onUpdate private ?string $onUpdate = null; Used by foreignKey(), build().
$sqlBuilder private ColumnSQLBuilder $sqlBuilder; Used by __construct(), generateColumnSQL(), generateForeignKeySQL().

Method index

Method Signature
__construct private function __construct()
INT public static function INT(string $name, string $length = '11'): self
TINYINT public static function TINYINT(string $name, string $length = '1'): self
SMALLINT public static function SMALLINT(string $name, string $length = '5'): self
BIGINT public static function BIGINT(string $name, string $length = '20'): self
BOOLEAN public static function BOOLEAN(string $name): self
FLOAT public static function FLOAT(string $name): self
DOUBLE public static function DOUBLE(string $name): self
DECIMAL public static function DECIMAL(string $name, string $precisionScale = '10,2'): self
VARCHAR public static function VARCHAR(string $name, string $length): self
CHAR public static function CHAR(string $name, string $length): self
TEXT public static function TEXT(string $name): self
MEDIUMTEXT public static function MEDIUMTEXT(string $name): self
LONGTEXT public static function LONGTEXT(string $name): self
DATE public static function DATE(string $name): self
DATETIME public static function DATETIME(string $name): self
TIMESTAMP public static function TIMESTAMP(string $name): self
ENUM public static function ENUM(string $name, array $values): self
SET public static function SET(string $name, array $values): self
BLOB public static function BLOB(string $name): self
JSON public static function JSON(string $name): self
default public function default(string $value, bool $asDefined = false): self
autoIncrement public function autoIncrement(): self
nullable public function nullable(): self
unsigned public function unsigned(): self
primary public function primary(): self
unique public function unique(): self
index public function index(): self
comment public function comment(string $text): self
after public function after(string $columnName): self
foreignKey public function foreignKey( string $referenceTable, string $referenceColumn, ?string $onDelete = null, ?string $onUpdate = null, ): self
build public function build(): ColumnDefinition
generateColumnSQL public function generateColumnSQL(): string
generateForeignKeySQL public function generateForeignKeySQL(): ?string
getName public function getName(): string
getType public function getType(): string
make private static function make(string $name, string $type, string $length = ''): self

__construct

Source line 61

private function __construct()

State writes: $this->sqlBuilder.

Implementation, validation guards and interaction order
private function __construct()
    {
        $this->sqlBuilder = new ColumnSQLBuilder();
    }

INT

Source line 71

public static function INT(string $name, string $length = '11'): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$length string $length = '11' Operation input; the exact use, validation and propagation are shown in the implementation trace.

Standard signed/unsigned integer. Pass length as a string, e.g. "11".

Return expressions (including local callbacks): self::make($name, 'INT', $length).

Implementation, validation guards and interaction order
// =========================================================================
    // Static factory methods — one per supported SQL type
    // =========================================================================

    /** Standard signed/unsigned integer. Pass length as a string, e.g. "11". */
    public static function INT(string $name, string $length = '11'): self
    {
        return self::make($name, 'INT', $length);
    }

TINYINT

Source line 77

public static function TINYINT(string $name, string $length = '1'): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$length string $length = '1' Operation input; the exact use, validation and propagation are shown in the implementation trace.

1-byte integer. Commonly used for boolean flags as TINYINT(1).

Return expressions (including local callbacks): self::make($name, 'TINYINT', $length).

Implementation, validation guards and interaction order
/** 1-byte integer. Commonly used for boolean flags as TINYINT(1). */
    public static function TINYINT(string $name, string $length = '1'): self
    {
        return self::make($name, 'TINYINT', $length);
    }

SMALLINT

Source line 83

public static function SMALLINT(string $name, string $length = '5'): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$length string $length = '5' Operation input; the exact use, validation and propagation are shown in the implementation trace.

2-byte integer.

Return expressions (including local callbacks): self::make($name, 'SMALLINT', $length).

Implementation, validation guards and interaction order
/** 2-byte integer. */
    public static function SMALLINT(string $name, string $length = '5'): self
    {
        return self::make($name, 'SMALLINT', $length);
    }

BIGINT

Source line 89

public static function BIGINT(string $name, string $length = '20'): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$length string $length = '20' Operation input; the exact use, validation and propagation are shown in the implementation trace.

8-byte integer. Use for IDs on large tables.

Return expressions (including local callbacks): self::make($name, 'BIGINT', $length).

Implementation, validation guards and interaction order
/** 8-byte integer. Use for IDs on large tables. */
    public static function BIGINT(string $name, string $length = '20'): self
    {
        return self::make($name, 'BIGINT', $length);
    }

BOOLEAN

Source line 98

public static function BOOLEAN(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Boolean column stored as TINYINT(1). Defaults to 0 (false) unless overridden with ->default('1').

Return expressions (including local callbacks): self::make($name, 'TINYINT', '1')->default('0').

Implementation, validation guards and interaction order
/**
     * Boolean column stored as TINYINT(1).
     * Defaults to 0 (false) unless overridden with ->default('1').
     */
    public static function BOOLEAN(string $name): self
    {
        return self::make($name, 'TINYINT', '1')->default('0');
    }

FLOAT

Source line 104

public static function FLOAT(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Single-precision floating point.

Return expressions (including local callbacks): self::make($name, 'FLOAT').

Implementation, validation guards and interaction order
/** Single-precision floating point. */
    public static function FLOAT(string $name): self
    {
        return self::make($name, 'FLOAT');
    }

DOUBLE

Source line 110

public static function DOUBLE(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Double-precision floating point.

Return expressions (including local callbacks): self::make($name, 'DOUBLE').

Implementation, validation guards and interaction order
/** Double-precision floating point. */
    public static function DOUBLE(string $name): self
    {
        return self::make($name, 'DOUBLE');
    }

DECIMAL

Source line 119

public static function DECIMAL(string $name, string $precisionScale = '10,2'): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$precisionScale string $precisionScale = '10,2' Operation input; the exact use, validation and propagation are shown in the implementation trace.

Fixed-precision decimal. Pass precision and scale as "precision,scale", e.g. "10,2" for a number up to 99999999.99.

Return expressions (including local callbacks): self::make($name, 'DECIMAL', $precisionScale).

Implementation, validation guards and interaction order
/**
     * Fixed-precision decimal. Pass precision and scale as "precision,scale",
     * e.g. "10,2" for a number up to 99999999.99.
     */
    public static function DECIMAL(string $name, string $precisionScale = '10,2'): self
    {
        return self::make($name, 'DECIMAL', $precisionScale);
    }

VARCHAR

Source line 125

public static function VARCHAR(string $name, string $length): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$length string $length Operation input; the exact use, validation and propagation are shown in the implementation trace.

Variable-length string up to 65,535 bytes. Length is required.

Return expressions (including local callbacks): self::make($name, 'VARCHAR', $length).

Implementation, validation guards and interaction order
/** Variable-length string up to 65,535 bytes. Length is required. */
    public static function VARCHAR(string $name, string $length): self
    {
        return self::make($name, 'VARCHAR', $length);
    }

CHAR

Source line 131

public static function CHAR(string $name, string $length): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$length string $length Operation input; the exact use, validation and propagation are shown in the implementation trace.

Fixed-length string. Pads shorter values with spaces.

Return expressions (including local callbacks): self::make($name, 'CHAR', $length).

Implementation, validation guards and interaction order
/** Fixed-length string. Pads shorter values with spaces. */
    public static function CHAR(string $name, string $length): self
    {
        return self::make($name, 'CHAR', $length);
    }

TEXT

Source line 137

public static function TEXT(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Up to 65,535 characters of text.

Return expressions (including local callbacks): self::make($name, 'TEXT').

Implementation, validation guards and interaction order
/** Up to 65,535 characters of text. */
    public static function TEXT(string $name): self
    {
        return self::make($name, 'TEXT');
    }

MEDIUMTEXT

Source line 143

public static function MEDIUMTEXT(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Up to 16,777,215 characters of text.

Return expressions (including local callbacks): self::make($name, 'MEDIUMTEXT').

Implementation, validation guards and interaction order
/** Up to 16,777,215 characters of text. */
    public static function MEDIUMTEXT(string $name): self
    {
        return self::make($name, 'MEDIUMTEXT');
    }

LONGTEXT

Source line 149

public static function LONGTEXT(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Up to 4,294,967,295 characters of text.

Return expressions (including local callbacks): self::make($name, 'LONGTEXT').

Implementation, validation guards and interaction order
/** Up to 4,294,967,295 characters of text. */
    public static function LONGTEXT(string $name): self
    {
        return self::make($name, 'LONGTEXT');
    }

DATE

Source line 158

public static function DATE(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

DATE stores year, month, and day (no time component). Use DATETIME() or TIMESTAMP() when time is needed.

Return expressions (including local callbacks): self::make($name, 'DATE').

Implementation, validation guards and interaction order
/**
     * DATE stores year, month, and day (no time component).
     * Use DATETIME() or TIMESTAMP() when time is needed.
     */
    public static function DATE(string $name): self
    {
        return self::make($name, 'DATE');
    }

DATETIME

Source line 164

public static function DATETIME(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Date and time stored in the database timezone. Range: 1000-01-01 to 9999-12-31.

Return expressions (including local callbacks): self::make($name, 'DATETIME').

Implementation, validation guards and interaction order
/** Date and time stored in the database timezone. Range: 1000-01-01 to 9999-12-31. */
    public static function DATETIME(string $name): self
    {
        return self::make($name, 'DATETIME');
    }

TIMESTAMP

Source line 173

public static function TIMESTAMP(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Date and time stored as UTC, displayed in the connection timezone. Range: 1970-01-01 to 2038-01-19.

Return expressions (including local callbacks): self::make($name, 'TIMESTAMP').

Implementation, validation guards and interaction order
/**
     * Date and time stored as UTC, displayed in the connection timezone.
     * Range: 1970-01-01 to 2038-01-19.
     */
    public static function TIMESTAMP(string $name): self
    {
        return self::make($name, 'TIMESTAMP');
    }

ENUM

Source line 184

public static function ENUM(string $name, array $values): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Column name.
$values array $values Allowed values.

Enforces that the column value is one of the provided strings.

@param string $name Column name. @param string[] $values Allowed values.

Return expressions (including local callbacks): $instance.

Implementation, validation guards and interaction order
/**
     * Enforces that the column value is one of the provided strings.
     *
     * @param string   $name   Column name.
     * @param string[] $values Allowed values.
     */
    public static function ENUM(string $name, array $values): self
    {
        $instance             = self::make($name, 'ENUM');
        $instance->enumValues = $values;
        return $instance;
    }

SET

Source line 198

public static function SET(string $name, array $values): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Column name.
$values array $values Allowed values.

Allows storing zero or more values from the provided set, as a comma-separated string.

@param string $name Column name. @param string[] $values Allowed values.

Return expressions (including local callbacks): $instance.

Implementation, validation guards and interaction order
/**
     * Allows storing zero or more values from the provided set, as a
     * comma-separated string.
     *
     * @param string   $name   Column name.
     * @param string[] $values Allowed values.
     */
    public static function SET(string $name, array $values): self
    {
        $instance             = self::make($name, 'SET');
        $instance->enumValues = $values;
        return $instance;
    }

BLOB

Source line 206

public static function BLOB(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

Binary large object, up to 65,535 bytes.

Return expressions (including local callbacks): self::make($name, 'BLOB').

Implementation, validation guards and interaction order
/** Binary large object, up to 65,535 bytes. */
    public static function BLOB(string $name): self
    {
        return self::make($name, 'BLOB');
    }

JSON

Source line 215

public static function JSON(string $name): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.

JSON column with native validation and path-expression support (MySQL 5.7.8+ / MariaDB 10.2+).

Return expressions (including local callbacks): self::make($name, 'JSON').

Implementation, validation guards and interaction order
/**
     * JSON column with native validation and path-expression support
     * (MySQL 5.7.8+ / MariaDB 10.2+).
     */
    public static function JSON(string $name): self
    {
        return self::make($name, 'JSON');
    }

default

Source line 232

public function default(string $value, bool $asDefined = false): self

Parameters

Parameter Type, modifiers and default Purpose
$value string $value The default value or expression.
$asDefined bool $asDefined = false When true, the value is emitted verbatim without

Set a DEFAULT value for the column.

@param string $value The default value or expression. @param bool $asDefined When true, the value is emitted verbatim without quoting. Use for SQL expressions such as NOW() or custom raw expressions not in the built-in list.

State writes: $this->default, $this->defaultAsDefined.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
// =========================================================================
    // Modifier methods
    // =========================================================================

    /**
     * Set a DEFAULT value for the column.
     *
     * @param string $value      The default value or expression.
     * @param bool   $asDefined  When true, the value is emitted verbatim without
     *                           quoting. Use for SQL expressions such as NOW() or
     *                           custom raw expressions not in the built-in list.
     */
    public function default(string $value, bool $asDefined = false): self
    {
        $this->default          = $value;
        $this->defaultAsDefined = $asDefined;
        return $this;
    }

autoIncrement

Source line 240

public function autoIncrement(): self

Mark the column AUTO_INCREMENT. Only valid on integer primary keys.

State writes: $this->autoIncrement.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/** Mark the column AUTO_INCREMENT. Only valid on integer primary keys. */
    public function autoIncrement(): self
    {
        $this->autoIncrement = true;
        return $this;
    }

nullable

Source line 247

public function nullable(): self

Allow NULL values. Omitting this makes the column NOT NULL.

State writes: $this->nullable.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/** Allow NULL values. Omitting this makes the column NOT NULL. */
    public function nullable(): self
    {
        $this->nullable = true;
        return $this;
    }

unsigned

Source line 257

public function unsigned(): self

Add UNSIGNED to the column definition. Silently ignored for non-numeric types.

State writes: $this->unsigned.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/**
     * Add UNSIGNED to the column definition.
     * Silently ignored for non-numeric types.
     */
    public function unsigned(): self
    {
        $this->unsigned = true;
        return $this;
    }

primary

Source line 264

public function primary(): self

Mark this column as the PRIMARY KEY.

State writes: $this->index.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/** Mark this column as the PRIMARY KEY. */
    public function primary(): self
    {
        $this->index = 'PRIMARY';
        return $this;
    }

unique

Source line 271

public function unique(): self

Add a UNIQUE constraint to the column.

State writes: $this->index.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/** Add a UNIQUE constraint to the column. */
    public function unique(): self
    {
        $this->index = 'UNIQUE';
        return $this;
    }

index

Source line 282

public function index(): self

Create a regular (non-unique) index on this column. The index is emitted as a separate CREATE INDEX statement by TableWizard rather than being inlined into the column definition.

State writes: $this->index.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/**
     * Create a regular (non-unique) index on this column.
     * The index is emitted as a separate CREATE INDEX statement by TableWizard
     * rather than being inlined into the column definition.
     */
    public function index(): self
    {
        $this->index = 'INDEX';
        return $this;
    }

comment

Source line 293

public function comment(string $text): self

Parameters

Parameter Type, modifiers and default Purpose
$text string $text The comment text.

Add a human-readable COMMENT to the column, stored in information_schema.

@param string $text The comment text.

State writes: $this->comment.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/**
     * Add a human-readable COMMENT to the column, stored in information_schema.
     *
     * @param string $text The comment text.
     */
    public function comment(string $text): self
    {
        $this->comment = $text;
        return $this;
    }

after

Source line 306

public function after(string $columnName): self

Parameters

Parameter Type, modifiers and default Purpose
$columnName string $columnName The column this one should follow.

Position this column immediately after another in ALTER TABLE ADD COLUMN statements. Has no effect inside CREATE TABLE (column order is determined by the order columns are added to TableWizard).

@param string $columnName The column this one should follow.

State writes: $this->after.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/**
     * Position this column immediately after another in ALTER TABLE ADD COLUMN
     * statements. Has no effect inside CREATE TABLE (column order is determined
     * by the order columns are added to TableWizard).
     *
     * @param string $columnName The column this one should follow.
     */
    public function after(string $columnName): self
    {
        $this->after = $columnName;
        return $this;
    }

foreignKey

Source line 320

public function foreignKey(
        string  $referenceTable,
        string  $referenceColumn,
        ?string $onDelete = null,
        ?string $onUpdate = null,
    ): self

Parameters

Parameter Type, modifiers and default Purpose
$referenceTable string $referenceTable The table being referenced.
$referenceColumn string $referenceColumn The column in the referenced table.
$onDelete ?string $onDelete = null ON DELETE action: CASCADE, SET NULL, RESTRICT, NO ACTION.
$onUpdate ?string $onUpdate = null ON UPDATE action: CASCADE, SET NULL, RESTRICT, NO ACTION.

Define a FOREIGN KEY constraint on this column.

@param string $referenceTable The table being referenced. @param string $referenceColumn The column in the referenced table. @param string|null $onDelete ON DELETE action: CASCADE, SET NULL, RESTRICT, NO ACTION. @param string|null $onUpdate ON UPDATE action: CASCADE, SET NULL, RESTRICT, NO ACTION.

State writes: $this->fkTable, $this->fkColumn, $this->onDelete, $this->onUpdate.

Return expressions (including local callbacks): $this.

Implementation, validation guards and interaction order
/**
     * Define a FOREIGN KEY constraint on this column.
     *
     * @param string      $referenceTable  The table being referenced.
     * @param string      $referenceColumn The column in the referenced table.
     * @param string|null $onDelete        ON DELETE action: CASCADE, SET NULL, RESTRICT, NO ACTION.
     * @param string|null $onUpdate        ON UPDATE action: CASCADE, SET NULL, RESTRICT, NO ACTION.
     */
    public function foreignKey(
        string  $referenceTable,
        string  $referenceColumn,
        ?string $onDelete = null,
        ?string $onUpdate = null,
    ): self {
        $this->fkTable  = $referenceTable;
        $this->fkColumn = $referenceColumn;
        $this->onDelete = $onDelete;
        $this->onUpdate = $onUpdate;
        return $this;
    }

build

Source line 341

public function build(): ColumnDefinition

Seal the accumulated state into an immutable ColumnDefinition. Called internally by TableWizard; rarely needed in application code.

Return expressions (including local callbacks): new ColumnDefinition( name: $this->name, type: $this->type, length: $this->length, nullable: $this->nullable, default: $this->default, defaultAsDefined: $this->defaultAsDefined, autoIncrement: $this->autoIncrement, unsigned: $this->unsigned, index: $this->index, comment: $this->comment, after: $this->after, enumValues: $this->enumValues, foreignKeyTable: $this->fkTable, foreignKeyColumn: $this->fkColumn, onDelete: $this->onDelete, onUpdate: $this->onUpdate, ).

Implementation, validation guards and interaction order
// =========================================================================
    // Build and SQL generation
    // =========================================================================

    /**
     * Seal the accumulated state into an immutable ColumnDefinition.
     * Called internally by TableWizard; rarely needed in application code.
     */
    public function build(): ColumnDefinition
    {
        return new ColumnDefinition(
            name:             $this->name,
            type:             $this->type,
            length:           $this->length,
            nullable:         $this->nullable,
            default:          $this->default,
            defaultAsDefined: $this->defaultAsDefined,
            autoIncrement:    $this->autoIncrement,
            unsigned:         $this->unsigned,
            index:            $this->index,
            comment:          $this->comment,
            after:            $this->after,
            enumValues:       $this->enumValues,
            foreignKeyTable:  $this->fkTable,
            foreignKeyColumn: $this->fkColumn,
            onDelete:         $this->onDelete,
            onUpdate:         $this->onUpdate,
        );
    }

generateColumnSQL

Source line 367

public function generateColumnSQL(): string

Generate the column definition SQL fragment. Delegates to ColumnSQLBuilder; no SQL logic lives here.

Return expressions (including local callbacks): $this->sqlBuilder->buildColumnSQL($this->build()).

Implementation, validation guards and interaction order
/**
     * Generate the column definition SQL fragment.
     * Delegates to ColumnSQLBuilder; no SQL logic lives here.
     */
    public function generateColumnSQL(): string
    {
        return $this->sqlBuilder->buildColumnSQL($this->build());
    }

generateForeignKeySQL

Source line 376

public function generateForeignKeySQL(): ?string

Generate the FOREIGN KEY constraint clause, or null when no foreign key is defined. Delegates to ColumnSQLBuilder.

Return expressions (including local callbacks): $this->sqlBuilder->buildForeignKeySQL($this->build()).

Implementation, validation guards and interaction order
/**
     * Generate the FOREIGN KEY constraint clause, or null when no foreign key
     * is defined. Delegates to ColumnSQLBuilder.
     */
    public function generateForeignKeySQL(): ?string
    {
        return $this->sqlBuilder->buildForeignKeySQL($this->build());
    }

getName

Source line 385

public function getName(): string

Return the column name. Used by TableWizard for registry lookups and duplicate detection without needing to build the full definition.

Return expressions (including local callbacks): $this->name.

Implementation, validation guards and interaction order
/**
     * Return the column name. Used by TableWizard for registry lookups and
     * duplicate detection without needing to build the full definition.
     */
    public function getName(): string
    {
        return $this->name;
    }

getType

Source line 394

public function getType(): string

Return the SQL type keyword. Used by TableWizard when recording the column in the schema registry.

Return expressions (including local callbacks): $this->type.

Implementation, validation guards and interaction order
/**
     * Return the SQL type keyword. Used by TableWizard when recording the column
     * in the schema registry.
     */
    public function getType(): string
    {
        return $this->type;
    }

make

Source line 404

private static function make(string $name, string $type, string $length = ''): self

Parameters

Parameter Type, modifiers and default Purpose
$name string $name Named key/label selected by this API; its exact scope is shown by the implementation trace.
$type string $type Expected class/type or enum selection according to the signature.
$length string $length = '' Operation input; the exact use, validation and propagation are shown in the implementation trace.

Centralised instance factory used by all static type methods.

Return expressions (including local callbacks): $instance.

Implementation, validation guards and interaction order
// =========================================================================
    // Private helpers
    // =========================================================================

    /** Centralised instance factory used by all static type methods. */
    private static function make(string $name, string $type, string $length = ''): self
    {
        $instance         = new self();
        $instance->name   = $name;
        $instance->type   = $type;
        $instance->length = $length;
        return $instance;
    }

Related types

Clone this wiki locally