Skip to content

Commit

Permalink
Fixed PHP 8.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Nov 6, 2024
1 parent 2fc9b67 commit 6c944dd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
34 changes: 17 additions & 17 deletions src/Schema/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand All @@ -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 );
}
Expand All @@ -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 );
}
Expand All @@ -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();
Expand All @@ -175,7 +175,7 @@ public function comment( string $value = null )
* @param array<string>|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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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 )
{
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/Schema/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -612,7 +612,7 @@ public function renameTable( $from, string $to = null ) : self
* @param array<string>|null $conditions Key/value pairs of column names and value to compare with
* @return array<int,array<string,mixed>> 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 = [];
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/Schema/Foreign.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Foreign
* @param array<string> $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;
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/Schema/Sequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
20 changes: 10 additions & 10 deletions src/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -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' );
Expand Down
4 changes: 2 additions & 2 deletions src/Up.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
} );
}
Expand Down

0 comments on commit 6c944dd

Please sign in to comment.