diff --git a/src/Schema/Column.php b/src/Schema/Column.php index 4aa46d0..9a80040 100644 --- a/src/Schema/Column.php +++ b/src/Schema/Column.php @@ -121,7 +121,7 @@ public function opt( string $option, $value = null, $for = null ) * @param bool|null $value New autoincrement flag or NULL to return current value * @return self|bool Same object for setting the value, current value without parameter */ - public function autoincrement( bool $value = null ) + public function autoincrement( ?bool $value = null ) { return $this->seq( $value ); } @@ -133,7 +133,7 @@ public function autoincrement( bool $value = null ) * @param string|null $value New column charset or NULL to return current value * @return self|string Same object for setting the value, current value without parameter */ - public function charset( string $value = null ) + public function charset( ?string $value = null ) { return $this->opt( 'charset', $value ); } @@ -145,7 +145,7 @@ public function charset( string $value = null ) * @param string|null $value New column collation or NULL to return current value * @return self|string Same object for setting the value, current value without parameter */ - public function collation( string $value = null ) + public function collation( ?string $value = null ) { return $this->opt( 'collation', $value ); } @@ -157,7 +157,7 @@ public function collation( string $value = null ) * @param string|null $value New column comment or NULL to return current value * @return self|string Same object for setting the value, current value without parameter */ - public function comment( string $value = null ) + public function comment( ?string $value = null ) { if( $value === null ) { return $this->column->getComment(); @@ -175,7 +175,7 @@ public function comment( string $value = null ) * @param array|string|null $for Database type this option should be used for ("mysql", "postgresql", "sqlite", "mssql", "oracle", "db2") * @return \Aimeos\Upscheme\Schema\Column Column object */ - public function custom( string $value = null, $for = null ) + public function custom( ?string $value = null, $for = null ) { if( $value === null ) { return $this->column->getColumnDefinition(); @@ -212,7 +212,7 @@ public function default( $value = null ) * @param bool|null $value New column fixed flag or NULL to return current value * @return self|bool Same object for setting the value, current value without parameter */ - public function fixed( bool $value = null ) + public function fixed( ?bool $value = null ) { if( $value === null ) { return $this->column->getFixed(); @@ -229,7 +229,7 @@ public function fixed( bool $value = null ) * @param int|null $value New column length or NULL to return current value * @return self|int Same object for setting the value, current value without parameter */ - public function length( int $value = null ) + public function length( ?int $value = null ) { if( $value === null ) { return $this->column->getLength(); @@ -257,7 +257,7 @@ public function name() : string * @param bool|null $value New column null flag or NULL to return current value * @return self|bool Same object for setting the value, current value without parameter */ - public function null( bool $value = null ) + public function null( ?bool $value = null ) { if( $value === null ) { return !$this->column->getNotnull(); @@ -274,7 +274,7 @@ public function null( bool $value = null ) * @param int|null $value New column precision value or NULL to return current value * @return self|int Same object for setting the value, current value without parameter */ - public function precision( int $value = null ) + public function precision( ?int $value = null ) { if( $value === null ) { return $this->column->getPrecision(); @@ -291,7 +291,7 @@ public function precision( int $value = null ) * @param int|null $value New column scale value or NULL to return current value * @return self|int Same object for setting the value, current value without parameter */ - public function scale( int $value = null ) + public function scale( ?int $value = null ) { if( $value === null ) { return $this->column->getScale(); @@ -308,7 +308,7 @@ public function scale( int $value = null ) * @param bool|null $value New autoincrement flag or NULL to return current value * @return self|bool Same object for setting the value, current value without parameter */ - public function seq( bool $value = null ) + public function seq( ?bool $value = null ) { if( $value === null ) { return $this->column->getAutoincrement(); @@ -325,7 +325,7 @@ public function seq( bool $value = null ) * @param string|null $value New column type or NULL to return current value * @return self|string Same object for setting the value, current value without parameter */ - public function type( string $value = null ) + public function type( ?string $value = null ) { if( $value === null ) { @@ -344,7 +344,7 @@ public function type( string $value = null ) * @param bool|null $value New column unsigned flag or NULL to return current value * @return self|bool Same object for setting the value, current value without parameter */ - public function unsigned( bool $value = null ) + public function unsigned( ?bool $value = null ) { if( $value === null ) { return $this->column->getUnsigned(); @@ -361,7 +361,7 @@ public function unsigned( bool $value = null ) * @param string|null $name Name of the index or NULL to generate automatically * @return self Same object for fluid method calls */ - public function index( string $name = null ) : self + public function index( ?string $name = null ) : self { $this->table->index( [$this->name()], $name ); return $this; @@ -374,7 +374,7 @@ public function index( string $name = null ) : self * @param string|null $name Name of the index or NULL to generate automatically * @return self Same object for fluid method calls */ - public function primary( string $name = null ) : self + public function primary( ?string $name = null ) : self { $this->table->primary( [$this->name()], $name ); return $this; @@ -387,7 +387,7 @@ public function primary( string $name = null ) : self * @param string|null $name Name of the index or NULL to generate automatically * @return self Same object for fluid method calls */ - public function spatial( string $name = null ) : self + public function spatial( ?string $name = null ) : self { $this->table->spatial( [$this->name()], $name ); return $this; @@ -400,7 +400,7 @@ public function spatial( string $name = null ) : self * @param string|null $name Name of the index or NULL to generate automatically * @return self Same object for fluid method calls */ - public function unique( string $name = null ) : self + public function unique( ?string $name = null ) : self { $this->table->unique( $this->name(), $name ); return $this; diff --git a/src/Schema/DB.php b/src/Schema/DB.php index 2c1f170..3152bbc 100644 --- a/src/Schema/DB.php +++ b/src/Schema/DB.php @@ -508,7 +508,7 @@ public function query( string $sql, array $params = [], array $types = [] ) : \D * @return self Same object for fluid method calls * @throws \RuntimeException If an error occured */ - public function renameColumn( string $table, $from, string $to = null ) : self + public function renameColumn( string $table, $from, ?string $to = null ) : self { $this->up(); $setup = false; @@ -546,7 +546,7 @@ public function renameColumn( string $table, $from, string $to = null ) : self * @param string|null $to New index name or NULL for autogenerated name (ignored if first parameter is an array) * @return self Same object for fluid method calls */ - public function renameIndex( string $table, $from, string $to = null ) : self + public function renameIndex( string $table, $from, ?string $to = null ) : self { if( $this->hasTable( $table ) ) { $this->table( $table )->renameIndex( $from, $to )->up(); @@ -564,7 +564,7 @@ public function renameIndex( string $table, $from, string $to = null ) : self * @return self Same object for fluid method calls * @throws \RuntimeException If an error occured */ - public function renameTable( $from, string $to = null ) : self + public function renameTable( $from, ?string $to = null ) : self { $this->up(); $setup = false; @@ -612,7 +612,7 @@ public function renameTable( $from, string $to = null ) : self * @param array|null $conditions Key/value pairs of column names and value to compare with * @return array> List of associative arrays containing column name/value pairs */ - public function select( string $table, array $conditions = null ) : array + public function select( string $table, ?array $conditions = null ) : array { $idx = 0; $list = []; @@ -651,7 +651,7 @@ public function select( string $table, array $conditions = null ) : array * @param \Closure|null $fcn Anonymous function with ($sequence) parameter creating or updating the sequence definition * @return \Aimeos\Upscheme\Schema\Sequence Sequence object */ - public function sequence( string $name, \Closure $fcn = null ) : Sequence + public function sequence( string $name, ?\Closure $fcn = null ) : Sequence { if( $this->to->hasSequence( $name ) ) { $seq = $this->to->getSequence( $name ); @@ -690,7 +690,7 @@ public function stmt() : \Doctrine\DBAL\Query\QueryBuilder * @param \Closure|null $fcn Anonymous function with ($table) parameter creating or updating the table definition * @return \Aimeos\Upscheme\Schema\Table Table object */ - public function table( string $name, \Closure $fcn = null ) : Table + public function table( string $name, ?\Closure $fcn = null ) : Table { if( $this->to->hasTable( $name ) ) { $dt = $this->to->getTable( $name ); diff --git a/src/Schema/Foreign.php b/src/Schema/Foreign.php index 773fd58..d78409f 100644 --- a/src/Schema/Foreign.php +++ b/src/Schema/Foreign.php @@ -74,7 +74,7 @@ class Foreign * @param array $fkcol List of columns from the referenced table spawning the foreign key constraint * @param string|null $name $name Name of the foreign key constraint and index or NULL for autogenerated name */ - public function __construct( DB $db, Table $table, DbalTable $dbaltable, array $localcol, string $fktable, array $fkcol, string $name = null ) + public function __construct( DB $db, Table $table, DbalTable $dbaltable, array $localcol, string $fktable, array $fkcol, ?string $name = null ) { $this->db = $db; $this->table = $table; @@ -201,7 +201,7 @@ public function name() * @param string|null $value Performed action or NULL to return current value * @return self|string Same object for setting the value, current value without parameter */ - public function onDelete( string $value = null ) + public function onDelete( ?string $value = null ) { if( $value === null ) { return $this->opts['onDelete']; @@ -230,7 +230,7 @@ public function onDelete( string $value = null ) * @param string|null $value Performed action or NULL to return current value * @return self|string Same object for setting the value, current value without parameter */ - public function onUpdate( string $value = null ) + public function onUpdate( ?string $value = null ) { if( $value === null ) { return $this->opts['onUpdate']; @@ -264,7 +264,7 @@ public function up() : self * @param string|null $newname Name of the new constraint or same name if NULL * @return self Same object for fluid method calls */ - protected function replace( string $newname = null ) : self + protected function replace( ?string $newname = null ) : self { $newname = $newname ?: $this->name; diff --git a/src/Schema/Sequence.php b/src/Schema/Sequence.php index cd0830f..e605814 100644 --- a/src/Schema/Sequence.php +++ b/src/Schema/Sequence.php @@ -91,7 +91,7 @@ public function __set( string $name, $value ) * @param int $value New number of sequence IDs cached by the client or NULL to return current value * @return self|int Same object for setting value, current value without parameter */ - public function cache( int $value = null ) + public function cache( ?int $value = null ) { if( $value === null ) { return $this->sequence->getCache(); @@ -119,7 +119,7 @@ public function name() * @param int $value New start value of the sequence or NULL to return current value * @return self|int Same object for setting value, current value without parameter */ - public function start( int $value = null ) + public function start( ?int $value = null ) { if( $value === null ) { return $this->sequence->getInitialValue(); @@ -136,7 +136,7 @@ public function start( int $value = null ) * @param int $value New step size the sequence is incremented or decremented by or NULL to return current value * @return self|int Same object for setting value, current value without parameter */ - public function step( int $value = null ) + public function step( ?int $value = null ) { if( $value === null ) { return $this->sequence->getAllocationSize(); diff --git a/src/Schema/Table.php b/src/Schema/Table.php index 9c15f69..1d659ed 100644 --- a/src/Schema/Table.php +++ b/src/Schema/Table.php @@ -13,8 +13,8 @@ * Table schema class * * @mixin \Doctrine\DBAL\Schema\Table - * @method Schema\Column id(string $name = null) - * @method Schema\Column bigid(string $name = null) + * @method Schema\Column id(?string $name = null) + * @method Schema\Column bigid(?string $name = null) */ class Table { @@ -174,7 +174,7 @@ public function char( string $name, int $length ) : Column * @param string $type|null Type of the column * @return \Aimeos\Upscheme\Schema\Column Column object */ - public function col( string $name, string $type = null ) : Column + public function col( string $name, ?string $type = null ) : Column { if( $this->table->hasColumn( $name ) ) { $col = $this->table->getColumn( $name ); @@ -511,7 +511,7 @@ public function hasForeign( $name ) : bool * @param string|null $name Name of the foreign key constraint and foreign key index or NULL for autogenerated name * @return \Aimeos\Upscheme\Schema\Foreign Foreign key constraint object */ - public function foreign( $localcolumn, string $foreigntable, $foreigncolumn = 'id', string $name = null ) : Foreign + public function foreign( $localcolumn, string $foreigntable, $foreigncolumn = 'id', ?string $name = null ) : Foreign { $localcolumn = (array) $localcolumn; $foreigncolumn = (array) $foreigncolumn; @@ -549,7 +549,7 @@ public function foreign( $localcolumn, string $foreigntable, $foreigncolumn = 'i * @param array $options Associative key/value pairs of DB-specific index options * @return self Same object for fluid method calls */ - public function index( $columns, string $name = null, array $flags = [], array $options = [] ) : self + public function index( $columns, ?string $name = null, array $flags = [], array $options = [] ) : self { $columns = (array) $columns; $name = $name ?: $this->nameIndex( $this->name(), $columns, 'idx' ); @@ -624,7 +624,7 @@ public function opt( string $name, $value = null ) * @param string|null $name Index name or NULL for autogenerated name * @return self Same object for fluid method calls */ - public function primary( $columns, string $name = null ) : self + public function primary( $columns, ?string $name = null ) : self { $columns = (array) $columns; $index = $this->table->getPrimaryKey(); @@ -654,7 +654,7 @@ public function primary( $columns, string $name = null ) : self * @param string|null $to New column name or NULL if first parameter is an array * @return self Same object for fluid method calls */ - public function renameColumn( $from, string $to = null ) : self + public function renameColumn( $from, ?string $to = null ) : self { if( !$this->hasColumn( $from ) ) { return $this; @@ -672,7 +672,7 @@ public function renameColumn( $from, string $to = null ) : self * @param string|null $to New index name or NULL for autogenerated name (ignored if first parameter is an array) * @return self Same object for fluid method calls */ - public function renameIndex( $from, string $to = null ) : self + public function renameIndex( $from, ?string $to = null ) : self { if( !is_array( $from ) ) { $from = [$from => $to]; @@ -704,7 +704,7 @@ public function renameIndex( $from, string $to = null ) : self * @param string|null $name Index name or NULL for autogenerated name * @return self Same object for fluid method calls */ - public function spatial( $columns, string $name = null ) : self + public function spatial( $columns, ?string $name = null ) : self { $columns = (array) $columns; $name = $name ?: $this->nameIndex( $this->name(), $columns, 'idx' ); @@ -736,7 +736,7 @@ public function spatial( $columns, string $name = null ) : self * @param string|null $name Index name or NULL for autogenerated name * @return self Same object for fluid method calls */ - public function unique( $columns, string $name = null ) : self + public function unique( $columns, ?string $name = null ) : self { $columns = (array) $columns; $name = $name ?: $this->nameIndex( $this->name(), $columns, 'unq' ); diff --git a/src/Up.php b/src/Up.php index 39d3407..352c4a4 100644 --- a/src/Up.php +++ b/src/Up.php @@ -311,11 +311,11 @@ protected function createTasks( array $paths ) : array */ protected function macros() { - \Aimeos\Upscheme\Schema\Table::macro( 'id', function( string $name = null ) : Schema\Column { + \Aimeos\Upscheme\Schema\Table::macro( 'id', function( ?string $name = null ) : Schema\Column { return $this->integer( $name ?: 'id' )->seq( true )->primary(); } ); - \Aimeos\Upscheme\Schema\Table::macro( 'bigid', function( string $name = null ) : Schema\Column { + \Aimeos\Upscheme\Schema\Table::macro( 'bigid', function( ?string $name = null ) : Schema\Column { return $this->bigint( $name ?: 'id' )->seq( true )->primary(); } ); }