Skip to content

Commit

Permalink
Fix phpdoc, order class, remove duplicate method. (#423)
Browse files Browse the repository at this point in the history
* Fix phpdoc, order class, remove duplicate method.
  • Loading branch information
terabytesoftw committed Dec 20, 2022
1 parent add6a27 commit adea7ac
Show file tree
Hide file tree
Showing 3 changed files with 388 additions and 144 deletions.
160 changes: 78 additions & 82 deletions src/Schema/ColumnSchema.php
Expand Up @@ -11,26 +11,46 @@

class ColumnSchema implements ColumnSchemaInterface
{
private string $name = '';
private bool $allowNull = false;
private string $type = '';
private string|null $phpType = null;
private bool $autoIncrement = false;
private string|null $comment = null;
private bool $computed = false;
private string $dbType = '';
private mixed $defaultValue = null;
private array|null $enumValues = null;
private int|null $size = null;
private string|null $extra = null;
private bool $isPrimaryKey = false;
private string $name = '';
private string|null $phpType = null;
private int|null $precision = null;
private int|null $scale = null;
private bool $isPrimaryKey = false;
private bool $autoIncrement = false;
private bool $computed = false;
private int|null $size = null;
private string $type = '';
private bool $unsigned = false;
private string|null $comment = null;
private string|null $extra = null;

public function phpTypecast(mixed $value): mixed
public function allowNull(bool $value): void
{
return $this->typecast($value);
$this->allowNull = $value;
}

public function autoIncrement(bool $value): void
{
$this->autoIncrement = $value;
}

public function comment(string|null $value): void
{
$this->comment = $value;
}

public function computed(bool $value): void
{
$this->computed = $value;
}

public function dbType(string $value): void
{
$this->dbType = $value;
}

public function dbTypecast(mixed $value): mixed
Expand All @@ -42,29 +62,24 @@ public function dbTypecast(mixed $value): mixed
return $this->typecast($value);
}

public function setType(string $value): void
{
$this->type = $value;
}

public function getName(): string
public function defaultValue(mixed $value): void
{
return $this->name;
$this->defaultValue = $value;
}

public function isAllowNull(): bool
public function enumValues(array|null $value): void
{
return $this->allowNull;
$this->enumValues = $value;
}

public function getType(): string
public function extra(string|null $value): void
{
return $this->type;
$this->extra = $value;
}

public function getPhpType(): string|null
public function getComment(): string|null
{
return $this->phpType;
return $this->comment;
}

public function getDbType(): string
Expand All @@ -82,129 +97,109 @@ public function getEnumValues(): array|null
return $this->enumValues;
}

public function getSize(): int|null
public function getExtra(): string|null
{
return $this->size;
return $this->extra;
}

public function getName(): string
{
return $this->name;
}

public function getPrecision(): int|null
{
return $this->precision;
}

public function getScale(): int|null
public function getPhpType(): string|null
{
return $this->scale;
return $this->phpType;
}

public function isPrimaryKey(): bool
public function getScale(): int|null
{
return $this->isPrimaryKey;
return $this->scale;
}

public function isAutoIncrement(): bool
public function getSize(): int|null
{
return $this->autoIncrement;
return $this->size;
}

public function isComputed(): bool
public function getType(): string
{
return $this->computed;
return $this->type;
}

public function isUnsigned(): bool
public function isAllowNull(): bool
{
return $this->unsigned;
return $this->allowNull;
}

public function getComment(): string|null
public function isAutoIncrement(): bool
{
return $this->comment;
return $this->autoIncrement;
}

public function getExtra(): string|null
public function isComputed(): bool
{
return $this->extra;
return $this->computed;
}

public function name(string $value): void
public function isPrimaryKey(): bool
{
$this->name = $value;
return $this->isPrimaryKey;
}

public function allowNull(bool $value): void
public function isUnsigned(): bool
{
$this->allowNull = $value;
return $this->unsigned;
}

public function type(string $value): void
public function name(string $value): void
{
$this->type = $value;
$this->name = $value;
}

public function phpType(string|null $value): void
{
$this->phpType = $value;
}

public function dbType(string $value): void
{
$this->dbType = $value;
}

public function defaultValue(mixed $value): void
{
$this->defaultValue = $value;
}

public function enumValues(array|null $value): void
{
$this->enumValues = $value;
}

public function size(int|null $value): void
public function phpTypecast(mixed $value): mixed
{
$this->size = $value;
return $this->typecast($value);
}

public function precision(int|null $value): void
{
$this->precision = $value;
}

public function scale(int|null $value): void
{
$this->scale = $value;
}

public function primaryKey(bool $value): void
{
$this->isPrimaryKey = $value;
}

public function autoIncrement(bool $value): void
{
$this->autoIncrement = $value;
}

public function computed(bool $value): void
public function scale(int|null $value): void
{
$this->computed = $value;
$this->scale = $value;
}

public function unsigned(bool $value): void
public function size(int|null $value): void
{
$this->unsigned = $value;
$this->size = $value;
}

public function comment(string|null $value): void
public function type(string $value): void
{
$this->comment = $value;
$this->type = $value;
}

public function extra(string|null $value): void
public function unsigned(bool $value): void
{
$this->extra = $value;
$this->unsigned = $value;
}

/**
Expand Down Expand Up @@ -273,7 +268,8 @@ protected function typecast(mixed $value): mixed
case Schema::PHP_TYPE_BOOLEAN:
/**
* treating a 0 bit value as false too
* https://github.com/yiisoft/yii2/issues/9006
*
* @link https://github.com/yiisoft/yii2/issues/9006
*/
return (bool) $value && $value !== "\0";
case Schema::PHP_TYPE_DOUBLE:
Expand Down

0 comments on commit adea7ac

Please sign in to comment.