Skip to content

Commit

Permalink
chore: namings and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailProcudin committed Mar 16, 2022
1 parent 904ea50 commit b813864
Showing 1 changed file with 46 additions and 51 deletions.
97 changes: 46 additions & 51 deletions src/Database/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@
class Blueprint extends \Illuminate\Database\Schema\Blueprint
{
/** @var string */
protected $alias;
protected string $alias;

/** @var string */
protected $document;
protected string $document;

/** @var array */
protected $meta = [];
protected array $meta = [];

/** @var array */
protected $indexSettings = [];
protected array $indexSettings = [];

/**
* Add a new column to the blueprint.
*
* @param string $type
* @param string $name
* @param array $parameters
* @return \Illuminate\Database\Schema\ColumnDefinition
* @return PropertyDefinition
*/
public function addColumn(string $type, string $name, array $parameters = [])
{
return $this->addColumnDefinition(new ColumnDefinition(
return $this->addColumnDefinition(new PropertyDefinition(
array_merge(compact('type', 'name'), $parameters)
));
}

/**
* Add a new column definition to the blueprint.
*
* @param \Illuminate\Database\Schema\ColumnDefinition $definition
* @return \Illuminate\Database\Schema\ColumnDefinition
* @param PropertyDefinition $definition
* @return PropertyDefinition
*/
protected function addColumnDefinition($definition)
protected function addColumnDefinition(PropertyDefinition $definition): PropertyDefinition
{
$this->columns[] = $definition;

Expand Down Expand Up @@ -91,7 +91,7 @@ public function alias(string $alias): void
* Create a new binary column on the table.
*
* @param string $column
* @return \Illuminate\Database\Schema\ColumnDefinition
* @return PropertyDefinition
*/
public function binary(string $column): PropertyDefinition
{
Expand All @@ -115,20 +115,18 @@ public function build(Connection $connection, Grammar $grammar)

/**
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function date(string $column, array $parameters = []): PropertyDefinition
public function date(string $column): PropertyDefinition
{
return $this->addColumn('date', $column, $parameters);
return $this->addColumn('date', $column);
}

/**
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function dateRange(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -144,10 +142,10 @@ public function document(string $name): void
}

/**
* @param string $name
* @param array $parameters
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function doubleRange(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -157,7 +155,7 @@ public function doubleRange(string $column, array $parameters = []): PropertyDef
/**
* @param bool|string $value
*/
public function dynamic($value): void
public function dynamic(bool|string $value): void
{
$this->addMetaField('dynamic', $value);
}
Expand All @@ -183,9 +181,9 @@ public function enableFieldNames(): void
* @param int $total
* @param int $places
* @param bool $unsigned
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function float($column, $total = 8, $places = 2, $unsigned = false): PropertyDefinition
public function float(string $column, int $total = 8, int $places = 2, bool $unsigned = false): PropertyDefinition
{
return $this->addColumn('float', $column);
}
Expand All @@ -194,7 +192,7 @@ public function float($column, $total = 8, $places = 2, $unsigned = false): Prop
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function floatRange(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -205,7 +203,7 @@ public function floatRange(string $column, array $parameters = []): PropertyDefi
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function geoPoint(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -216,7 +214,7 @@ public function geoPoint(string $column, array $parameters = []): PropertyDefini
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function geoShape(string $column, array $parameters = []): PropertyDefinition
{
Expand Down Expand Up @@ -270,27 +268,27 @@ public function getMeta(): array
* @param string column
* @param bool $autoIncrement
* @param bool $unsigned
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function integer(string $column, $autoIncrement = false, $unsigned = false): PropertyDefinition
{
return $this->addColumn('integer', $column);
}

/**
* @param string $name
* @param array $parameters
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function integerRange(string $column, array $parameters = []): PropertyDefinition
{
return $this->range('integer_range', $column, $parameters);
}

/**
* @param string $name
* @return ColumnDefinition
* @param string $column
* @return PropertyDefinition
*/
public function ip(string $column): PropertyDefinition
{
Expand All @@ -299,7 +297,7 @@ public function ip(string $column): PropertyDefinition

/**
* @param string $column
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function ipAddress(string $column = 'ip_address'): PropertyDefinition
{
Expand All @@ -310,7 +308,7 @@ public function ipAddress(string $column = 'ip_address'): PropertyDefinition
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function ipRange(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -321,7 +319,7 @@ public function ipRange(string $column, array $parameters = []): PropertyDefinit
* @param string $column
* @param array $relations
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function join(string $column, array $relations): PropertyDefinition
{
Expand All @@ -331,7 +329,7 @@ public function join(string $column, array $relations): PropertyDefinition
/**
* @param string $column
* @param array $parameters
* @return \Illuminate\Database\Schema\ColumnDefinition
* @return PropertyDefinition
*/
public function keyword(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -341,9 +339,9 @@ public function keyword(string $column, array $parameters = []): PropertyDefinit
/**
* @param string $column
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function long(string $column):ColumnDefinition
public function long(string $column):PropertyDefinition
{
return $this->addColumn('long', $column);
}
Expand All @@ -352,7 +350,7 @@ public function long(string $column):ColumnDefinition
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function longRange(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -371,7 +369,7 @@ public function meta(array $meta): void
* @param string $column
* @param \Closure $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function nested(string $column): PropertyDefinition
{
Expand All @@ -380,7 +378,7 @@ public function nested(string $column): PropertyDefinition

/**
* @param string $column
* @return ColumnDefinition|\Illuminate\Database\Schema\ColumnDefinition
* @return PropertyDefinition
*/
public function object(string $column)
{
Expand All @@ -391,7 +389,7 @@ public function object(string $column)
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function percolator(string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -403,7 +401,7 @@ public function percolator(string $column, array $parameters = []): PropertyDefi
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function range(string $type, string $column, array $parameters = []): PropertyDefinition
{
Expand All @@ -422,9 +420,9 @@ public function routingRequired(): void
* @param string $column
* @param array $length
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function string($column, $length = null): PropertyDefinition
public function string(string $column, $length = null): PropertyDefinition
{
$length = $length ?: Builder::$defaultStringLength;

Expand All @@ -433,14 +431,11 @@ public function string($column, $length = null): PropertyDefinition

/**
* @param string $column
* @param string $type
* @param array|null $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function text(string $type, string $column, array $parameters = []): PropertyDefinition
public function text(string $column): PropertyDefinition
{
return $this->addColumn($type, $column, $parameters);
return $this->addColumn('text', $column);
}

/**
Expand Down Expand Up @@ -476,7 +471,7 @@ public function toSql(Connection $connection, Grammar $grammar)
* @param string $column
* @param array $parameters
*
* @return ColumnDefinition
* @return PropertyDefinition
*/
public function tokenCount(string $column, array $parameters = []): PropertyDefinition
{
Expand Down

0 comments on commit b813864

Please sign in to comment.