* @return $this this database table
* @throws \InvalidArgumentException if any column is invalid or duplicate column names exist
*/
- public function columns(array $columns)
+ public function columns(array $columns): static
{
$this->columns = [];
foreach ($columns as $column) {
* @return $this this database table
* @throws \InvalidArgumentException if any foreign key is invalid or duplicate foreign key names exist
*/
- public function foreignKeys(array $foreignKeys)
+ public function foreignKeys(array $foreignKeys): static
{
$this->foreignKeys = [];
foreach ($foreignKeys as $foreignKey) {
* @return $this this database table
* @throws \InvalidArgumentException if any index is invalid or duplicate index key names exist
*/
- public function indices(array $indices)
+ public function indices(array $indices): static
{
$this->indices = [];
foreach ($indices as $index) {
*
* @return $this
*/
- public function drop()
+ public function drop(): static
{
$this->drop = true;
/**
* @inheritDoc
*/
- public function name(string $name)
+ public function name(string $name): static
{
if (isset($this->name)) {
throw new \BadMethodCallException("Name of the database table column has already been set.");
/**
* @inheritDoc
*/
- public function notNull(bool $notNull = true)
+ public function notNull(bool $notNull = true): static
{
$this->notNull = $notNull;
* @inheritDoc
* @since 5.4
*/
- public function renameTo(string $newName)
+ public function renameTo(string $newName): static
{
if ($newName === $this->getName()) {
throw new \InvalidArgumentException("'{$newName}' is the current name of the column.");
* @inheritDoc
* @return static
*/
- public static function create(string $name)
+ public static function create(string $name): static
{
return (new static())->name($name);
}
/**
* @inheritDoc
*/
- public static function createFromData(string $name, array $data)
+ public static function createFromData(string $name, array $data): static
{
$column = static::create($name)
->notNull($data['notNull']);
/**
* @inheritDoc
*/
- public static function createFromData(string $name, array $data)
+ public static function createFromData(string $name, array $data): static
{
$length = $data['length'] ?? null;
/**
* @inheritDoc
*/
- public function decimals(?int $decimals): self
+ public function decimals(?int $decimals): static
{
if ($this->getLength() === null) {
throw new \BadMethodCallException("Before setting the decimals, the length has to be set.");
*
* @return $this
*/
- public function autoIncrement(bool $autoIncrement = true);
+ public function autoIncrement(bool $autoIncrement = true): static;
/**
* Returns `true` if the values of the database table column are auto-increment.
*
* @return $this
*/
- public function drop();
+ public function drop(): static;
/**
* Returns the data used by `DatabaseEditor` to add the column to a table.
*
* @return $this
*/
- public function name(string $name);
+ public function name(string $name): static;
/**
* Sets if the values of the column cannot be `null`.
*
* @return $this
*/
- public function notNull(bool $notNull = true);
+ public function notNull(bool $notNull = true): static;
/**
* Sets the new name of the column and returns the column.
* @since 5.4
* @return $this
*/
- public function renameTo(string $newName);
+ public function renameTo(string $newName): static;
/**
* Returns `true` if the column will be dropped.
*
* @return $this
*/
- public static function create(string $name);
+ public static function create(string $name): static;
/**
* Returns a `DatabaseTableColumn` object with the given name and data.
* @param array $data data returned by `DatabaseEditor::getColumns()`
* @return $this
*/
- public static function createFromData(string $name, array $data);
+ public static function createFromData(string $name, array $data): static;
}
*
* @return $this
*/
- public function decimals(?int $decimals);
+ public function decimals(?int $decimals): static;
/**
* Returns the number of decimals the database table column supports or `null` if the number
* @param string[] $values
* @return $this
*/
- public function enumValues(array $values);
+ public function enumValues(array $values): static;
/**
* Returns the predetermined set of valid values for the database table column.
* @return $this this column
* @throws \InvalidArgumentException if given length is invalid
*/
- public function length(?int $length);
+ public function length(?int $length): static;
}
*
* @return $this
*/
- public function autoIncrement(bool $autoIncrement = true)
+ public function autoIncrement(bool $autoIncrement = true): static
{
$this->autoIncrement = $autoIncrement;
*
* @return $this
*/
- public function decimals(?int $decimals)
+ public function decimals(?int $decimals): static
{
if ($this->getMaximumDecimals() !== null && $decimals > $this->getMaximumDecimals()) {
throw new \InvalidArgumentException(
*
* @return $this
*/
- public function defaultValue(mixed $defaultValue)
+ public function defaultValue(mixed $defaultValue): static
{
$this->validateDefaultValue($defaultValue);
* @param string[] $values
* @return $this
*/
- public function enumValues(array $values)
+ public function enumValues(array $values): static
{
$this->enumValues = $values;
* @return $this this column
* @throws \InvalidArgumentException if given length is invalid
*/
- public function length(?int $length)
+ public function length(?int $length): static
{
if ($length !== null) {
$length = (int)$length;
* @param string[] $columns indexed columns
* @return $this
*/
- public function columns(array $columns): self
+ public function columns(array $columns): static
{
$this->columns = \array_values($columns);
*
* @return $this
*/
- public function generatedName(string $name): self
+ public function generatedName(string $name): static
{
$this->name($name);
$this->generatedName = true;
*
* @return $this
*/
- public function name(string $name): self
+ public function name(string $name): static
{
$this->name = $name;
*
* @throws \InvalidArgumentException if given type is invalid
*/
- public function type(?string $type): self
+ public function type(?string $type): static
{
if (
$type !== static::DEFAULT_TYPE
/**
* Returns a `DatabaseTableIndex` object with the given name.
*/
- public static function create(string $name): self
+ public static function create(string $name): static
{
- return new self($name);
+ return new static($name);
}
/**
*
* @param array $data data returned by `DatabaseEditor::getIndexInformation()`
*/
- public static function createFromData(string $name, array $data): self
+ public static function createFromData(string $name, array $data): static
{
return self::create($name)
->type($data['type'])