From 164f2066d62e7ba6af78666b82216693f8db8084 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Fri, 23 Aug 2024 18:17:06 -0300 Subject: [PATCH] Upgrade coding standard --- composer.json | 2 +- src/Database.php | 58 ++++----- src/Definition/AlterSchema.php | 2 +- src/Definition/AlterTable.php | 2 +- src/Definition/CreateSchema.php | 2 +- src/Definition/CreateTable.php | 2 +- src/Definition/DropSchema.php | 2 +- src/Definition/DropTable.php | 2 +- src/Definition/Table/Columns/Column.php | 6 +- .../Table/Columns/ColumnDefinition.php | 22 ++-- .../Table/Indexes/IndexDefinition.php | 2 +- src/Definition/Table/TableDefinition.php | 12 +- src/Definition/Table/TableStatement.php | 4 +- src/Manipulation/Delete.php | 10 +- src/Manipulation/Insert.php | 2 +- src/Manipulation/LoadData.php | 2 +- src/Manipulation/Select.php | 24 ++-- src/Manipulation/Statement.php | 6 +- src/Manipulation/Traits/Explain.php | 2 +- src/Manipulation/Traits/Having.php | 4 +- src/Manipulation/Traits/Join.php | 120 +++++++++--------- src/Manipulation/Traits/Values.php | 4 +- src/Manipulation/Traits/Where.php | 86 ++++++------- src/Manipulation/Update.php | 10 +- src/PreparedStatement.php | 2 +- src/Result.php | 8 +- src/Result/Explain.php | 8 +- src/Statement.php | 2 +- tests/Manipulation/SelectTest.php | 4 +- tests/Manipulation/StatementMock.php | 4 +- 30 files changed, 208 insertions(+), 208 deletions(-) diff --git a/composer.json b/composer.json index bb3c7c7..3232cd4 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^2.1", + "aplus/coding-standard": "^2.8", "ergebnis/composer-normalize": "^2.25", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", diff --git a/src/Database.php b/src/Database.php index 1bfcac8..0a9929a 100644 --- a/src/Database.php +++ b/src/Database.php @@ -89,12 +89,12 @@ public function __construct( #[SensitiveParameter] array | string $username, #[SensitiveParameter] - string $password = null, - string $schema = null, + ?string $password = null, + ?string $schema = null, string $host = 'localhost', int $port = 3306, - Logger $logger = null, - DatabaseCollector $collector = null + ?Logger $logger = null, + ?DatabaseCollector $collector = null ) { if ($collector) { $this->setDebugCollector($collector); @@ -187,8 +187,8 @@ protected function connect( #[SensitiveParameter] array | string $username, #[SensitiveParameter] - string $password = null, - string $schema = null, + ?string $password = null, + ?string $schema = null, string $host = 'localhost', int $port = 3306 ) : static { @@ -415,7 +415,7 @@ public function use(string $schema) : static * * @return CreateSchema */ - public function createSchema(string $schemaName = null) : CreateSchema + public function createSchema(?string $schemaName = null) : CreateSchema { $instance = new CreateSchema($this); if ($schemaName !== null) { @@ -431,7 +431,7 @@ public function createSchema(string $schemaName = null) : CreateSchema * * @return DropSchema */ - public function dropSchema(string $schemaName = null) : DropSchema + public function dropSchema(?string $schemaName = null) : DropSchema { $instance = new DropSchema($this); if ($schemaName !== null) { @@ -447,7 +447,7 @@ public function dropSchema(string $schemaName = null) : DropSchema * * @return AlterSchema */ - public function alterSchema(string $schemaName = null) : AlterSchema + public function alterSchema(?string $schemaName = null) : AlterSchema { $instance = new AlterSchema($this); if ($schemaName !== null) { @@ -463,7 +463,7 @@ public function alterSchema(string $schemaName = null) : AlterSchema * * @return CreateTable */ - public function createTable(string $tableName = null) : CreateTable + public function createTable(?string $tableName = null) : CreateTable { $instance = new CreateTable($this); if ($tableName !== null) { @@ -480,7 +480,7 @@ public function createTable(string $tableName = null) : CreateTable * * @return DropTable */ - public function dropTable(string $table = null, string ...$tables) : DropTable + public function dropTable(?string $table = null, string ...$tables) : DropTable { $instance = new DropTable($this); if ($table !== null) { @@ -496,7 +496,7 @@ public function dropTable(string $table = null, string ...$tables) : DropTable * * @return AlterTable */ - public function alterTable(string $tableName = null) : AlterTable + public function alterTable(?string $tableName = null) : AlterTable { $instance = new AlterTable($this); if ($tableName !== null) { @@ -508,14 +508,14 @@ public function alterTable(string $tableName = null) : AlterTable /** * Call a DELETE statement. * - * @param array|Closure|string|null $reference - * @param array|Closure|string ...$references + * @param Closure|array|string|null $reference + * @param Closure|array|string ...$references * * @return Delete */ public function delete( - array | Closure | string $reference = null, - array | Closure | string ...$references + Closure | array | string | null $reference = null, + Closure | array | string ...$references ) : Delete { $instance = new Delete($this); if ($reference !== null) { @@ -531,7 +531,7 @@ public function delete( * * @return Insert */ - public function insert(string $intoTable = null) : Insert + public function insert(?string $intoTable = null) : Insert { $instance = new Insert($this); if ($intoTable !== null) { @@ -547,7 +547,7 @@ public function insert(string $intoTable = null) : Insert * * @return LoadData */ - public function loadData(string $intoTable = null) : LoadData + public function loadData(?string $intoTable = null) : LoadData { $instance = new LoadData($this); if ($intoTable !== null) { @@ -563,7 +563,7 @@ public function loadData(string $intoTable = null) : LoadData * * @return Replace */ - public function replace(string $intoTable = null) : Replace + public function replace(?string $intoTable = null) : Replace { $instance = new Replace($this); if ($intoTable !== null) { @@ -575,14 +575,14 @@ public function replace(string $intoTable = null) : Replace /** * Call a SELECT statement. * - * @param array|Closure|string|null $reference - * @param array|Closure|string ...$references + * @param Closure|array|string|null $reference + * @param Closure|array|string ...$references * * @return Select */ public function select( - array | Closure | string $reference = null, - array | Closure | string ...$references + Closure | array | string | null $reference = null, + Closure | array | string ...$references ) : Select { $instance = new Select($this); if ($reference !== null) { @@ -594,14 +594,14 @@ public function select( /** * Call a UPDATE statement. * - * @param array|Closure|string|null $reference - * @param array|Closure|string ...$references + * @param Closure|array|string|null $reference + * @param Closure|array|string ...$references * * @return Update */ public function update( - array | Closure | string $reference = null, - array | Closure | string ...$references + Closure | array | string | null $reference = null, + Closure | array | string ...$references ) : Update { $instance = new Update($this); if ($reference !== null) { @@ -773,7 +773,7 @@ public function protectIdentifier(string $identifier) : string * the word "NULL". If is false, "FALSE". If is true, "TRUE". If is a string, * returns the quoted string. The types int or float returns the same input value. */ - public function quote(float | bool | int | string | null $value) : float | int | string + public function quote(bool | float | int | string | null $value) : float | int | string { $type = \gettype($value); if ($type === 'string') { @@ -818,7 +818,7 @@ protected function addToDebug(Closure $function) : mixed protected function finalizeAddToDebug( float $start, - string|null $description = null + ?string $description = null ) : void { $end = \microtime(true); $rows = $this->mysqli->affected_rows; diff --git a/src/Definition/AlterSchema.php b/src/Definition/AlterSchema.php index b09aa8a..d22fb3c 100644 --- a/src/Definition/AlterSchema.php +++ b/src/Definition/AlterSchema.php @@ -143,7 +143,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Definition/AlterTable.php b/src/Definition/AlterTable.php index a268879..b254001 100644 --- a/src/Definition/AlterTable.php +++ b/src/Definition/AlterTable.php @@ -498,7 +498,7 @@ protected function renderRenameKeys() : ?string return \implode(',' . \PHP_EOL, $renames); } - public function convertToCharset(string $charset, string $collation = null) : static + public function convertToCharset(string $charset, ?string $collation = null) : static { $this->sql['convert_to_charset'] = [ 'charset' => $charset, diff --git a/src/Definition/CreateSchema.php b/src/Definition/CreateSchema.php index c94fcd7..92a8d71 100644 --- a/src/Definition/CreateSchema.php +++ b/src/Definition/CreateSchema.php @@ -140,7 +140,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Definition/CreateTable.php b/src/Definition/CreateTable.php index a6b6ca2..3afa68e 100644 --- a/src/Definition/CreateTable.php +++ b/src/Definition/CreateTable.php @@ -137,7 +137,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Definition/DropSchema.php b/src/Definition/DropSchema.php index acaf9ac..4c38642 100644 --- a/src/Definition/DropSchema.php +++ b/src/Definition/DropSchema.php @@ -69,7 +69,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Definition/DropTable.php b/src/Definition/DropTable.php index 2e04563..2760b9e 100644 --- a/src/Definition/DropTable.php +++ b/src/Definition/DropTable.php @@ -144,7 +144,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Definition/Table/Columns/Column.php b/src/Definition/Table/Columns/Column.php index fffbdcc..3ed3906 100644 --- a/src/Definition/Table/Columns/Column.php +++ b/src/Definition/Table/Columns/Column.php @@ -30,7 +30,7 @@ abstract class Column extends DefinitionPart protected bool $null = false; protected bool $uniqueKey = false; protected bool $primaryKey = false; - protected bool | Closure | float | int | string | null $default; + protected Closure | bool | float | int | string | null $default; protected Closure $check; protected ?string $comment; protected bool $first = false; @@ -108,11 +108,11 @@ protected function renderNull() : ?string } /** - * @param bool|Closure|float|int|string|null $default + * @param Closure|bool|float|int|string|null $default * * @return static */ - public function default(bool | Closure | float | int | string | null $default) : static + public function default(Closure | bool | float | int | string | null $default) : static { $this->default = $default; return $this; diff --git a/src/Definition/Table/Columns/ColumnDefinition.php b/src/Definition/Table/Columns/ColumnDefinition.php index 1c2d0f3..8930d70 100644 --- a/src/Definition/Table/Columns/ColumnDefinition.php +++ b/src/Definition/Table/Columns/ColumnDefinition.php @@ -66,52 +66,52 @@ public function __construct(Database $database) $this->database = $database; } - public function int(int $maximum = null) : IntColumn + public function int(?int $maximum = null) : IntColumn { return $this->column = new IntColumn($this->database, $maximum); } - public function bigint(int $maximum = null) : BigintColumn + public function bigint(?int $maximum = null) : BigintColumn { return $this->column = new BigintColumn($this->database, $maximum); } - public function tinyint(int $maximum = null) : TinyintColumn + public function tinyint(?int $maximum = null) : TinyintColumn { return $this->column = new TinyintColumn($this->database, $maximum); } - public function decimal(int $maximum = null, int $decimals = null) : DecimalColumn + public function decimal(?int $maximum = null, ?int $decimals = null) : DecimalColumn { return $this->column = new DecimalColumn($this->database, $maximum, $decimals); } - public function float(int $maximum = null, int $decimals = null) : FloatColumn + public function float(?int $maximum = null, ?int $decimals = null) : FloatColumn { return $this->column = new FloatColumn($this->database, $maximum, $decimals); } - public function mediumint(int $maximum = null) : MediumintColumn + public function mediumint(?int $maximum = null) : MediumintColumn { return $this->column = new MediumintColumn($this->database, $maximum); } - public function smallint(int $maximum = null) : SmallintColumn + public function smallint(?int $maximum = null) : SmallintColumn { return $this->column = new SmallintColumn($this->database, $maximum); } - public function boolean(int $maximum = null) : BooleanColumn + public function boolean(?int $maximum = null) : BooleanColumn { return $this->column = new BooleanColumn($this->database, $maximum); } - public function varchar(int $maximum = null) : VarcharColumn + public function varchar(?int $maximum = null) : VarcharColumn { return $this->column = new VarcharColumn($this->database, $maximum); } - public function char(int $maximum = null) : CharColumn + public function char(?int $maximum = null) : CharColumn { return $this->column = new CharColumn($this->database, $maximum); } @@ -126,7 +126,7 @@ public function set(string $value, string ...$values) : SetColumn return $this->column = new SetColumn($this->database, $value, ...$values); } - public function text(int $maximum = null) : TextColumn + public function text(?int $maximum = null) : TextColumn { return $this->column = new TextColumn($this->database, $maximum); } diff --git a/src/Definition/Table/Indexes/IndexDefinition.php b/src/Definition/Table/Indexes/IndexDefinition.php index 2f340c9..ee43895 100644 --- a/src/Definition/Table/Indexes/IndexDefinition.php +++ b/src/Definition/Table/Indexes/IndexDefinition.php @@ -33,7 +33,7 @@ class IndexDefinition extends DefinitionPart protected ?string $name; protected ?Index $index = null; - public function __construct(Database $database, string $name = null) + public function __construct(Database $database, ?string $name = null) { $this->database = $database; $this->name = $name; diff --git a/src/Definition/Table/TableDefinition.php b/src/Definition/Table/TableDefinition.php index 5b9520b..7212859 100644 --- a/src/Definition/Table/TableDefinition.php +++ b/src/Definition/Table/TableDefinition.php @@ -42,7 +42,7 @@ class TableDefinition extends DefinitionPart * @param Database $database * @param string|null $condition */ - public function __construct(Database $database, string $condition = null) + public function __construct(Database $database, ?string $condition = null) { $this->database = $database; $this->condition = $condition; @@ -56,7 +56,7 @@ public function __construct(Database $database, string $condition = null) * * @return ColumnDefinition */ - public function column(string $name, string $changeName = null) : ColumnDefinition + public function column(string $name, ?string $changeName = null) : ColumnDefinition { $definition = new ColumnDefinition($this->database); $this->columns[] = [ @@ -74,7 +74,7 @@ public function column(string $name, string $changeName = null) : ColumnDefiniti * * @return IndexDefinition */ - public function index(string $name = null) : IndexDefinition + public function index(?string $name = null) : IndexDefinition { $definition = new IndexDefinition($this->database, $name); $this->indexes[] = [ @@ -97,7 +97,7 @@ public function check(Closure $expression) : Check return $this->checks[] = new Check($this->database, $expression); } - protected function renderColumns(string $prefix = null) : string + protected function renderColumns(?string $prefix = null) : string { if ($prefix) { $prefix .= ' COLUMN'; @@ -117,7 +117,7 @@ protected function renderColumns(string $prefix = null) : string return \implode(',' . \PHP_EOL, $sql); } - protected function renderIndexes(string $prefix = null) : string + protected function renderIndexes(?string $prefix = null) : string { $sql = []; foreach ($this->indexes as $index) { @@ -140,7 +140,7 @@ protected function renderChecks() : string return \implode(',' . \PHP_EOL, $sql); } - protected function sql(string $prefix = null) : string + protected function sql(?string $prefix = null) : string { $sql = $this->renderColumns($prefix); $part = $this->renderIndexes($prefix); diff --git a/src/Definition/Table/TableStatement.php b/src/Definition/Table/TableStatement.php index 85fa393..0f083c8 100644 --- a/src/Definition/Table/TableStatement.php +++ b/src/Definition/Table/TableStatement.php @@ -158,7 +158,7 @@ abstract class TableStatement extends Statement * * @return static */ - public function option(string $name, int | string $value = null) : static + public function option(string $name, int | string | null $value = null) : static { $this->sql['options'][$name] = $value; return $this; @@ -533,7 +533,7 @@ private function getValue( string $optionName, string $originalValue, array $options, - string $value = null, + ?string $value = null, bool $getByKey = false ) : string { $value ??= $originalValue; diff --git a/src/Manipulation/Delete.php b/src/Manipulation/Delete.php index ff57939..59c591c 100644 --- a/src/Manipulation/Delete.php +++ b/src/Manipulation/Delete.php @@ -55,17 +55,17 @@ protected function renderOptions() : ?string /** * Sets the table references. * - * @param array|Closure|string $reference The table + * @param Closure|array|string $reference The table * name as string, a subquery as Closure or an array for aliased table where * the key is the alias name and the value is the table name or a subquery - * @param array|Closure|string ...$references Extra + * @param Closure|array|string ...$references Extra * references. Same values as $reference * * @return static */ public function table( - array | Closure | string $reference, - array | Closure | string ...$references + Closure | array | string $reference, + Closure | array | string ...$references ) : static { $this->sql['table'] = []; foreach ([$reference, ...$references] as $reference) { @@ -149,7 +149,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Manipulation/Insert.php b/src/Manipulation/Insert.php index bc0af20..babaeb5 100644 --- a/src/Manipulation/Insert.php +++ b/src/Manipulation/Insert.php @@ -230,7 +230,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Manipulation/LoadData.php b/src/Manipulation/LoadData.php index c96bd65..a9cdde8 100644 --- a/src/Manipulation/LoadData.php +++ b/src/Manipulation/LoadData.php @@ -264,7 +264,7 @@ public function sql() : string return $sql; } - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/Manipulation/Select.php b/src/Manipulation/Select.php index ed99499..64cf68c 100644 --- a/src/Manipulation/Select.php +++ b/src/Manipulation/Select.php @@ -196,16 +196,16 @@ protected function renderOptions() : ?string * * Generally used with the FROM clause as column names. * - * @param array|Closure|string $expression - * @param array|Closure|string ...$expressions + * @param Closure|array|string $expression + * @param Closure|array|string ...$expressions * * @see https://mariadb.com/kb/en/select/#select-expressions * * @return static */ public function expressions( - array | Closure | string $expression, - array | Closure | string ...$expressions + Closure | array | string $expression, + Closure | array | string ...$expressions ) : static { foreach ([$expression, ...$expressions] as $expression) { $this->sql['expressions'][] = $expression; @@ -216,14 +216,14 @@ public function expressions( /** * Alias of the expressions method. * - * @param array|Closure|string $expression - * @param array|Closure|string ...$expressions + * @param Closure|array|string $expression + * @param Closure|array|string ...$expressions * * @return static */ public function columns( - array | Closure | string $expression, - array | Closure | string ...$expressions + Closure | array | string $expression, + Closure | array | string ...$expressions ) : static { return $this->expressions($expression, ...$expressions); } @@ -253,7 +253,7 @@ protected function renderExpressions() : ?string * * @return static */ - public function limit(int $limit, int $offset = null) : static + public function limit(int $limit, ?int $offset = null) : static { return $this->setLimit($limit, $offset); } @@ -302,7 +302,7 @@ protected function renderProcedure() : ?string */ public function intoOutfile( string $filename, - string $charset = null, + ?string $charset = null, array $fieldsOptions = [], array $linesOptions = [] ) : static { @@ -426,7 +426,7 @@ protected function renderIntoDumpfile() : ?string * * @return static */ - public function lockForUpdate(int $wait = null) : static + public function lockForUpdate(?int $wait = null) : static { $this->sql['lock'] = [ 'type' => 'FOR UPDATE', @@ -442,7 +442,7 @@ public function lockForUpdate(int $wait = null) : static * * @return static */ - public function lockInShareMode(int $wait = null) : static + public function lockInShareMode(?int $wait = null) : static { $this->sql['lock'] = [ 'type' => 'LOCK IN SHARE MODE', diff --git a/src/Manipulation/Statement.php b/src/Manipulation/Statement.php index ab870db..7c973c2 100644 --- a/src/Manipulation/Statement.php +++ b/src/Manipulation/Statement.php @@ -76,7 +76,7 @@ protected function subquery(Closure $subquery) : string * * @return static */ - protected function setLimit(int $limit, int $offset = null) : static + protected function setLimit(int $limit, ?int $offset = null) : static { $this->sql['limit'] = [ 'limit' => $limit, @@ -125,12 +125,12 @@ protected function renderIdentifier(Closure | string $column) : string /** * Renders a column part with an optional alias name, AS clause. * - * @param array|Closure|string $column The column name, + * @param Closure|array|string $column The column name, * a subquery or an array where the index is the alias and the value is the column/subquery * * @return string */ - protected function renderAliasedIdentifier(array | Closure | string $column) : string + protected function renderAliasedIdentifier(Closure | array | string $column) : string { if (\is_array($column)) { if (\count($column) !== 1) { diff --git a/src/Manipulation/Traits/Explain.php b/src/Manipulation/Traits/Explain.php index c6d4202..0073e13 100644 --- a/src/Manipulation/Traits/Explain.php +++ b/src/Manipulation/Traits/Explain.php @@ -45,7 +45,7 @@ trait Explain * * @return array */ - public function explain(string $option = null) : array + public function explain(?string $option = null) : array { if ($option !== null) { $opt = \strtoupper($option); diff --git a/src/Manipulation/Traits/Having.php b/src/Manipulation/Traits/Having.php index 73f5110..3dfbbd2 100644 --- a/src/Manipulation/Traits/Having.php +++ b/src/Manipulation/Traits/Having.php @@ -572,7 +572,7 @@ public function orHavingIsNotNull(Closure | string $column) : static * Adds a HAVING part. * * @param string $glue `AND` or `OR` - * @param array|Closure|string>|Closure|string $column + * @param Closure|array|string>|string $column * @param string $operator `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, * `LIKE`, `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`, `IS NULL`, * `IS NOT NULL` or `MATCH` @@ -582,7 +582,7 @@ public function orHavingIsNotNull(Closure | string $column) : static */ private function addHaving( string $glue, - array | Closure | string $column, + Closure | array | string $column, string $operator, array $values ) : static { diff --git a/src/Manipulation/Traits/Join.php b/src/Manipulation/Traits/Join.php index 8de43f3..68b4fa5 100644 --- a/src/Manipulation/Traits/Join.php +++ b/src/Manipulation/Traits/Join.php @@ -27,16 +27,16 @@ trait Join /** * Sets the FROM clause. * - * @param array|Closure|string $reference Table reference - * @param array|Closure|string ...$references Table references + * @param Closure|array|string $reference Table reference + * @param Closure|array|string ...$references Table references * * @see https://mariadb.com/kb/en/join-syntax/ * * @return static */ public function from( - array | Closure | string $reference, - array | Closure | string ...$references + Closure | array | string $reference, + Closure | array | string ...$references ) : static { $this->sql['from'] = []; foreach ([$reference, ...$references] as $reference) { @@ -71,7 +71,7 @@ protected function renderFrom() : ?string * * @return bool True if it has FROM, otherwise false */ - protected function hasFrom(string $clause = null) : bool + protected function hasFrom(?string $clause = null) : bool { if (isset($this->sql['from'])) { return true; @@ -85,22 +85,22 @@ protected function hasFrom(string $clause = null) : bool /** * Adds a JOIN clause with "$type JOIN $table $clause $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param string $type JOIN type. One of: `CROSS`, `INNER`, `LEFT`, `LEFT OUTER`, * `RIGHT`, `RIGHT OUTER`, `NATURAL`, `NATURAL LEFT`, `NATURAL LEFT OUTER`, * `NATURAL RIGHT`, `NATURAL RIGHT OUTER` or empty (same as `INNER`) * @param string|null $clause Condition clause. Null if it has a NATURAL type, * otherwise `ON` or `USING` - * @param array|Closure|null $conditional A conditional + * @param Closure|array|null $conditional A conditional * expression as Closure or the columns list as array * * @return static */ public function join( - array | Closure | string $table, + Closure | array | string $table, string $type = '', - string $clause = null, - array | Closure $conditional = null + ?string $clause = null, + Closure | array | null $conditional = null ) : static { return $this->setJoin($table, $type, $clause, $conditional); } @@ -108,13 +108,13 @@ public function join( /** * Adds a JOIN clause with "JOIN $table ON $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure $conditional Conditional expression * * @return static */ public function joinOn( - array | Closure | string $table, + Closure | array | string $table, Closure $conditional ) : static { return $this->setJoin($table, '', 'ON', $conditional); @@ -123,13 +123,13 @@ public function joinOn( /** * Adds a JOIN clause with "JOIN $table USING ...$columns". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure|string ...$columns Columns list * * @return static */ public function joinUsing( - array | Closure | string $table, + Closure | array | string $table, Closure | string ...$columns ) : static { return $this->setJoin($table, '', 'USING', $columns); @@ -138,13 +138,13 @@ public function joinUsing( /** * Adds a JOIN clause with "INNER JOIN $table ON $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure $conditional Conditional expression * * @return static */ public function innerJoinOn( - array | Closure | string $table, + Closure | array | string $table, Closure $conditional ) : static { return $this->setJoin($table, 'INNER', 'ON', $conditional); @@ -153,13 +153,13 @@ public function innerJoinOn( /** * Adds a JOIN clause with "INNER JOIN $table USING ...$columns". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure|string ...$columns Columns list * * @return static */ public function innerJoinUsing( - array | Closure | string $table, + Closure | array | string $table, Closure | string ...$columns ) : static { return $this->setJoin($table, 'INNER', 'USING', $columns); @@ -168,11 +168,11 @@ public function innerJoinUsing( /** * Adds a JOIN clause with "CROSS JOIN $table". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * * @return static */ - public function crossJoin(array | Closure | string $table) : static + public function crossJoin(Closure | array | string $table) : static { return $this->setJoin($table, 'CROSS'); } @@ -180,13 +180,13 @@ public function crossJoin(array | Closure | string $table) : static /** * Adds a JOIN clause with "CROSS JOIN $table ON $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure $conditional Conditional expression * * @return static */ public function crossJoinOn( - array | Closure | string $table, + Closure | array | string $table, Closure $conditional ) : static { return $this->setJoin($table, 'CROSS', 'ON', $conditional); @@ -195,13 +195,13 @@ public function crossJoinOn( /** * Adds a JOIN clause with "CROSS JOIN $table USING ...$columns". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure|string ...$columns Columns list * * @return static */ public function crossJoinUsing( - array | Closure | string $table, + Closure | array | string $table, Closure | string ...$columns ) : static { return $this->setJoin($table, 'CROSS', 'USING', $columns); @@ -210,13 +210,13 @@ public function crossJoinUsing( /** * Adds a JOIN clause with "LEFT JOIN $table ON $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure $conditional Conditional expression * * @return static */ public function leftJoinOn( - array | Closure | string $table, + Closure | array | string $table, Closure $conditional ) : static { return $this->setJoin($table, 'LEFT', 'ON', $conditional); @@ -225,13 +225,13 @@ public function leftJoinOn( /** * Adds a JOIN clause with "LEFT JOIN $table USING ...$columns". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure|string ...$columns Columns list * * @return static */ public function leftJoinUsing( - array | Closure | string $table, + Closure | array | string $table, Closure | string ...$columns ) : static { return $this->setJoin($table, 'LEFT', 'USING', $columns); @@ -240,13 +240,13 @@ public function leftJoinUsing( /** * Adds a JOIN clause with "LEFT OUTER JOIN $table ON $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure $conditional Conditional expression * * @return static */ public function leftOuterJoinOn( - array | Closure | string $table, + Closure | array | string $table, Closure $conditional ) : static { return $this->setJoin($table, 'LEFT OUTER', 'ON', $conditional); @@ -255,13 +255,13 @@ public function leftOuterJoinOn( /** * Adds a JOIN clause with "LEFT OUTER JOIN $table USING ...$columns". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure|string ...$columns Columns list * * @return static */ public function leftOuterJoinUsing( - array | Closure | string $table, + Closure | array | string $table, Closure | string ...$columns ) : static { return $this->setJoin($table, 'LEFT OUTER', 'USING', $columns); @@ -270,13 +270,13 @@ public function leftOuterJoinUsing( /** * Adds a JOIN clause with "RIGHT JOIN $table ON $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure $conditional Conditional expression * * @return static */ public function rightJoinOn( - array | Closure | string $table, + Closure | array | string $table, Closure $conditional ) : static { return $this->setJoin($table, 'RIGHT', 'ON', $conditional); @@ -285,13 +285,13 @@ public function rightJoinOn( /** * Adds a JOIN clause with "RIGHT JOIN $table USING ...$columns". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure|string ...$columns Columns list * * @return static */ public function rightJoinUsing( - array | Closure | string $table, + Closure | array | string $table, Closure | string ...$columns ) : static { return $this->setJoin($table, 'RIGHT', 'USING', $columns); @@ -300,13 +300,13 @@ public function rightJoinUsing( /** * Adds a JOIN clause with "RIGHT OUTER JOIN $table ON $conditional". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure $conditional Conditional expression * * @return static */ public function rightOuterJoinOn( - array | Closure | string $table, + Closure | array | string $table, Closure $conditional ) : static { return $this->setJoin($table, 'RIGHT OUTER', 'ON', $conditional); @@ -315,13 +315,13 @@ public function rightOuterJoinOn( /** * Adds a JOIN clause with "RIGHT OUTER JOIN $table USING ...$columns". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * @param Closure|string ...$columns Columns list * * @return static */ public function rightOuterJoinUsing( - array | Closure | string $table, + Closure | array | string $table, Closure | string ...$columns ) : static { return $this->setJoin($table, 'RIGHT OUTER', 'USING', $columns); @@ -330,11 +330,11 @@ public function rightOuterJoinUsing( /** * Adds a JOIN clause with "NATURAL JOIN $table". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * * @return static */ - public function naturalJoin(array | Closure | string $table) : static + public function naturalJoin(Closure | array | string $table) : static { return $this->setJoin($table, 'NATURAL'); } @@ -342,11 +342,11 @@ public function naturalJoin(array | Closure | string $table) : static /** * Adds a JOIN clause with "NATURAL LEFT JOIN $table". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * * @return static */ - public function naturalLeftJoin(array | Closure | string $table) : static + public function naturalLeftJoin(Closure | array | string $table) : static { return $this->setJoin($table, 'NATURAL LEFT'); } @@ -354,12 +354,12 @@ public function naturalLeftJoin(array | Closure | string $table) : static /** * Adds a JOIN clause with "NATURAL LEFT OUTER JOIN $table". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * * @return static */ public function naturalLeftOuterJoin( - array | Closure | string $table + Closure | array | string $table ) : static { return $this->setJoin($table, 'NATURAL LEFT OUTER'); } @@ -367,11 +367,11 @@ public function naturalLeftOuterJoin( /** * Adds a JOIN clause with "NATURAL RIGHT JOIN $table". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * * @return static */ - public function naturalRightJoin(array | Closure | string $table) : static + public function naturalRightJoin(Closure | array | string $table) : static { return $this->setJoin($table, 'NATURAL RIGHT'); } @@ -379,12 +379,12 @@ public function naturalRightJoin(array | Closure | string $table) : static /** * Adds a JOIN clause with "NATURAL RIGHT OUTER JOIN $table". * - * @param array|Closure|string $table Table factor + * @param Closure|array|string $table Table factor * * @return static */ public function naturalRightOuterJoin( - array | Closure | string $table + Closure | array | string $table ) : static { return $this->setJoin($table, 'NATURAL RIGHT OUTER'); } @@ -392,20 +392,20 @@ public function naturalRightOuterJoin( /** * Sets the JOIN clause. * - * @param array|Closure|string $table The table factor + * @param Closure|array|string $table The table factor * @param string $type ``, `CROSS`, `INNER`, `LEFT`, `LEFT OUTER`, `RIGHT`, * `RIGHT OUTER`, `NATURAL`, `NATURAL LEFT`, `NATURAL LEFT OUTER`, `NATURAL RIGHT` * or `NATURAL RIGHT OUTER` * @param string|null $clause `ON`, `USING` or null for none - * @param array|Closure|null $expression Column(s) or subquery(ies) + * @param Closure|array|null $expression Column(s) or subquery(ies) * * @return static */ private function setJoin( - array | Closure | string $table, + Closure | array | string $table, string $type, - string $clause = null, - Closure | array $expression = null + ?string $clause = null, + Closure | array | null $expression = null ) : static { $this->sql['join'][] = [ 'type' => $type, @@ -452,15 +452,15 @@ protected function renderJoin() : ?string * @param string $type ``, `CROSS`,`INNER`, `LEFT`, `LEFT OUTER`, `RIGHT`, * `RIGHT OUTER`, `NATURAL`, `NATURAL LEFT`, `NATURAL LEFT OUTER`, `NATURAL RIGHT` * or `NATURAL RIGHT OUTER` - * @param array|Closure|string $table The table name + * @param Closure|array|string $table The table name * @param string|null $clause `ON`, `USING` or null for none - * @param array|Closure|null $expression Column(s) or subquery(ies) + * @param Closure|array|null $expression Column(s) or subquery(ies) * * @return string The JOIN conditional part */ private function renderJoinConditional( string $type, - array | Closure | string $table, + Closure | array | string $table, ?string $clause, Closure | array | null $expression ) : string { @@ -520,7 +520,7 @@ private function renderJoinType(string $type) : string * @param string $type `NATURAL`, `NATURAL LEFT`, `NATURAL LEFT OUTER`, * `NATURAL RIGHT`, `NATURAL RIGHT OUTER` or any other non-natural * @param string|null $clause Must be null if type is natural - * @param array|Closure|null $expression Must be null if type is natural + * @param Closure|array|null $expression Must be null if type is natural * * @throws InvalidArgumentException if $type is natural and has clause or expression * @@ -576,7 +576,7 @@ private function renderJoinConditionClause(?string $clause) : ?string * Renders the JOIN condition expression. * * @param string|null $clause `ON`or null - * @param array|Closure|null $expression Column(s) or subquery(ies) + * @param Closure|array|null $expression Column(s) or subquery(ies) * * @return string|null The condition or null if $clause is null */ diff --git a/src/Manipulation/Traits/Values.php b/src/Manipulation/Traits/Values.php index 34dddfd..99b397f 100644 --- a/src/Manipulation/Traits/Values.php +++ b/src/Manipulation/Traits/Values.php @@ -22,13 +22,13 @@ trait Values /** * Adds a row of values to the VALUES clause. * - * @param array>|Closure|float|int|string|null $value + * @param Closure|array>|float|int|string|null $value * @param Closure|float|int|string|null ...$values * * @return static */ public function values( - array | Closure | float | int | string | null $value, + Closure | array | float | int | string | null $value, Closure | float | int | string | null ...$values ) : static { if (!\is_array($value)) { diff --git a/src/Manipulation/Traits/Where.php b/src/Manipulation/Traits/Where.php index c0f70c4..0d0910c 100644 --- a/src/Manipulation/Traits/Where.php +++ b/src/Manipulation/Traits/Where.php @@ -22,17 +22,17 @@ trait Where /** * Appends an "AND $column $operator ...$values" condition in the WHERE clause. * - * @param array|Closure|string>|Closure|string $column Closure for a subquery, + * @param Closure|array|string>|string $column Closure for a subquery, * a string with the column name or an array with column names on WHERE MATCH clause * @param string $operator - * @param array|Closure|float|int|string|null>|Closure|float|int|string|null ...$values + * @param Closure|array|float|int|string|null>|float|int|string|null ...$values * * @return static */ public function where( - array | Closure | string $column, + Closure | array | string $column, string $operator, - array | Closure | float | int | string | null ...$values + Closure | array | float | int | string | null ...$values ) : static { // @phpstan-ignore-next-line return $this->addWhere('AND', $column, $operator, $values); @@ -41,17 +41,17 @@ public function where( /** * Appends a "OR $column $operator ...$values" condition in the WHERE clause. * - * @param array|Closure|string>|Closure|string $column Closure for a subquery, + * @param Closure|array|string>|string $column Closure for a subquery, * a string with the column name or an array with column names on WHERE MATCH clause * @param string $operator - * @param array|Closure|float|int|string|null>|Closure|float|int|string|null ...$values + * @param Closure|array|float|int|string|null>|float|int|string|null ...$values * * @return static */ public function orWhere( - array | Closure | string $column, + Closure | array | string $column, string $operator, - array | Closure | float | int | string | null ...$values + Closure | array | float | int | string | null ...$values ) : static { // @phpstan-ignore-next-line return $this->addWhere('OR', $column, $operator, $values); @@ -584,8 +584,8 @@ public function whereNotExists(Closure $subquery) * Appends an "AND MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext * searching in the WHERE clause. * - * @param array|Closure|string>|Closure|string $columns Columns to MATCH - * @param array|Closure|string>|Closure|string $against AGAINST expression + * @param Closure|array|string>|string $columns Columns to MATCH + * @param Closure|array|string>|string $against AGAINST expression * * @see https://mariadb.com/kb/en/full-text-index-overview/ * @see https://mariadb.com/kb/en/match-against/ @@ -593,8 +593,8 @@ public function whereNotExists(Closure $subquery) * @return static */ public function whereMatch( - array | Closure | string $columns, - array | Closure | string $against + Closure | array | string $columns, + Closure | array | string $against ) : static { return $this->where($columns, 'MATCH', $against); } @@ -603,8 +603,8 @@ public function whereMatch( * Appends a "OR MATCH (...$columns) AGAINST ($against IN NATURAL LANGUAGE MODE)" fulltext * searching in the WHERE clause. * - * @param array|Closure|string>|Closure|string $columns Columns to MATCH - * @param array|Closure|string>|Closure|string $against AGAINST expression + * @param Closure|array|string>|string $columns Columns to MATCH + * @param Closure|array|string>|string $against AGAINST expression * * @see https://mariadb.com/kb/en/full-text-index-overview/ * @see https://mariadb.com/kb/en/match-against/ @@ -612,8 +612,8 @@ public function whereMatch( * @return static */ public function orWhereMatch( - array | Closure | string $columns, - array | Closure | string $against + Closure | array | string $columns, + Closure | array | string $against ) : static { return $this->orWhere($columns, 'MATCH', $against); } @@ -622,8 +622,8 @@ public function orWhereMatch( * Appends an "AND MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext * searching in the WHERE clause. * - * @param array|Closure|string>|Closure|string $columns Columns to MATCH - * @param array|Closure|string>|Closure|string $against AGAINST expression + * @param Closure|array|string>|string $columns Columns to MATCH + * @param Closure|array|string>|string $against AGAINST expression * * @see https://mariadb.com/kb/en/full-text-index-overview/ * @see https://mariadb.com/kb/en/match-against/ @@ -631,8 +631,8 @@ public function orWhereMatch( * @return static */ public function whereMatchWithQueryExpansion( - array | Closure | string $columns, - array | Closure | string $against + Closure | array | string $columns, + Closure | array | string $against ) : static { return $this->where($columns, 'MATCH', $against, 'WITH QUERY EXPANSION'); } @@ -641,8 +641,8 @@ public function whereMatchWithQueryExpansion( * Appends a "OR MATCH (...$columns) AGAINST ($against WITH QUERY EXPANSION)" fulltext * searching in the WHERE clause. * - * @param array|Closure|string>|Closure|string $columns Columns to MATCH - * @param array|Closure|string>|Closure|string $against AGAINST expression + * @param Closure|array|string>|string $columns Columns to MATCH + * @param Closure|array|string>|string $against AGAINST expression * * @see https://mariadb.com/kb/en/full-text-index-overview/ * @see https://mariadb.com/kb/en/match-against/ @@ -650,8 +650,8 @@ public function whereMatchWithQueryExpansion( * @return static */ public function orWhereMatchWithQueryExpansion( - array | Closure | string $columns, - array | Closure | string $against + Closure | array | string $columns, + Closure | array | string $against ) : static { return $this->orWhere($columns, 'MATCH', $against, 'WITH QUERY EXPANSION'); } @@ -660,8 +660,8 @@ public function orWhereMatchWithQueryExpansion( * Appends an "AND MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in * the WHERE clause. * - * @param array|Closure|string>|Closure|string $columns Columns to MATCH - * @param array|Closure|string>|Closure|string $against AGAINST expression + * @param Closure|array|string>|string $columns Columns to MATCH + * @param Closure|array|string>|string $against AGAINST expression * * @see https://mariadb.com/kb/en/full-text-index-overview/ * @see https://mariadb.com/kb/en/match-against/ @@ -669,8 +669,8 @@ public function orWhereMatchWithQueryExpansion( * @return static */ public function whereMatchInBooleanMode( - array | Closure | string $columns, - array | Closure | string $against + Closure | array | string $columns, + Closure | array | string $against ) : static { return $this->where($columns, 'MATCH', $against, 'IN BOOLEAN MODE'); } @@ -679,8 +679,8 @@ public function whereMatchInBooleanMode( * Appends a "OR MATCH (...$columns) AGAINST ($against IN BOOLEAN MODE)" fulltext searching in * the WHERE clause. * - * @param array|Closure|string>|Closure|string $columns Columns to MATCH - * @param array|Closure|string>|Closure|string $against AGAINST expression + * @param Closure|array|string>|string $columns Columns to MATCH + * @param Closure|array|string>|string $against AGAINST expression * * @see https://mariadb.com/kb/en/full-text-index-overview/ * @see https://mariadb.com/kb/en/match-against/ @@ -688,8 +688,8 @@ public function whereMatchInBooleanMode( * @return static */ public function orWhereMatchInBooleanMode( - array | Closure | string $columns, - array | Closure | string $against + Closure | array | string $columns, + Closure | array | string $against ) : static { return $this->orWhere($columns, 'MATCH', $against, 'IN BOOLEAN MODE'); } @@ -698,7 +698,7 @@ public function orWhereMatchInBooleanMode( * Adds a WHERE (or HAVING) part. * * @param string $glue `AND` or `OR` - * @param array|Closure|string>|Closure|string $column + * @param Closure|array|string>|string $column * @param string $operator `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, `LIKE`, * `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`, `IS NULL`, `IS NOT NULL` or `MATCH` * @param array $values Values used by the operator @@ -708,7 +708,7 @@ public function orWhereMatchInBooleanMode( */ private function addWhere( string $glue, - array | Closure | string $column, + Closure | array | string $column, string $operator, array $values, string $clause = 'where' @@ -725,15 +725,15 @@ private function addWhere( /** * Renders a MATCH AGAINST clause. * - * @param array|Closure|string $columns - * @param array|Closure|string $expression + * @param Closure|array|string $columns + * @param Closure|array|string $expression * @param string $modifier * * @return string */ private function renderMatch( - array | Closure | string $columns, - array | Closure | string $expression, + Closure | array | string $columns, + Closure | array | string $expression, string $modifier = '' ) { $columns = $this->renderMatchColumns($columns); @@ -745,11 +745,11 @@ private function renderMatch( } /** - * @param array|Closure|string $columns + * @param Closure|array|string $columns * * @return string */ - private function renderMatchColumns(array | Closure | string $columns) : string + private function renderMatchColumns(Closure | array | string $columns) : string { if (\is_array($columns)) { foreach ($columns as &$column) { @@ -766,12 +766,12 @@ private function renderMatchColumns(array | Closure | string $columns) : string } /** - * @param array|Closure|string $expression + * @param Closure|array|string $expression * * @return float|int|string */ private function renderMatchExpression( - array | Closure | string $expression + Closure | array | string $expression ) : float | int | string { if (\is_array($expression)) { $expression = \implode(', ', $expression); @@ -926,7 +926,7 @@ private function renderWhereValues(string $operator, array $values) : ?string /** * Quote the input values or transform it in subqueries. * - * @param array $values + * @param array $values * * @return array Each input value quoted or transformed in subquery */ diff --git a/src/Manipulation/Update.php b/src/Manipulation/Update.php index fc757ca..1d31e67 100644 --- a/src/Manipulation/Update.php +++ b/src/Manipulation/Update.php @@ -63,14 +63,14 @@ protected function renderOptions() : ?string /** * Sets the table references. * - * @param array|Closure|string $reference - * @param array|Closure|string ...$references + * @param Closure|array|string $reference + * @param Closure|array|string ...$references * * @return static */ public function table( - array | Closure | string $reference, - array | Closure | string ...$references + Closure | array | string $reference, + Closure | array | string ...$references ) : static { $this->sql['table'] = []; foreach ([$reference, ...$references] as $reference) { @@ -151,7 +151,7 @@ public function sql() : string * * @return int|string The number of affected rows */ - public function run() : int|string + public function run() : int | string { return $this->database->exec($this->sql()); } diff --git a/src/PreparedStatement.php b/src/PreparedStatement.php index 131caae..59fb789 100644 --- a/src/PreparedStatement.php +++ b/src/PreparedStatement.php @@ -54,7 +54,7 @@ public function query(bool | float | int | string | null ...$params) : Result * * @return int|string */ - public function exec(bool | float | int | string | null ...$params) : int|string + public function exec(bool | float | int | string | null ...$params) : int | string { $this->bindParams($params); $this->statement->execute(); diff --git a/src/Result.php b/src/Result.php index ee2128a..d2d040b 100644 --- a/src/Result.php +++ b/src/Result.php @@ -126,7 +126,7 @@ public function setFetchClass(string $class, mixed ...$constructor) : static * * @return object|null */ - public function fetch(string $class = null, mixed ...$constructor) : object | null + public function fetch(?string $class = null, mixed ...$constructor) : ?object { $this->checkIsFree(); $class ??= $this->fetchClass; @@ -147,7 +147,7 @@ public function fetch(string $class = null, mixed ...$constructor) : object | nu * * @return array */ - public function fetchAll(string $class = null, mixed ...$constructor) : array + public function fetchAll(?string $class = null, mixed ...$constructor) : array { $this->checkIsFree(); $all = []; @@ -166,7 +166,7 @@ public function fetchAll(string $class = null, mixed ...$constructor) : array * * @return object */ - public function fetchRow(int $offset, string $class = null, mixed ...$constructor) : object + public function fetchRow(int $offset, ?string $class = null, mixed ...$constructor) : object { $this->checkIsFree(); $this->moveCursor($offset); @@ -178,7 +178,7 @@ public function fetchRow(int $offset, string $class = null, mixed ...$constructo * * @return array|null */ - public function fetchArray() : array | null + public function fetchArray() : ?array { $this->checkIsFree(); return $this->result->fetch_assoc(); // @phpstan-ignore-line diff --git a/src/Result/Explain.php b/src/Result/Explain.php index 5e8222a..5751c3d 100644 --- a/src/Result/Explain.php +++ b/src/Result/Explain.php @@ -42,20 +42,20 @@ /** * keys in table that could be used to find rows in the table. */ - public string | null $possibleKeys; + public ?string $possibleKeys; /** * The name of the key that is used to retrieve rows. NULL is no key was used. */ - public string | null $key; + public ?string $key; /** * How many bytes of the key that was used (shows if we are using only parts * of the multi-column key). */ - public string | null $keyLen; + public ?string $keyLen; /** * The reference that is used as the key value. */ - public string | null $ref; + public ?string $ref; /** * An estimate of how many rows we will find in the table for each key lookup. */ diff --git a/src/Statement.php b/src/Statement.php index 1942717..70cc5e4 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -48,7 +48,7 @@ public function __toString() : string * * @return static */ - public function reset(string $sql = null) : static + public function reset(?string $sql = null) : static { if ($sql === null) { unset($this->sql); diff --git a/tests/Manipulation/SelectTest.php b/tests/Manipulation/SelectTest.php index 71ea133..da10b7c 100644 --- a/tests/Manipulation/SelectTest.php +++ b/tests/Manipulation/SelectTest.php @@ -24,11 +24,11 @@ public function setup() : void } /** - * @param array|Closure|string ...$from + * @param Closure|array|string ...$from * * @return string */ - protected function selectAllFrom(array | Closure | string ...$from) : string + protected function selectAllFrom(Closure | array | string ...$from) : string { return $this->select->columns('*')->from(...$from)->sql(); } diff --git a/tests/Manipulation/StatementMock.php b/tests/Manipulation/StatementMock.php index 4618ac4..3eac148 100644 --- a/tests/Manipulation/StatementMock.php +++ b/tests/Manipulation/StatementMock.php @@ -25,7 +25,7 @@ public function subquery(Closure $subquery) : string * * @return static */ - public function limit(int $limit, int $offset = null) : static + public function limit(int $limit, ?int $offset = null) : static { return $this->setLimit($limit, $offset); } @@ -40,7 +40,7 @@ public function renderIdentifier(Closure | string $column) : string return parent::renderIdentifier($column); } - public function renderAliasedIdentifier(array | Closure | string $column) : string + public function renderAliasedIdentifier(Closure | array | string $column) : string { return parent::renderAliasedIdentifier($column); }