diff --git a/analyzer-baseline.toml b/analyzer-baseline.toml index 3722155c..f94309d3 100644 --- a/analyzer-baseline.toml +++ b/analyzer-baseline.toml @@ -1752,84 +1752,18 @@ code = "missing-api-or-internal" message = 'Abstract class `PhpDb\Sql\AbstractPreparableSql` is missing an `@api` or `@internal` annotation.' count = 1 -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "imprecise-type" -message = "Type `array` in parameter `$column` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "imprecise-type" -message = "Type `array` in parameter `$parameters` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "imprecise-type" -message = "Type `array` in parameter `$specifications` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "imprecise-type" -message = "Type `array` in property `$instanceParameterIndex` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/AbstractSql.php" code = "imprecise-type" message = "Type `array` in return type of `resolveTable` is imprecise, equivalent to `array`." count = 1 -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "invalid-iterator" -message = "The expression provided to `foreach` is not iterable. It resolved to type `mixed`, which is not iterable." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "invalid-operand" -message = "Invalid type for left operand." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but provided type `array-key|null` is less specific.' -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #3 of `PhpDb\Sql\AbstractSql::processExpressionOrSelect`: expected `int`, but provided type `array-key` is less specific.' -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #2 of `implode`: expected `array|null`, but provided type `array` is less specific." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #2 of `vsprintf`: expected `array`, but provided type `array` is less specific." -count = 1 - [[issues]] file = "src/Sql/AbstractSql.php" code = "less-specific-nested-argument-type" message = "Argument type mismatch for argument #2 of `vsprintf`: expected `array`, but provided type `array|list{mixed}` is less specific." count = 1 -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #2 of `vsprintf`: expected `array`, but provided type `list` is less specific." -count = 1 - [[issues]] file = "src/Sql/AbstractSql.php" code = "missing-api-or-internal" @@ -1838,134 +1772,68 @@ count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifierInFragment`: expected `string`, but found `mixed`.' -count = 2 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifierInFragment`: expected `string`, but found `nonnull`.' -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteValue`: expected `string`, but found `nonnull`.' -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `count`: expected `Countable|array`, but found `mixed`." +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 2 [[issues]] file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `implode`: expected `array|string`, but found `nonnull`." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `strtoupper`: expected `string`, but found `mixed`." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `vsprintf`: expected `string`, but found `mixed`." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `vsprintf`: expected `string`, but found `nonnull`." -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = "Invalid argument type for argument #2 of `vsprintf`: expected `array`, but found `mixed`." +code = "overly-wide-return-type" +message = "Declared return type `array|null|string` for `resolvetable` has unused branches: `array`." count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #3 of `PhpDb\Sql\AbstractSql::processExpressionParameterName`: expected `int`, but found `nonnull`.' +code = "overly-wide-return-type" +message = "Declared return type `null|string` for `processexpressionparametername` has unused branches: `null`." count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "mixed-array-access" -message = "Unsafe array access on type `mixed`." -count = 4 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 11 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-assignment" -message = "Assigning `nonnull` type to a variable may lead to unexpected behavior." -count = 2 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "mixed-operand" -message = "Casting `mixed` to `bool`." +code = "possibly-false-argument" +message = 'Argument #1 of method `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier` is possibly `false`, but parameter type `string` does not accept it.' count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "mixed-operand" -message = "Invalid left operand: type `nonnull` cannot be reliably used in string concatenation." +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifierInFragment`: expected `string`, but possibly received `bool|int|string`.' count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "mixed-operand" -message = "Invalid middle operand: type `mixed` cannot be reliably used in string concatenation." +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteValue`: expected `string`, but possibly received `bool|int|string`.' count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "non-iterable-object-iteration" -message = 'Iterating over object of type `PhpDb\Sql\ExpressionInterface` which does not implement `Iterator` or `IteratorAggregate`.' +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #1 of `count`: expected `Countable|array`, but possibly received `array|string>|string`." count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "non-iterable-object-iteration" -message = 'Iterating over object of type `PhpDb\Sql\SqlInterface` which does not implement `Iterator` or `IteratorAggregate`.' +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #2 of `vsprintf`: expected `array`, but possibly received `array|string>|string>`." count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "overly-wide-return-type" -message = "Declared return type `array|null|string` for `resolvetable` has unused branches: `array`." +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #2 of `vsprintf`: expected `array`, but possibly received `array|string>|string`." count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "overly-wide-return-type" -message = "Declared return type `null|string` for `processexpressionparametername` has unused branches: `null`." +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #2 of `vsprintf`: expected `array`, but possibly received `list|string>|string>`." count = 1 [[issues]] file = "src/Sql/AbstractSql.php" code = "possibly-invalid-iterator" -message = 'The expression provided to `foreach` (type `PhpDb\Sql\ExpressionInterface|PhpDb\Sql\SqlInterface|array|null|scalar`) might not be iterable at runtime.' +message = "The expression provided to `foreach` (type `array|string>|string`) might not be iterable at runtime." count = 1 [[issues]] @@ -1994,14 +1862,14 @@ count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "possibly-null-iterator" -message = 'Expression being iterated (type `PhpDb\Sql\ExpressionInterface|PhpDb\Sql\SqlInterface|array|null|scalar`) might be `null` at runtime.' +code = "redundant-cast" +message = "Redundant cast to `(bool)`: the expression already has this type." count = 1 [[issues]] file = "src/Sql/AbstractSql.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('column')` accessed on `array`." +code = "redundant-cast" +message = "Redundant cast to `(string)`: the expression already has this type." count = 1 [[issues]] @@ -2022,24 +1890,6 @@ code = "unhandled-thrown-type" message = 'Potentially unhandled exception `PhpDb\Sql\Exception\RuntimeException` in `PhpDb\Sql\AbstractSql::buildSqlString`.' count = 1 -[[issues]] -file = "src/Sql/Argument.php" -code = "imprecise-type" -message = "Type `array` in parameter `$values` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Argument.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Argument\Values::__construct`: expected `list`, but possibly received `array`.' -count = 1 - -[[issues]] -file = "src/Sql/ArgumentInterface.php" -code = "imprecise-type" -message = "Type `array` in return type of `getValue` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/ArgumentInterface.php" code = "missing-api-or-internal" @@ -2096,20 +1946,14 @@ count = 1 [[issues]] file = "src/Sql/Combine.php" -code = "imprecise-type" -message = "Type `array` in parameter `$select` is imprecise, equivalent to `array`." -count = 5 - -[[issues]] -file = "src/Sql/Combine.php" -code = "incompatible-property-type" -message = 'Property `PhpDb\Sql\Combine::$specifications` has an incompatible type declaration from docblock.' +code = "invalid-array-element" +message = "Cannot use spread operator on non-iterable type `mixed`." count = 1 [[issues]] file = "src/Sql/Combine.php" -code = "invalid-array-element" -message = "Cannot use spread operator on non-iterable type `mixed`." +code = "less-specific-nested-argument-type" +message = 'Argument type mismatch for argument #1 of `PhpDb\Sql\Select::columns`: expected `array`, but provided type `array` is less specific.' count = 1 [[issues]] @@ -2142,40 +1986,16 @@ code = "missing-constant-type" message = "Class constant `COMBINE` is missing a type hint." count = 1 -[[issues]] -file = "src/Sql/Combine.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Combine::combine`: expected `PhpDb\Sql\Select|array`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Combine.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #2 of `PhpDb\Sql\Combine::combine`: expected `string`, but found `nonnull`.' -count = 1 - -[[issues]] -file = "src/Sql/Combine.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #3 of `PhpDb\Sql\Combine::combine`: expected `string`, but found `nonnull`.' -count = 1 - -[[issues]] -file = "src/Sql/Combine.php" -code = "mixed-array-access" -message = "Unsafe array access on type `mixed`." -count = 1 - [[issues]] file = "src/Sql/Combine.php" code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 2 +count = 1 [[issues]] file = "src/Sql/Combine.php" -code = "possible-method-access-on-null" -message = "Attempting to call a method on `null`." +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #3 of `str_replace`: expected `array|string`, but possibly received `array|null>>|null|string`." count = 1 [[issues]] @@ -2186,20 +2006,20 @@ count = 1 [[issues]] file = "src/Sql/Combine.php" -code = "possibly-null-array-access" -message = "Cannot perform array access on possibly `null` value." +code = "possibly-undefined-string-array-index" +message = "Possibly undefined array key `string('combine')` accessed on `array|null>>|string>`." count = 1 [[issues]] file = "src/Sql/Combine.php" -code = "possibly-undefined-int-array-index" -message = '''Possibly undefined array key `int(0)` accessed on `non-empty-array`.''' +code = "undefined-int-array-index" +message = 'Undefined list index `1` accessed on `list{PhpDb\Sql\Select}`.' count = 1 [[issues]] file = "src/Sql/Combine.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('combine')` accessed on `array`." +code = "undefined-int-array-index" +message = 'Undefined list index `2` accessed on `list{PhpDb\Sql\Select}`.' count = 1 [[issues]] @@ -2208,60 +2028,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Ddl\AlterTable` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in parameter `$options` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in property `$addColumns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in property `$addConstraints` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in property `$changeColumns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in property `$dropColumns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in property `$dropConstraints` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in property `$dropIndexes` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in property `$options` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `getOptions` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/AlterTable.php" code = "imprecise-type" @@ -2270,74 +2036,38 @@ count = 1 [[issues]] file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `processAddColumns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `processAddConstraints` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `processChangeColumns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `processDropColumns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `processDropConstraints` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `processDropIndexes` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "invalid-property-default-value" -message = 'Default value for property `PhpDb\Sql\Ddl\AlterTable::$specifications` is not assignable to its declared type.' +code = "invalid-return-statement" +message = '''Invalid return type for function `PhpDb\Sql\Ddl\AlterTable::getRawState`: expected `array|string`, but found `PhpDb\Sql\TableIdentifier|array|array{'addColumns': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|bool|int|list|string, 'addConstraints': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|bool|int|list|string, 'changeColumns': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|array|bool|int|string, 'dropColumns': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|bool|int|list|string, 'dropConstraints': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|bool|int|list|string, 'dropIndexes': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|bool|int|list|string, 'table': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|PhpDb\Sql\TableIdentifier|bool|int|string, 'tableOptions': PhpDb\Sql\Ddl\Column\ColumnInterface|PhpDb\Sql\Literal|array|bool|int|string}|list|string`.''' count = 1 [[issues]] file = "src/Sql/Ddl/AlterTable.php" code = "invalid-return-statement" -message = '''Invalid return type for function `PhpDb\Sql\Ddl\AlterTable::getRawState`: expected `array|string`, but found `PhpDb\Sql\TableIdentifier|array|array{'addColumns': mixed, 'addConstraints': mixed, 'changeColumns': mixed, 'dropColumns': mixed, 'dropConstraints': mixed, 'dropIndexes': mixed, 'table': mixed, 'tableOptions': mixed}|string`.''' +message = 'Invalid return type for function `PhpDb\Sql\Ddl\AlterTable::processTable`: expected `array`, but found `list{array|null|string}`.' count = 1 [[issues]] file = "src/Sql/Ddl/AlterTable.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `PhpDb\Sql\Ddl\AlterTable::processTable`: expected `array`, but found `list{array|null|string}`.' +code = "less-specific-nested-return-statement" +message = '''Returned type `list{list}` is less specific than the declared return type `array{0: list}` for function `PhpDb\Sql\Ddl\AlterTable::processChangeColumns` due to nested 'mixed'.''' count = 1 [[issues]] file = "src/Sql/Ddl/AlterTable.php" -code = "invalid-return-tag" -message = "Failed to resolve `@return` type string." -count = 6 +code = "less-specific-nested-return-statement" +message = '''Returned type `list{list}` is less specific than the declared return type `array{0: list}` for function `PhpDb\Sql\Ddl\AlterTable::processDropColumns` due to nested 'mixed'.''' +count = 1 [[issues]] file = "src/Sql/Ddl/AlterTable.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but provided type `array-key` is less specific.' +code = "less-specific-nested-return-statement" +message = '''Returned type `list{list}` is less specific than the declared return type `array{0: list}` for function `PhpDb\Sql\Ddl\AlterTable::processDropConstraints` due to nested 'mixed'.''' count = 1 [[issues]] file = "src/Sql/Ddl/AlterTable.php" -code = "less-specific-argument" -message = "Argument type mismatch for argument #1 of `strtoupper`: expected `string`, but provided type `array-key` is less specific." +code = "less-specific-nested-return-statement" +message = '''Returned type `list{list}` is less specific than the declared return type `array{0: list}` for function `PhpDb\Sql\Ddl\AlterTable::processDropIndexes` due to nested 'mixed'.''' count = 1 [[issues]] @@ -2388,29 +2118,11 @@ code = "missing-constant-type" message = "Class constant `TABLE` is missing a type hint." count = 1 -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but found `mixed`.' -count = 3 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteTrustedValue`: expected `bool|float|int|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Ddl/AlterTable.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::processExpression`: expected `PhpDb\Sql\ExpressionInterface`, but found `mixed`.' -count = 3 - [[issues]] file = "src/Sql/Ddl/AlterTable.php" code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 8 +count = 1 [[issues]] file = "src/Sql/Ddl/AlterTable.php" @@ -2430,24 +2142,12 @@ code = "possibly-null-argument" message = 'Argument #2 of method `PhpDb\Sql\AbstractSql::resolveTable` is possibly `null`, but parameter type `PhpDb\Adapter\Platform\PlatformInterface` does not accept it.' count = 1 -[[issues]] -file = "src/Sql/Ddl/Column/AbstractLengthColumn.php" -code = "imprecise-type" -message = "Type `array` in parameter `$options` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/Column/AbstractLengthColumn.php" code = "missing-api-or-internal" message = 'Abstract class `PhpDb\Sql\Ddl\Column\AbstractLengthColumn` is missing an `@api` or `@internal` annotation.' count = 1 -[[issues]] -file = "src/Sql/Ddl/Column/AbstractPrecisionColumn.php" -code = "imprecise-type" -message = "Type `array` in parameter `$options` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/Column/AbstractPrecisionColumn.php" code = "missing-api-or-internal" @@ -2490,24 +2190,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Ddl\Column\Char` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Ddl/Column/Column.php" -code = "imprecise-type" -message = "Type `array` in parameter `$options` is imprecise, equivalent to `array`." -count = 2 - -[[issues]] -file = "src/Sql/Ddl/Column/Column.php" -code = "imprecise-type" -message = "Type `array` in property `$options` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/Column/Column.php" -code = "imprecise-type" -message = "Type `array` in return type of `getOptions` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/Column/Column.php" code = "mixed-argument" @@ -2526,12 +2208,6 @@ code = "uninitialized-property" message = 'Property `$default` is not initialized in the constructor of class `PhpDb\Sql\Ddl\Column\Column`.' count = 1 -[[issues]] -file = "src/Sql/Ddl/Column/ColumnInterface.php" -code = "imprecise-type" -message = "Type `array` in return type of `getOptions` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/Column/ColumnInterface.php" code = "missing-api-or-internal" @@ -2610,24 +2286,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Ddl\Column\Varchar` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Ddl/Constraint/AbstractConstraint.php" -code = "imprecise-type" -message = "Type `array` in parameter `$columns` is imprecise, equivalent to `array`." -count = 2 - -[[issues]] -file = "src/Sql/Ddl/Constraint/AbstractConstraint.php" -code = "imprecise-type" -message = "Type `array` in property `$columns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/Constraint/AbstractConstraint.php" -code = "imprecise-type" -message = "Type `array` in return type of `getColumns` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/Constraint/AbstractConstraint.php" code = "missing-api-or-internal" @@ -2636,14 +2294,14 @@ count = 1 [[issues]] file = "src/Sql/Ddl/Constraint/AbstractConstraint.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Argument\Identifier::__construct`: expected `string`, but found `mixed`.' +code = "possibly-null-argument" +message = 'Argument #1 of method `PhpDb\Sql\Argument\Identifier::__construct` is possibly `null`, but parameter type `string` does not accept it.' count = 1 [[issues]] file = "src/Sql/Ddl/Constraint/AbstractConstraint.php" code = "possibly-undefined-int-array-index" -message = "Possibly undefined array key `non-negative-int` accessed on `array`." +message = "Possibly undefined array index accessed on `list`." count = 1 [[issues]] @@ -2652,12 +2310,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Ddl\Constraint\Check` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Ddl/Constraint/ConstraintInterface.php" -code = "imprecise-type" -message = "Type `array` in return type of `getColumns` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/Constraint/ConstraintInterface.php" code = "missing-api-or-internal" @@ -2670,18 +2322,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Ddl\Constraint\ForeignKey` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Ddl/Constraint/ForeignKey.php" -code = "imprecise-type" -message = "Type `array` in parameter `$columns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/Constraint/ForeignKey.php" -code = "imprecise-type" -message = "Type `array` in return type of `getReferenceColumn` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/Constraint/ForeignKey.php" code = "possibly-undefined-int-array-index" @@ -2712,36 +2352,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Ddl\CreateTable` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "imprecise-type" -message = "Type `array` in parameter `$options` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "imprecise-type" -message = "Type `array` in property `$columns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "imprecise-type" -message = "Type `array` in property `$constraints` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "imprecise-type" -message = "Type `array` in property `$options` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "imprecise-type" -message = "Type `array` in return type of `getOptions` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Ddl/CreateTable.php" code = "invalid-operand" @@ -2756,14 +2366,14 @@ count = 1 [[issues]] file = "src/Sql/Ddl/CreateTable.php" -code = "invalid-property-default-value" -message = 'Default value for property `PhpDb\Sql\Ddl\CreateTable::$specifications` is not assignable to its declared type.' +code = "invalid-return-statement" +message = '''Invalid return type for function `PhpDb\Sql\Ddl\CreateTable::getRawState`: expected `array|string>|string`, but found `PhpDb\Sql\TableIdentifier|array|array{'columns': PhpDb\Sql\Literal|bool|int|list|string, 'constraints': PhpDb\Sql\Literal|bool|int|list|string, 'table': PhpDb\Sql\Literal|PhpDb\Sql\TableIdentifier|bool|int|string, 'tableOptions': PhpDb\Sql\Literal|array|bool|int|string}|list|string`.''' count = 1 [[issues]] file = "src/Sql/Ddl/CreateTable.php" code = "invalid-return-statement" -message = 'Invalid return type for function `PhpDb\Sql\Ddl\CreateTable::processCombinedby`: expected `null|string`, but found `array|null|string`.' +message = 'Invalid return type for function `PhpDb\Sql\Ddl\CreateTable::processCombinedby`: expected `null|string`, but found `array|null>>|null|string`.' count = 1 [[issues]] @@ -2772,18 +2382,6 @@ code = "invalid-return-statement" message = '''Invalid return type for function `PhpDb\Sql\Ddl\CreateTable::processTable`: expected `array`, but found `list{string('')|string('TEMPORARY '), string('')|string('IF NOT EXISTS '), array|null|string}`.''' count = 1 -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "less-specific-argument" -message = "Argument type mismatch for argument #1 of `strtoupper`: expected `string`, but provided type `array-key` is less specific." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "less-specific-nested-return-statement" -message = '''Returned type `PhpDb\Sql\TableIdentifier|array|array{'columns': mixed, 'constraints': mixed, 'table': mixed, 'tableOptions': mixed}|string` is less specific than the declared return type `array|string>|string` for function `PhpDb\Sql\Ddl\CreateTable::getRawState` due to nested 'mixed'.''' -count = 1 - [[issues]] file = "src/Sql/Ddl/CreateTable.php" code = "missing-constant-type" @@ -2808,23 +2406,11 @@ code = "missing-constant-type" message = "Class constant `TABLE` is missing a type hint." count = 1 -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteTrustedValue`: expected `bool|float|int|string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::processExpression`: expected `PhpDb\Sql\ExpressionInterface`, but found `mixed`.' -count = 2 - [[issues]] file = "src/Sql/Ddl/CreateTable.php" code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 4 +count = 1 [[issues]] file = "src/Sql/Ddl/CreateTable.php" @@ -2847,13 +2433,7 @@ count = 1 [[issues]] file = "src/Sql/Ddl/CreateTable.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('combinedBy')` accessed on `array>`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/CreateTable.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('combinedBy')` accessed on `array`." +message = "Possibly undefined array key `string('combinedBy')` accessed on `array|null>>|string>`." count = 1 [[issues]] @@ -2900,32 +2480,14 @@ count = 1 [[issues]] file = "src/Sql/Ddl/Index/Index.php" -code = "imprecise-type" -message = "Type `array` in parameter `$columns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/Index/Index.php" -code = "imprecise-type" -message = "Type `array` in parameter `$lengths` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/Index/Index.php" -code = "imprecise-type" -message = "Type `array` in property `$lengths` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Ddl/Index/Index.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Argument\Identifier::__construct`: expected `string`, but found `mixed`.' +code = "possibly-null-argument" +message = 'Argument #1 of method `PhpDb\Sql\Argument\Identifier::__construct` is possibly `null`, but parameter type `string` does not accept it.' count = 1 [[issues]] file = "src/Sql/Ddl/Index/Index.php" code = "possibly-undefined-int-array-index" -message = "Possibly undefined array key `non-negative-int` accessed on `array`." +message = "Possibly undefined array index accessed on `list`." count = 1 [[issues]] @@ -2940,24 +2502,6 @@ code = "impossible-null-type-comparison" message = 'Impossible condition: variable `$this->where` (type `PhpDb\Sql\Where`) will always be `null`.' count = 1 -[[issues]] -file = "src/Sql/Delete.php" -code = "imprecise-type" -message = "Type `array` in parameter `$predicate` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Delete.php" -code = "imprecise-type" -message = "Type `array` in parameter `$table` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Delete.php" -code = "imprecise-type" -message = "Type `array` in property `$table` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Delete.php" code = "invalid-return-statement" @@ -2976,12 +2520,6 @@ code = "less-specific-nested-argument-type" message = "Argument type mismatch for argument #2 of `str_replace`: expected `array|string`, but provided type `array|null|string` is less specific." count = 1 -[[issues]] -file = "src/Sql/Delete.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #3 of `str_replace`: expected `array|string`, but provided type `array|null|string` is less specific." -count = 2 - [[issues]] file = "src/Sql/Delete.php" code = "missing-constant-type" @@ -2997,9 +2535,15 @@ count = 1 [[issues]] file = "src/Sql/Delete.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::resolveTable`: expected `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::resolveTable`: expected `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' count = 1 +[[issues]] +file = "src/Sql/Delete.php" +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #3 of `str_replace`: expected `array|string`, but possibly received `array|null>>|null|string`." +count = 2 + [[issues]] file = "src/Sql/Delete.php" code = "possibly-null-argument" @@ -3015,25 +2559,13 @@ count = 2 [[issues]] file = "src/Sql/Delete.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('delete')` accessed on `array>`." -count = 1 - -[[issues]] -file = "src/Sql/Delete.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('delete')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Sql/Delete.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('where')` accessed on `array>`." +message = "Possibly undefined array key `string('delete')` accessed on `array|null>>|string>`." count = 1 [[issues]] file = "src/Sql/Delete.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('where')` accessed on `array`." +message = "Possibly undefined array key `string('where')` accessed on `array|null>>|string>`." count = 1 [[issues]] @@ -3049,51 +2581,27 @@ message = "Redundant `||` operation: left operand is always false and right oper count = 1 [[issues]] -file = "src/Sql/Delete.php" -code = "redundant-null-coalesce" -message = "Redundant null coalesce: left-hand side can never be `null` or undefined." -count = 1 - -[[issues]] -file = "src/Sql/Expression.php" -code = "imprecise-type" -message = "Type `array` in parameter `$parameters` is imprecise, equivalent to `array`." -count = 2 - -[[issues]] -file = "src/Sql/Expression.php" -code = "imprecise-type" -message = "Type `array` in return type of `getParameters` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Expression.php" -code = "missing-constant-type" -message = "Class constant `PLACEHOLDER` is missing a type hint." -count = 1 - -[[issues]] -file = "src/Sql/Expression.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Argument\Value::__construct`: expected `bool|float|int|null|string`, but found `mixed`.' +file = "src/Sql/Delete.php" +code = "redundant-null-coalesce" +message = "Redundant null coalesce: left-hand side can never be `null` or undefined." count = 1 [[issues]] file = "src/Sql/Expression.php" -code = "mixed-argument" -message = "Invalid argument type for argument #4 of `str_replace`: expected `int|null`, but found `mixed`." +code = "less-specific-nested-argument-type" +message = 'Argument type mismatch for argument #1 of `PhpDb\Sql\Expression::setParameters`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|array|null|scalar>|list|null|scalar`, but provided type `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|array|list|null|scalar` is less specific.' count = 1 [[issues]] file = "src/Sql/Expression.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +code = "missing-constant-type" +message = "Class constant `PLACEHOLDER` is missing a type hint." count = 1 [[issues]] file = "src/Sql/Expression.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Argument\Values::__construct`: expected `list`, but possibly received `array`.' +code = "mixed-argument" +message = "Invalid argument type for argument #4 of `str_replace`: expected `int|null`, but found `mixed`." count = 1 [[issues]] @@ -3132,48 +2640,12 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Having` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Insert.php" -code = "imprecise-type" -message = "Type `array` in parameter `$array` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Insert.php" -code = "imprecise-type" -message = "Type `array` in parameter `$columns` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Insert.php" -code = "imprecise-type" -message = "Type `array` in parameter `$table` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Insert.php" -code = "imprecise-type" -message = "Type `array` in parameter `$values` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Insert.php" -code = "imprecise-type" -message = "Type `array` in property `$columns` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Insert.php" code = "imprecise-type" message = "Type `array` in property `$select` is imprecise, equivalent to `array`." count = 1 -[[issues]] -file = "src/Sql/Insert.php" -code = "imprecise-type" -message = "Type `array` in property `$table` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Insert.php" code = "imprecise-type" @@ -3204,24 +2676,12 @@ code = "less-specific-argument" message = 'Argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but provided type `array-key` is less specific.' count = 1 -[[issues]] -file = "src/Sql/Insert.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #1 of `array_flip`: expected `array`, but provided type `array` is less specific." -count = 1 - [[issues]] file = "src/Sql/Insert.php" code = "less-specific-nested-argument-type" message = "Argument type mismatch for argument #2 of `implode`: expected `array|null`, but provided type `non-empty-list` is less specific." count = 1 -[[issues]] -file = "src/Sql/Insert.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #3 of `str_replace`: expected `array|string`, but provided type `array|null|string` is less specific." -count = 2 - [[issues]] file = "src/Sql/Insert.php" code = "missing-constant-type" @@ -3261,7 +2721,7 @@ count = 1 [[issues]] file = "src/Sql/Insert.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::resolveColumnValue`: expected `PhpDb\Sql\ExpressionInterface|PhpDb\Sql\Select|array|bool|int|null|string`, but found `mixed`.' +message = '''Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::resolveColumnValue`: expected `PhpDb\Sql\ExpressionInterface|PhpDb\Sql\Select|array{'column': PhpDb\Sql\ExpressionInterface|PhpDb\Sql\Select|bool|int|null|string, 'fromTable'?: string, 'isIdentifier'?: bool}|bool|int|null|string`, but found `mixed`.''' count = 1 [[issues]] @@ -3291,7 +2751,7 @@ count = 1 [[issues]] file = "src/Sql/Insert.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::resolveTable`: expected `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::resolveTable`: expected `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' count = 2 [[issues]] @@ -3314,38 +2774,26 @@ count = 1 [[issues]] file = "src/Sql/Insert.php" -code = "possibly-null-argument" -message = "Argument #3 of function `str_replace` is possibly `null`, but parameter type `array|string` does not accept it." +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #3 of `str_replace`: expected `array|string`, but possibly received `array|null>>|null|string`." count = 2 [[issues]] file = "src/Sql/Insert.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('insert')` accessed on `array>`." -count = 1 - -[[issues]] -file = "src/Sql/Insert.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('insert')` accessed on `array`." -count = 1 +code = "possibly-null-argument" +message = "Argument #3 of function `str_replace` is possibly `null`, but parameter type `array|string` does not accept it." +count = 2 [[issues]] file = "src/Sql/Insert.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('select')` accessed on `array>`." +message = "Possibly undefined array key `string('insert')` accessed on `array|null>>|string>`." count = 1 [[issues]] file = "src/Sql/Insert.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('select')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Sql/Insert.php" -code = "template-constraint-violation" -message = "Argument type mismatch for template `V`." +message = "Possibly undefined array key `string('select')` accessed on `array|null>>|string>`." count = 1 [[issues]] @@ -3362,20 +2810,8 @@ count = 1 [[issues]] file = "src/Sql/Join.php" -code = "imprecise-type" -message = "Type `array` in property `$joins` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Join.php" -code = "imprecise-type" -message = "Type `array` in return type of `current` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Join.php" -code = "imprecise-type" -message = "Type `array` in return type of `getJoins` is imprecise, equivalent to `array`." +code = "invalid-return-statement" +message = '''Invalid return type for function `PhpDb\Sql\Join::current`: expected `array{'columns': array, 'name': PhpDb\Sql\TableIdentifier|non-empty-array|string, 'on': PhpDb\Sql\Predicate\PredicateInterface|string, 'type': string}`, but found `array{'columns': array, 'name': PhpDb\Sql\TableIdentifier|non-empty-array|string, 'on': PhpDb\Sql\Predicate\PredicateInterface|string, 'type': string}|null`.''' count = 1 [[issues]] @@ -3422,26 +2858,20 @@ count = 1 [[issues]] file = "src/Sql/Join.php" -code = "missing-template-parameter" -message = "Too few template arguments for `Iterator`: expected at least 2, but found 0." -count = 1 - -[[issues]] -file = "src/Sql/Join.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Exception\InvalidArgumentException::forInvalidJoinName`: expected `string`, but found `mixed`.' +code = "nullable-return-statement" +message = '''Function `PhpDb\Sql\Join::current` is declared to return `array{'columns': array, 'name': PhpDb\Sql\TableIdentifier|non-empty-array|string, 'on': PhpDb\Sql\Predicate\PredicateInterface|string, 'type': string}` but possibly returns a nullable value (inferred as `array{'columns': array, 'name': PhpDb\Sql\TableIdentifier|non-empty-array|string, 'on': PhpDb\Sql\Predicate\PredicateInterface|string, 'type': string}|null`).''' count = 1 [[issues]] file = "src/Sql/Join.php" -code = "mixed-return-statement" -message = 'Could not infer a precise return type for function `PhpDb\Sql\Join::current`. Saw type `mixed`.' +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Exception\InvalidArgumentException::forInvalidJoinName`: expected `string`, but possibly received `PhpDb\Sql\Expression|PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|string`.' count = 1 [[issues]] file = "src/Sql/Join.php" code = "possibly-undefined-int-array-index" -message = "Possibly undefined array key `int` accessed on `array`." +message = '''Possibly undefined array index accessed on `list, 'name': PhpDb\Sql\TableIdentifier|non-empty-array|string, 'on': PhpDb\Sql\Predicate\PredicateInterface|string, 'type': string}>`.''' count = 1 [[issues]] @@ -3588,18 +3018,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Predicate\Expression` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Predicate/In.php" -code = "imprecise-type" -message = "Type `array` in parameter `$valueSet` is imprecise, equivalent to `array`." -count = 2 - -[[issues]] -file = "src/Sql/Predicate/In.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Argument\Values::__construct`: expected `list`, but possibly received `array`.' -count = 1 - [[issues]] file = "src/Sql/Predicate/IsNotNull.php" code = "class-must-be-final" @@ -3756,6 +3174,12 @@ code = "invalid-property-assignment-value" message = 'Invalid type for property `$unnest`: expected `PhpDb\Sql\Predicate\Predicate`, but got `null`.' count = 1 +[[issues]] +file = "src/Sql/Predicate/Predicate.php" +code = "less-specific-nested-argument-type" +message = 'Argument type mismatch for argument #2 of `PhpDb\Sql\Expression::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|array|null|scalar>|list|null|scalar`, but provided type `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|float|int|non-empty-array|null|string` is less specific.' +count = 1 + [[issues]] file = "src/Sql/Predicate/Predicate.php" code = "possibly-invalid-argument" @@ -3792,6 +3216,12 @@ code = "possibly-invalid-argument" message = 'Possible argument type mismatch for argument #2 of `PhpDb\Sql\Predicate\Between::__construct`: expected `PhpDb\Sql\ArgumentInterface|float|int|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|array|float|int|null|string`.' count = 2 +[[issues]] +file = "src/Sql/Predicate/Predicate.php" +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #2 of `PhpDb\Sql\Predicate\In::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\Select|list|null`, but possibly received `PhpDb\Sql\ArgumentInterface|array`.' +count = 2 + [[issues]] file = "src/Sql/Predicate/Predicate.php" code = "possibly-invalid-argument" @@ -3804,52 +3234,10 @@ code = "missing-api-or-internal" message = 'Interface `PhpDb\Sql\Predicate\PredicateInterface` is missing an `@api` or `@internal` annotation.' count = 1 -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "imprecise-type" -message = "Type `array` in parameter `$predicates` is imprecise, equivalent to `array`." -count = 2 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "imprecise-type" -message = "Type `array` in property `$predicates` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "imprecise-type" -message = "Type `array` in return type of `getPredicates` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "invalid-destructuring-source" -message = "Invalid destructuring assignment: Cannot unpack type `mixed` into variables." -count = 2 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "invalid-iterator" -message = "The expression provided to `foreach` is not iterable. It resolved to type `mixed`, which is not iterable." -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #2 of `implode`: expected `array|null`, but provided type `list` is less specific." -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "less-specific-nested-return-statement" -message = '''Returned type `array{'spec': non-empty-string, 'values': mixed}` is less specific than the declared return type `array{'spec': string, 'values': array}` for function `PhpDb\Sql\Predicate\PredicateSet::getExpressionData` due to nested 'mixed'.''' -count = 1 - [[issues]] file = "src/Sql/Predicate/PredicateSet.php" code = "less-specific-nested-return-statement" -message = '''Returned type `array{'spec': string, 'values': list}` is less specific than the declared return type `array{'spec': string, 'values': array}` for function `PhpDb\Sql\Predicate\PredicateSet::getExpressionData` due to nested 'mixed'.''' +message = '''Returned type `array{'spec': non-empty-string, 'values': mixed}` is less specific than the declared return type `array{'spec': string, 'values': list}` for function `PhpDb\Sql\Predicate\PredicateSet::getExpressionData` due to nested 'mixed'.''' count = 1 [[issues]] @@ -3877,219 +3265,111 @@ message = "Class constant `OP_OR` is missing a type hint." count = 1 [[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Expression::__construct`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Literal::__construct`: expected `string`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Predicate\PredicateSet::addPredicate`: expected `PhpDb\Sql\Predicate\PredicateInterface`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `str_contains`: expected `string`, but found `mixed`." -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #2 of `PhpDb\Sql\Expression::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|array|null|scalar`, but found `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #3 of `PhpDb\Sql\Predicate\Operator::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|PhpDb\Sql\SqlInterface|null|scalar`, but found `nonnull`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-array-access" -message = "Unsafe array access on type `mixed`." -count = 5 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 11 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-method-access" -message = "Attempting to access a method on a non-object type (`mixed`)." -count = 2 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "mixed-return-statement" -message = 'Could not infer a precise return type for function `PhpDb\Sql\Predicate\PredicateSet::getExpressionData`. Saw type `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Predicate\PredicateSet::addPredicate`: expected `PhpDb\Sql\Predicate\PredicateInterface`, but possibly received `PhpDb\Sql\Expression|PhpDb\Sql\Predicate\Expression|PhpDb\Sql\Predicate\In|PhpDb\Sql\Predicate\IsNull|PhpDb\Sql\Predicate\Literal|PhpDb\Sql\Predicate\Operator|PhpDb\Sql\Predicate\PredicateInterface`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/PredicateSet.php" -code = "possibly-undefined-int-array-index" -message = "Possibly undefined array key `int(0)` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Sql/PreparableSqlInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\Sql\PreparableSqlInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - -[[issues]] -file = "src/Sql/Select.php" -code = "array-to-string-conversion" -message = "Potential array in left operand of string concatenation." -count = 2 - -[[issues]] -file = "src/Sql/Select.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Sql\Select` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Sql/Select.php" -code = "impossible-null-type-comparison" -message = 'Impossible condition: variable `$this->having` (type `PhpDb\Sql\Having`) will always be `null`.' -count = 1 - -[[issues]] -file = "src/Sql/Select.php" -code = "impossible-null-type-comparison" -message = 'Impossible condition: variable `$this->where` (type `PhpDb\Sql\Where`) will always be `null`.' -count = 1 - -[[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in parameter `$columns` is imprecise, equivalent to `array`." -count = 2 - -[[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in parameter `$name` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in parameter `$order` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Expression::__construct`: expected `string`, but found `mixed`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in parameter `$predicate` is imprecise, equivalent to `array`." -count = 2 +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Literal::__construct`: expected `string`, but found `mixed`.' +count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in parameter `$table` is imprecise, equivalent to `array`." -count = 3 +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-argument" +message = "Invalid argument type for argument #1 of `str_contains`: expected `string`, but found `mixed`." +count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in property `$columns` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #2 of `PhpDb\Sql\Expression::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|array|null|scalar>|list|null|scalar`, but found `mixed`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in property `$combine` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #3 of `PhpDb\Sql\Predicate\Operator::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\ExpressionInterface|PhpDb\Sql\SqlInterface|null|scalar`, but found `nonnull`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in property `$group` is imprecise, equivalent to `array`." -count = 1 +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-array-access" +message = "Unsafe array access on type `mixed`." +count = 2 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in property `$order` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-assignment" +message = "Assigning `mixed` type to a variable may lead to unexpected behavior." +count = 2 + +[[issues]] +file = "src/Sql/Predicate/PredicateSet.php" +code = "mixed-return-statement" +message = 'Could not infer a precise return type for function `PhpDb\Sql\Predicate\PredicateSet::getExpressionData`. Saw type `mixed`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in property `$table` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "possible-method-access-on-null" +message = "Attempting to call a method on `null`." count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processCombine` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Predicate\PredicateSet::addPredicate`: expected `PhpDb\Sql\Predicate\PredicateInterface`, but possibly received `PhpDb\Sql\Expression|PhpDb\Sql\Predicate\Expression|PhpDb\Sql\Predicate\In|PhpDb\Sql\Predicate\IsNull|PhpDb\Sql\Predicate\Literal|PhpDb\Sql\Predicate\Operator|PhpDb\Sql\Predicate\PredicateInterface`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processGroup` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #2 of `PhpDb\Sql\Predicate\In::__construct`: expected `PhpDb\Sql\ArgumentInterface|PhpDb\Sql\Select|list|null`, but possibly received `array`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processHaving` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "possibly-null-destructuring-source" +message = 'Destructuring a possibly null value of type `array{0: string, 1: PhpDb\Sql\Predicate\PredicateInterface}|null`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processLimit` is imprecise, equivalent to `array`." +file = "src/Sql/Predicate/PredicateSet.php" +code = "possibly-undefined-int-array-index" +message = 'Possibly undefined array index accessed on `list`.' count = 1 [[issues]] -file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processOffset` is imprecise, equivalent to `array`." +file = "src/Sql/PreparableSqlInterface.php" +code = "missing-api-or-internal" +message = 'Interface `PhpDb\Sql\PreparableSqlInterface` is missing an `@api` or `@internal` annotation.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processOrder` is imprecise, equivalent to `array`." -count = 1 +code = "array-to-string-conversion" +message = "Potential array in left operand of string concatenation." +count = 2 [[issues]] file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processSelect` is imprecise, equivalent to `array`." +code = "class-must-be-final" +message = 'Class `PhpDb\Sql\Select` should be declared `final`.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "imprecise-type" -message = "Type `array` in return type of `processWhere` is imprecise, equivalent to `array`." +code = "impossible-null-type-comparison" +message = 'Impossible condition: variable `$this->having` (type `PhpDb\Sql\Having`) will always be `null`.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "invalid-iterator" -message = "The expression provided to `foreach` is not iterable. It resolved to type `mixed`, which is not iterable." +code = "impossible-null-type-comparison" +message = 'Impossible condition: variable `$this->where` (type `PhpDb\Sql\Where`) will always be `null`.' count = 1 [[issues]] @@ -4110,12 +3390,6 @@ code = "invalid-property-assignment-value" message = 'Invalid type for property `$where`: expected `PhpDb\Sql\Where`, but got `null`.' count = 1 -[[issues]] -file = "src/Sql/Select.php" -code = "invalid-property-default-value" -message = 'Default value for property `PhpDb\Sql\Select::$specifications` is not assignable to its declared type.' -count = 1 - [[issues]] file = "src/Sql/Select.php" code = "invalid-return-statement" @@ -4124,20 +3398,14 @@ count = 1 [[issues]] file = "src/Sql/Select.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but provided type `array-key` is less specific.' -count = 1 - -[[issues]] -file = "src/Sql/Select.php" -code = "less-specific-argument" -message = 'Argument type mismatch for argument #2 of `PhpDb\Sql\Join::join`: expected `PhpDb\Sql\Predicate\Expression|string`, but provided type `PhpDb\Sql\Predicate\PredicateInterface|string` is less specific.' +code = "less-specific-nested-return-statement" +message = '''Returned type `list{mixed}` is less specific than the declared return type `array{0: string}|null` for function `PhpDb\Sql\Select::processLimit` due to nested 'mixed'.''' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "less-specific-nested-argument-type" -message = 'Argument type mismatch for argument #3 of `PhpDb\Sql\Join::join`: expected `array|string`, but provided type `array|string` is less specific.' +code = "less-specific-nested-return-statement" +message = '''Returned type `list{mixed}` is less specific than the declared return type `array{0: string}|null` for function `PhpDb\Sql\Select::processOffset` due to nested 'mixed'.''' count = 1 [[issues]] @@ -4310,110 +3578,98 @@ count = 1 [[issues]] file = "src/Sql/Select.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifierInFragment`: expected `string`, but found `mixed`.' +code = "possible-method-access-on-null" +message = "Attempting to call a method on `null`." count = 2 [[issues]] file = "src/Sql/Select.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but found `mixed`.' +code = "possibly-false-argument" +message = 'Argument #1 of method `PhpDb\Sql\AbstractSql::resolveTable` is possibly `false`, but parameter type `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string` does not accept it.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::processSubSelect`: expected `PhpDb\Sql\Select`, but found `mixed`.' +code = "possibly-false-iterator" +message = 'Expression being iterated (type `array|false|list`) might be `false` at runtime.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::resolveTable`: expected `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string`, but found `mixed`.' -count = 2 - -[[issues]] -file = "src/Sql/Select.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `str_contains`: expected `string`, but found `mixed`." +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteIdentifier`: expected `string`, but possibly received `PhpDb\Sql\ExpressionInterface|string`.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `strtoupper`: expected `string`, but found `mixed`." -count = 1 +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteValue`: expected `string`, but possibly received `int|string`.' +count = 2 [[issues]] file = "src/Sql/Select.php" -code = "mixed-argument" -message = "Invalid argument type for argument #1 of `trim`: expected `string`, but found `mixed`." +code = "possibly-invalid-argument" +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::renderTable`: expected `string`, but possibly received `array|null|string`.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "mixed-argument" -message = "Invalid argument type for argument #2 of `explode`: expected `string`, but found `mixed`." +code = "possibly-null-argument" +message = "Argument #1 of function `strtoupper` is possibly `null`, but parameter type `string` does not accept it." count = 1 [[issues]] file = "src/Sql/Select.php" -code = "mixed-array-access" -message = "Unsafe array access on type `mixed`." +code = "possibly-null-argument" +message = "Argument #1 of function `trim` is possibly `null`, but parameter type `string` does not accept it." count = 1 [[issues]] file = "src/Sql/Select.php" -code = "mixed-assignment" -message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 12 - -[[issues]] -file = "src/Sql/Select.php" -code = "possible-method-access-on-null" -message = "Attempting to call a method on `null`." -count = 2 +code = "possibly-null-argument" +message = 'Argument #1 of method `PhpDb\Sql\AbstractSql::processSubSelect` is possibly `null`, but parameter type `PhpDb\Sql\Select` does not accept it.' +count = 1 [[issues]] file = "src/Sql/Select.php" -code = "possibly-false-iterator" -message = 'Expression being iterated (type `array|false|list`) might be `false` at runtime.' +code = "possibly-null-argument" +message = 'Argument #1 of method `PhpDb\Sql\AbstractSql::renderTable` is possibly `null`, but parameter type `string` does not accept it.' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Adapter\Platform\PlatformInterface::quoteValue`: expected `string`, but possibly received `int|string`.' -count = 2 +code = "possibly-null-operand" +message = "Possibly null left operand used in string concatenation (type `array|null|string`)." +count = 1 [[issues]] file = "src/Sql/Select.php" -code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::renderTable`: expected `string`, but possibly received `array|null|string`.' +code = "possibly-undefined-int-array-index" +message = "Possibly undefined array index accessed on `non-empty-list`." count = 1 [[issues]] file = "src/Sql/Select.php" -code = "possibly-null-argument" -message = 'Argument #1 of method `PhpDb\Sql\AbstractSql::renderTable` is possibly `null`, but parameter type `string` does not accept it.' +code = "possibly-undefined-string-array-index" +message = '''Possibly undefined array key 'modifier' accessed on `array{'modifier'?: string, 'select'?: PhpDb\Sql\Select, 'type'?: string}`.''' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "possibly-null-operand" -message = "Possibly null left operand used in string concatenation (type `array|null|string`)." +code = "possibly-undefined-string-array-index" +message = '''Possibly undefined array key 'select' accessed on `array{'modifier'?: string, 'select'?: PhpDb\Sql\Select, 'type'?: string}`.''' count = 1 [[issues]] file = "src/Sql/Select.php" -code = "possibly-undefined-int-array-index" -message = "Possibly undefined array index accessed on `non-empty-list`." +code = "possibly-undefined-string-array-index" +message = '''Possibly undefined array key 'type' accessed on `array{'modifier'?: string('')|string('0'), 'select'?: PhpDb\Sql\Select, 'type'?: string}`.''' count = 1 [[issues]] file = "src/Sql/Select.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('modifier')` accessed on `non-empty-array`." +message = '''Possibly undefined array key 'type' accessed on `array{'modifier'?: truthy-string, 'select'?: PhpDb\Sql\Select, 'type'?: string}`.''' count = 1 [[issues]] @@ -4452,24 +3708,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Sql` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Sql.php" -code = "imprecise-type" -message = "Type `array` in parameter `$table` is imprecise, equivalent to `array`." -count = 2 - -[[issues]] -file = "src/Sql/Sql.php" -code = "imprecise-type" -message = "Type `array` in property `$table` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Sql.php" -code = "imprecise-type" -message = "Type `array` in return type of `getTable` is imprecise, equivalent to `array`." -count = 1 - [[issues]] file = "src/Sql/Sql.php" code = "overly-wide-return-type" @@ -4485,25 +3723,25 @@ count = 1 [[issues]] file = "src/Sql/Sql.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Delete::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Delete::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' count = 1 [[issues]] file = "src/Sql/Sql.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Exception\InvalidArgumentException::forForeignTable`: expected `string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Exception\InvalidArgumentException::forForeignTable`: expected `string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' count = 4 [[issues]] file = "src/Sql/Sql.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Insert::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Insert::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' count = 1 [[issues]] file = "src/Sql/Sql.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Update::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Update::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' count = 1 [[issues]] @@ -4554,54 +3792,12 @@ code = "class-must-be-final" message = 'Class `PhpDb\Sql\Update` should be declared `final`.' count = 1 -[[issues]] -file = "src/Sql/Update.php" -code = "docblock-parameter-narrowing" -message = "Docblock type `string` for parameter `$flag` drops part of native type `int|string`." -count = 1 - [[issues]] file = "src/Sql/Update.php" code = "impossible-null-type-comparison" message = 'Impossible condition: variable `$this->where` (type `PhpDb\Sql\Where`) will always be `null`.' count = 1 -[[issues]] -file = "src/Sql/Update.php" -code = "imprecise-type" -message = "Type `array` in parameter `$name` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "imprecise-type" -message = "Type `array` in parameter `$predicate` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "imprecise-type" -message = "Type `array` in parameter `$table` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "imprecise-type" -message = "Type `array` in property `$table` is imprecise, equivalent to `array`." -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "incompatible-property-type" -message = 'Property `PhpDb\Sql\Update::$specifications` has an incompatible type declaration from docblock.' -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "invalid-property-default-value" -message = 'Default value for property `PhpDb\Sql\Update::$specifications` is not assignable to its declared type.' -count = 1 - [[issues]] file = "src/Sql/Update.php" code = "invalid-return-statement" @@ -4626,12 +3822,6 @@ code = "less-specific-nested-argument-type" message = "Argument type mismatch for argument #2 of `str_replace`: expected `array|string`, but provided type `array|null|string` is less specific." count = 1 -[[issues]] -file = "src/Sql/Update.php" -code = "less-specific-nested-argument-type" -message = "Argument type mismatch for argument #3 of `str_replace`: expected `array|string`, but provided type `array|null|string` is less specific." -count = 3 - [[issues]] file = "src/Sql/Update.php" code = "missing-constant-type" @@ -4677,7 +3867,7 @@ count = 1 [[issues]] file = "src/Sql/Update.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::resolveColumnValue`: expected `PhpDb\Sql\ExpressionInterface|PhpDb\Sql\Select|array|bool|int|null|string`, but found `mixed`.' +message = '''Invalid argument type for argument #1 of `PhpDb\Sql\AbstractSql::resolveColumnValue`: expected `PhpDb\Sql\ExpressionInterface|PhpDb\Sql\Select|array{'column': PhpDb\Sql\ExpressionInterface|PhpDb\Sql\Select|bool|int|null|string, 'fromTable'?: string, 'isIdentifier'?: bool}|bool|int|null|string`, but found `mixed`.''' count = 1 [[issues]] @@ -4695,15 +3885,21 @@ count = 1 [[issues]] file = "src/Sql/Update.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::resolveTable`: expected `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\AbstractSql::resolveTable`: expected `PhpDb\Sql\Select|PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' count = 1 [[issues]] file = "src/Sql/Update.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #3 of `Laminas\Stdlib\PriorityList::insert`: expected `int`, but possibly received `int(0)|numeric-string`.' +message = 'Possible argument type mismatch for argument #3 of `Laminas\Stdlib\PriorityList::insert`: expected `int`, but possibly received `int|numeric-string`.' count = 1 +[[issues]] +file = "src/Sql/Update.php" +code = "possibly-invalid-argument" +message = "Possible argument type mismatch for argument #3 of `str_replace`: expected `array|string`, but possibly received `array|null>>|null|string`." +count = 3 + [[issues]] file = "src/Sql/Update.php" code = "possibly-null-argument" @@ -4719,37 +3915,19 @@ count = 3 [[issues]] file = "src/Sql/Update.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('set')` accessed on `array>`." -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('set')` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('update')` accessed on `array>`." -count = 1 - -[[issues]] -file = "src/Sql/Update.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('update')` accessed on `array`." +message = "Possibly undefined array key `string('set')` accessed on `array|null>>|string>`." count = 1 [[issues]] file = "src/Sql/Update.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('where')` accessed on `array>`." +message = "Possibly undefined array key `string('update')` accessed on `array|null>>|string>`." count = 1 [[issues]] file = "src/Sql/Update.php" code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string('where')` accessed on `array`." +message = "Possibly undefined array key `string('where')` accessed on `array|null>>|string>`." count = 1 [[issues]] @@ -4884,6 +4062,18 @@ code = "invalid-return-statement" message = 'Invalid return type for function `PhpDb\TableGateway\AbstractTableGateway::getTable`: expected `PhpDb\Sql\TableIdentifier|array|string`, but found `PhpDb\Sql\TableIdentifier|array|null|string`.' count = 1 +[[issues]] +file = "src/TableGateway/AbstractTableGateway.php" +code = "less-specific-argument" +message = 'Argument type mismatch for argument #2 of `PhpDb\Sql\Sql::__construct`: expected `PhpDb\Sql\TableIdentifier|array|null|string`, but provided type `PhpDb\Sql\TableIdentifier|array|string` is less specific.' +count = 1 + +[[issues]] +file = "src/TableGateway/AbstractTableGateway.php" +code = "less-specific-nested-argument-type" +message = 'Argument type mismatch for argument #1 of `PhpDb\Sql\Select::columns`: expected `array`, but provided type `non-empty-array` is less specific.' +count = 1 + [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "missing-api-or-internal" @@ -4899,19 +4089,19 @@ count = 1 [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Delete::from`: expected `PhpDb\Sql\TableIdentifier|array|string`, but found `mixed`.' +message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Delete::from`: expected `PhpDb\Sql\TableIdentifier|array|string`, but found `mixed`.' count = 2 [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Insert::into`: expected `PhpDb\Sql\TableIdentifier|array|string`, but found `mixed`.' +message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Insert::into`: expected `PhpDb\Sql\TableIdentifier|array|string`, but found `mixed`.' count = 2 [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Update::table`: expected `PhpDb\Sql\TableIdentifier|array|string`, but found `mixed`.' +message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Update::table`: expected `PhpDb\Sql\TableIdentifier|array|string`, but found `mixed`.' count = 2 [[issues]] @@ -5100,6 +4290,12 @@ code = "imprecise-type" message = "Type `array` in parameter `$table` is imprecise, equivalent to `array`." count = 1 +[[issues]] +file = "src/TableGateway/TableGateway.php" +code = "less-specific-argument" +message = 'Argument type mismatch for argument #2 of `PhpDb\Sql\Sql::__construct`: expected `PhpDb\Sql\TableIdentifier|array|null|string`, but provided type `PhpDb\Sql\TableIdentifier|array|string` is less specific.' +count = 1 + [[issues]] file = "src/TableGateway/TableGatewayInterface.php" code = "imprecise-type" diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index 6043537e..d290bdab 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -29,6 +29,17 @@ use function strtoupper; use function vsprintf; +/** + * @psalm-type ParameterSpecification = array|null + * @psalm-type Specification = string|array> + * @psalm-type SqlParameters = array>> + * @psalm-type ColumnReference = array{ + * column: Select|string|int|bool|ExpressionInterface|null, + * fromTable?: string, + * isIdentifier?: bool, + * } + * @psalm-import-type JoinSpecification from Join + */ abstract class AbstractSql implements SqlInterface { protected SqlInterface|PreparableSqlInterface|null $subject = null; @@ -36,7 +47,7 @@ abstract class AbstractSql implements SqlInterface /** * Specifications for Sql String generation * - * @var string[]|array[] + * @var array */ protected array $specifications = []; @@ -47,6 +58,7 @@ abstract class AbstractSql implements SqlInterface */ protected array $processInfo = ['paramPrefix' => '', 'subselectCount' => 0]; + /** @var array */ protected array $instanceParameterIndex = []; /** @@ -70,6 +82,7 @@ protected function buildSqlString( $sqls = []; foreach ($this->specifications as $name => $specification) { + /** @var SqlParameters|string|null $result */ $result = $this->{"process{$name}"}( $platform, $driver, @@ -87,6 +100,8 @@ protected function buildSqlString( } /** + * @param Specification $specifications + * @param SqlParameters $parameters * @throws Exception\RuntimeException */ protected function createSqlFromSpecificationAndParameters(array|string $specifications, array $parameters): string @@ -150,8 +165,8 @@ protected function createSqlFromSpecificationAndParameters(array|string $specifi /** * Flattens expression values, expanding Values arguments * - * @param ArgumentInterface[] $arguments - * @return ArgumentInterface[] + * @param list $arguments + * @return list */ protected function flattenExpressionValues(array $arguments): array { @@ -299,6 +314,7 @@ protected function processIdentifiersArgument( ArgumentInterface $argument, PlatformInterface $platform, ): string { + /** @var list $identifiers */ $identifiers = $argument->getValue(); $processedIdentifiers = []; @@ -310,7 +326,7 @@ protected function processIdentifiersArgument( } /** - * @return null|string[][][] Null if no joins present, array of JOIN statements otherwise + * @return null|array{0: array>} Null if no joins present, array of JOIN statements otherwise */ protected function processJoin( ?Join $joins, @@ -411,6 +427,9 @@ protected function renderTable(string $table, ?string $alias = null): string return $alias ? "{$table} AS {$alias}" : $table; } + /** + * @param ColumnReference|Select|string|int|bool|ExpressionInterface|null $column + */ protected function resolveColumnValue( Select|array|string|int|bool|ExpressionInterface|null $column, PlatformInterface $platform, diff --git a/src/Sql/Argument.php b/src/Sql/Argument.php index 1e9e7015..be2c778b 100644 --- a/src/Sql/Argument.php +++ b/src/Sql/Argument.php @@ -44,6 +44,7 @@ public static function value(string|int|float|bool|null $value): Value return new Value($value); } + /** @param list $values */ public static function values(array $values): Values { return new Values($values); diff --git a/src/Sql/ArgumentInterface.php b/src/Sql/ArgumentInterface.php index b4fe488c..921ba0cb 100644 --- a/src/Sql/ArgumentInterface.php +++ b/src/Sql/ArgumentInterface.php @@ -10,5 +10,6 @@ public function getSpecification(): string; public function getType(): ArgumentType; + /** @return ExpressionInterface|SqlInterface|bool|string|float|int|null|list */ public function getValue(): ExpressionInterface|SqlInterface|string|int|float|bool|array|null; } diff --git a/src/Sql/Combine.php b/src/Sql/Combine.php index c9c2de0a..0971b481 100644 --- a/src/Sql/Combine.php +++ b/src/Sql/Combine.php @@ -18,6 +18,9 @@ /** * Combine SQL statement - allows combining multiple select statements into one + * + * @psalm-import-type Specification from AbstractSql + * @psalm-type CombineSelects = Select|list */ class Combine extends AbstractPreparableSql { @@ -31,14 +34,17 @@ class Combine extends AbstractPreparableSql final public const COMBINE_INTERSECT = 'intersect'; - /** @var string[] */ + /** @var array */ protected array $specifications = [ self::COMBINE => '%1$s (%2$s) ', ]; - /** @var array */ + /** @var list */ private array $combine = []; + /** + * @param CombineSelects|null $select + */ public function __construct( Select|array|null $select = null, string $type = self::COMBINE_UNION, @@ -79,6 +85,7 @@ public function alignColumns(): static /** * Create combine clause * + * @param CombineSelects $select * @throws Exception\InvalidArgumentException */ public function combine(Select|array $select, string $type = self::COMBINE_UNION, string $modifier = ''): static @@ -109,6 +116,8 @@ public function combine(Select|array $select, string $type = self::COMBINE_UNION /** * Create except clause + * + * @param CombineSelects $select */ public function except(Select|array $select, string $modifier = ''): static { @@ -131,6 +140,8 @@ public function getRawState(?string $key = null): mixed /** * Create intersect clause + * + * @param CombineSelects $select */ public function intersect(Select|array $select, string $modifier = ''): static { @@ -139,6 +150,8 @@ public function intersect(Select|array $select, string $modifier = ''): static /** * Create union clause + * + * @param CombineSelects $select */ public function union(Select|array $select, string $modifier = ''): static { diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index e8f2a4f0..2c51e564 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -14,6 +14,9 @@ use function is_int; use function strtoupper; +/** + * @psalm-import-type Specification from AbstractSql + */ class AlterTable extends AbstractSql { final public const ADD_COLUMNS = 'addColumns'; @@ -32,22 +35,31 @@ class AlterTable extends AbstractSql final public const TABLE_OPTIONS = 'tableOptions'; + /** @var list */ protected array $addColumns = []; + /** @var list */ protected array $addConstraints = []; + /** @var array */ protected array $changeColumns = []; + /** @var list */ protected array $dropColumns = []; + /** @var list */ protected array $dropConstraints = []; + /** @var list */ protected array $dropIndexes = []; + /** @var array */ protected array $options = []; /** * Specifications for Sql String generation + * + * @var array */ protected array $specifications = [ self::TABLE => "ALTER TABLE %1\$s\n", @@ -142,6 +154,7 @@ public function dropIndex(string $name): static return $this; } + /** @return array */ public function getOptions(): array { return $this->options; @@ -169,6 +182,7 @@ public function setOption(string $name, Literal|bool|int|string $value): static return $this; } + /** @param array $options */ public function setOptions(array $options): static { $this->options = $options; @@ -183,8 +197,7 @@ public function setTable(string|TableIdentifier $name): static } /** - * @return string[][] - * @psalm-return list{list{0?: string,...}} + * @return array{0: list} */ protected function processAddColumns(?PlatformInterface $adapterPlatform = null): array { @@ -197,8 +210,7 @@ protected function processAddColumns(?PlatformInterface $adapterPlatform = null) } /** - * @return string[][] - * @psalm-return list{list{0?: string,...}} + * @return array{0: list} */ protected function processAddConstraints(?PlatformInterface $adapterPlatform = null): array { @@ -211,8 +223,7 @@ protected function processAddConstraints(?PlatformInterface $adapterPlatform = n } /** - * @return string[][][] - * @psalm-return list{list{0?: list{string, string},...}} + * @return array{0: list} */ protected function processChangeColumns(?PlatformInterface $adapterPlatform = null): array { @@ -228,8 +239,7 @@ protected function processChangeColumns(?PlatformInterface $adapterPlatform = nu } /** - * @return string[][] - * @psalm-return list{list{0?: string,...}} + * @return array{0: list} */ protected function processDropColumns(?PlatformInterface $adapterPlatform = null): array { @@ -242,8 +252,7 @@ protected function processDropColumns(?PlatformInterface $adapterPlatform = null } /** - * @return string[][] - * @psalm-return list{list{0?: string,...}} + * @return array{0: list} */ protected function processDropConstraints(?PlatformInterface $adapterPlatform = null): array { @@ -256,8 +265,7 @@ protected function processDropConstraints(?PlatformInterface $adapterPlatform = } /** - * @return string[][] - * @psalm-return list{list{0?: string,...}} + * @return array{0: list} */ protected function processDropIndexes(?PlatformInterface $adapterPlatform = null): array { @@ -276,7 +284,7 @@ protected function processTable(?PlatformInterface $adapterPlatform = null): arr } /** - * @return string[][]|null + * @return array{0: list}|null */ protected function processTableOptions(?PlatformInterface $adapterPlatform = null): ?array { diff --git a/src/Sql/Ddl/Column/AbstractLengthColumn.php b/src/Sql/Ddl/Column/AbstractLengthColumn.php index c4bf3556..0f99759e 100644 --- a/src/Sql/Ddl/Column/AbstractLengthColumn.php +++ b/src/Sql/Ddl/Column/AbstractLengthColumn.php @@ -21,6 +21,7 @@ abstract class AbstractLengthColumn extends Column protected ?int $length = null; + /** @param array $options */ public function __construct( string $name, ?int $length = null, diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index 744ad4fd..48bdd39e 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -11,6 +11,7 @@ abstract class AbstractPrecisionColumn extends AbstractLengthColumn { protected ?int $decimal; + /** @param array $options */ public function __construct( string $name, ?int $digits = null, diff --git a/src/Sql/Ddl/Column/Column.php b/src/Sql/Ddl/Column/Column.php index 7e1c41de..25f8862b 100644 --- a/src/Sql/Ddl/Column/Column.php +++ b/src/Sql/Ddl/Column/Column.php @@ -21,15 +21,17 @@ class Column implements ColumnInterface protected string $name = ''; + /** @var array */ protected array $options = []; - /** @var ConstraintInterface[] */ + /** @var list */ protected array $constraints = []; protected string $specification = '%s %s'; protected string $type = 'INTEGER'; + /** @param array $options */ public function __construct( string $name = '', bool $nullable = false, @@ -101,6 +103,7 @@ public function getName(): string } #[Override] + /** @return array */ public function getOptions(): array { return $this->options; @@ -136,6 +139,7 @@ public function setOption(string $name, bool|int|string $value): static return $this; } + /** @param array $options */ public function setOptions(array $options): static { $this->options = $options; diff --git a/src/Sql/Ddl/Column/ColumnInterface.php b/src/Sql/Ddl/Column/ColumnInterface.php index 9e5e69e5..ebf4ad23 100644 --- a/src/Sql/Ddl/Column/ColumnInterface.php +++ b/src/Sql/Ddl/Column/ColumnInterface.php @@ -17,6 +17,7 @@ public function getDefault(): string|int|float|bool|Literal|Value|null; public function getName(): string; + /** @return array */ public function getOptions(): array; public function isNullable(): bool; diff --git a/src/Sql/Ddl/Constraint/AbstractConstraint.php b/src/Sql/Ddl/Constraint/AbstractConstraint.php index ffecc368..bea2ecee 100644 --- a/src/Sql/Ddl/Constraint/AbstractConstraint.php +++ b/src/Sql/Ddl/Constraint/AbstractConstraint.php @@ -22,8 +22,10 @@ abstract class AbstractConstraint implements ConstraintInterface protected string $name = ''; + /** @var list */ protected array $columns = []; + /** @param list|string|null $columns */ public function __construct(array|string|null $columns = null, ?string $name = null) { if (null !== $columns) { @@ -42,6 +44,7 @@ public function addColumn(string $column): static } #[Override] + /** @return list */ public function getColumns(): array { return $this->columns; @@ -83,6 +86,7 @@ public function getName(): string return $this->name; } + /** @param list|string $columns */ public function setColumns(string|array $columns): static { $this->columns = (array) $columns; diff --git a/src/Sql/Ddl/Constraint/ConstraintInterface.php b/src/Sql/Ddl/Constraint/ConstraintInterface.php index 9ca18cb3..d61be959 100644 --- a/src/Sql/Ddl/Constraint/ConstraintInterface.php +++ b/src/Sql/Ddl/Constraint/ConstraintInterface.php @@ -8,5 +8,6 @@ interface ConstraintInterface extends ExpressionInterface { + /** @return list */ public function getColumns(): array; } diff --git a/src/Sql/Ddl/Constraint/ForeignKey.php b/src/Sql/Ddl/Constraint/ForeignKey.php index e7d7a690..d06b8eec 100644 --- a/src/Sql/Ddl/Constraint/ForeignKey.php +++ b/src/Sql/Ddl/Constraint/ForeignKey.php @@ -22,7 +22,7 @@ class ForeignKey extends AbstractConstraint protected string $columnSpecification = 'FOREIGN KEY (%s)'; - /** @var string[] */ + /** @var list */ protected array $referenceColumn = []; /** @var string[] */ @@ -32,7 +32,8 @@ class ForeignKey extends AbstractConstraint ]; /** - * @param string[]|string|null $referenceColumn + * @param list|string $columns + * @param list|string|null $referenceColumn */ public function __construct( string $name, @@ -93,6 +94,7 @@ public function getOnUpdateRule(): string return $this->onUpdateRule; } + /** @return list */ public function getReferenceColumn(): array { return $this->referenceColumn; @@ -118,7 +120,7 @@ public function setOnUpdateRule(string $onUpdateRule): static } /** - * @param string[]|string $referenceColumn + * @param list|string $referenceColumn */ public function setReferenceColumn(array|string $referenceColumn): static { diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index ff1aff99..5189b312 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -15,6 +15,9 @@ use function is_int; use function strtoupper; +/** + * @psalm-import-type Specification from AbstractSql + */ class CreateTable extends AbstractSql { final public const COLUMNS = 'columns'; @@ -25,19 +28,20 @@ class CreateTable extends AbstractSql final public const TABLE_OPTIONS = 'tableOptions'; + /** @var list */ protected array $columns = []; + /** @var list */ protected array $constraints = []; protected bool $ifNotExists = false; protected bool $isTemporary = false; + /** @var array */ protected array $options = []; - /** - * {@inheritDoc} - */ + /** @var array */ protected array $specifications = [ self::TABLE => 'CREATE %1$sTABLE %2$s%3$s (', self::COLUMNS => [ @@ -80,6 +84,7 @@ public function getIfNotExists(): bool return $this->ifNotExists; } + /** @return array */ public function getOptions(): array { return $this->options; @@ -118,6 +123,7 @@ public function setOption(string $name, Literal|bool|int|string $value): static return $this; } + /** @param array $options */ public function setOptions(array $options): static { $this->options = $options; diff --git a/src/Sql/Ddl/DropTable.php b/src/Sql/Ddl/DropTable.php index 7f879218..4bd314b5 100644 --- a/src/Sql/Ddl/DropTable.php +++ b/src/Sql/Ddl/DropTable.php @@ -8,12 +8,16 @@ use PhpDb\Sql\AbstractSql; use PhpDb\Sql\TableIdentifier; +/** + * @psalm-import-type Specification from AbstractSql + */ class DropTable extends AbstractSql { final public const TABLE = 'table'; protected bool $ifExists = false; + /** @var array */ protected array $specifications = [ self::TABLE => 'DROP TABLE %1$s%2$s', ]; diff --git a/src/Sql/Ddl/Index/Index.php b/src/Sql/Ddl/Index/Index.php index 1d314528..04597226 100644 --- a/src/Sql/Ddl/Index/Index.php +++ b/src/Sql/Ddl/Index/Index.php @@ -16,10 +16,15 @@ class Index extends AbstractIndex { protected string $specification = 'INDEX %s(...)'; + /** @var array */ protected array $lengths; protected ?string $type = null; + /** + * @param list|string|null $columns + * @param array $lengths + */ public function __construct(array|string|null $columns, ?string $name = null, array $lengths = []) { parent::__construct($columns, $name); diff --git a/src/Sql/Delete.php b/src/Sql/Delete.php index 72006aaa..5d6a0058 100644 --- a/src/Sql/Delete.php +++ b/src/Sql/Delete.php @@ -16,6 +16,7 @@ /** * @property Where $where + * @psalm-import-type Specification from AbstractSql */ class Delete extends AbstractPreparableSql { @@ -28,14 +29,13 @@ class Delete extends AbstractPreparableSql /** @#- */ - /** - * {@inheritDoc} - */ + /** @var array */ protected array $specifications = [ self::SPECIFICATION_DELETE => 'DELETE FROM %1$s', self::SPECIFICATION_WHERE => 'WHERE %1$s', ]; + /** @var TableIdentifier|string|array */ protected TableIdentifier|string|array $table = ''; protected bool $emptyWhereProtection = true; @@ -54,6 +54,8 @@ public function __construct(string|TableIdentifier|null $table = null) /** * Create from statement + * + * @param TableIdentifier|string|array $table */ public function from(TableIdentifier|string|array $table): static { @@ -74,6 +76,7 @@ public function getRawState(?string $key = null): mixed /** * Create where clause * + * @param PredicateInterface|array|Closure|string|Where $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet */ public function where( diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index c4771771..a2b880e4 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -18,6 +18,9 @@ use function preg_match_all; use function str_replace; +/** + * @psalm-type ExpressionParameter = bool|string|float|int|null|list|ExpressionInterface|ArgumentInterface + */ class Expression extends AbstractExpression { /** @@ -27,11 +30,13 @@ class Expression extends AbstractExpression protected string $expression = ''; - /** @var ArgumentInterface[] */ + /** @var list */ protected array $parameters = []; /** * @todo Update documentation to show how parameters can be specifically typed + * + * @param ExpressionParameter|array $parameters */ public function __construct( string $expression = '', @@ -94,6 +99,7 @@ public function getExpressionData(): array ]; } + /** @return list */ public function getParameters(): array { return $this->parameters; @@ -113,6 +119,7 @@ public function setExpression(string $expression): self } /** + * @param ExpressionParameter|array $parameters * @throws Exception\InvalidArgumentException */ public function setParameters( diff --git a/src/Sql/ExpressionInterface.php b/src/Sql/ExpressionInterface.php index 8121ddc3..eff6202a 100644 --- a/src/Sql/ExpressionInterface.php +++ b/src/Sql/ExpressionInterface.php @@ -9,7 +9,7 @@ interface ExpressionInterface /** * Returns raw expression data as array for optimised processing * - * @return array{spec: string, values: ArgumentInterface[]} + * @return array{spec: string, values: list} */ public function getExpressionData(): array; } diff --git a/src/Sql/Insert.php b/src/Sql/Insert.php index 46f67ff4..f046917e 100644 --- a/src/Sql/Insert.php +++ b/src/Sql/Insert.php @@ -21,6 +21,9 @@ use function range; use function str_replace; +/** + * @psalm-import-type Specification from AbstractSql + */ class Insert extends AbstractPreparableSql { /** @@ -36,14 +39,16 @@ class Insert extends AbstractPreparableSql final public const VALUES_SET = 'set'; - /** @var string[]|array[] $specifications */ + /** @var array */ protected array $specifications = [ self::SPECIFICATION_INSERT => 'INSERT INTO %1$s (%2$s) VALUES (%3$s)', self::SPECIFICATION_SELECT => 'INSERT INTO %1$s %2$s %3$s', ]; + /** @var TableIdentifier|string|array */ protected TableIdentifier|string|array $table = ''; + /** @var array */ protected array $columns = []; protected array|Select|null $select = null; @@ -60,6 +65,8 @@ public function __construct(string|TableIdentifier|null $table = null) /** * Specify columns + * + * @param list $columns */ public function columns(array $columns): static { @@ -82,6 +89,8 @@ public function getRawState(?string $key = null): TableIdentifier|string|array /** * Create INTO clause + * + * @param TableIdentifier|string|array $table */ public function into(TableIdentifier|string|array $table): static { @@ -100,7 +109,8 @@ public function select(Select $select): static /** * Specify values to insert * - * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET + * @param array|Select $values + * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET * @throws Exception\InvalidArgumentException */ public function values(array|Select $values, string $flag = self::VALUES_SET): static @@ -211,6 +221,7 @@ protected function processSelect( * * @link http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential */ + /** @param array $array */ private function isAssocativeArray(array $array): bool { return array_keys($array) !== range(0, count($array) - 1); diff --git a/src/Sql/InsertIgnore.php b/src/Sql/InsertIgnore.php index e8b2e9fe..99939792 100644 --- a/src/Sql/InsertIgnore.php +++ b/src/Sql/InsertIgnore.php @@ -4,9 +4,12 @@ namespace PhpDb\Sql; +/** + * @psalm-import-type Specification from AbstractSql + */ class InsertIgnore extends Insert { - /** @var string[]|array[] $specifications */ + /** @var array */ protected array $specifications = [ self::SPECIFICATION_INSERT => 'INSERT IGNORE INTO %1$s (%2$s) VALUES (%3$s)', self::SPECIFICATION_SELECT => 'INSERT IGNORE INTO %1$s %2$s %3$s', diff --git a/src/Sql/Join.php b/src/Sql/Join.php index 303ec695..fdee1d37 100644 --- a/src/Sql/Join.php +++ b/src/Sql/Join.php @@ -25,6 +25,15 @@ * `Select::SQL_STAR`. * - type: the type of JOIN being performed; see the `JOIN_*` constants; * defaults to `JOIN_INNER` + * + * @psalm-type JoinName = string|TableIdentifier|non-empty-array + * @psalm-type JoinSpecification = array{ + * name: JoinName, + * on: string|Predicate\PredicateInterface, + * columns: array, + * type: string, + * } + * @implements Iterator */ class Join implements Iterator, Countable { @@ -49,6 +58,8 @@ class Join implements Iterator, Countable /** * JOIN specifications + * + * @var list */ protected array $joins = []; @@ -64,6 +75,8 @@ public function count(): int /** * Return current join specification. + * + * @return JoinSpecification */ #[Override] #[ReturnTypeWillChange] @@ -72,19 +85,23 @@ public function current(): array return $this->joins[$this->position]; } + /** @return list */ public function getJoins(): array { return $this->joins; } /** - * @param array|string|TableIdentifier $name A table name on which to join, or a single - * element associative array, of the form alias => table, or TableIdentifier instance - * @param string|Predicate\Expression $on A specification describing the fields to join on. - * @param string|string[] $columns A single column name, an array - * of column names, or (a) specification(s) such as SQL_STAR representing + * @param JoinName $name A table name on which + * to join, or a single element associative array, of the form alias => table, or TableIdentifier + * instance + * @param string|Predicate\PredicateInterface $on A specification + * describing the fields to join on. + * @param string|array $columns A single + * column name, an array of column names, or (a) specification(s) such as SQL_STAR representing * the columns to join. - * @param string $type The JOIN type to use; see the JOIN_* constants. + * @param string $type The JOIN type to use; + * see the JOIN_* constants. * @throws Exception\InvalidArgumentException For invalid $name values. */ // phpcs:ignore Generic.NamingConventions.ConstructorName.OldStyle diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index 13b4900e..d8c2cc3b 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -21,6 +21,8 @@ class In extends AbstractExpression implements PredicateInterface /** * Constructor + * + * @param list|Select|ArgumentInterface|null $valueSet */ public function __construct( string|ArgumentInterface|null $identifier = null, @@ -86,6 +88,8 @@ public function setIdentifier(string|ArgumentInterface $identifier): static /** * Set set of values for IN comparison + * + * @param list|Select|ArgumentInterface $valueSet */ public function setValueSet(array|Select|ArgumentInterface $valueSet): static { diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index 93ca6484..2f8ac0ab 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -33,10 +33,13 @@ class PredicateSet implements PredicateInterface, Countable protected string $defaultCombination = self::OP_AND; + /** @var list */ protected array $predicates = []; /** * Constructor + * + * @param list|null $predicates */ public function __construct(?array $predicates = null, string $defaultCombination = self::OP_AND) { @@ -68,6 +71,7 @@ public function addPredicate(PredicateInterface $predicate, ?string $combination /** * Add predicates to set * + * @param PredicateInterface|Closure|string|array $predicates * @throws Exception\InvalidArgumentException */ public function addPredicates( @@ -201,6 +205,8 @@ public function getExpressionData(): array /** * Return the predicates + * + * @return list */ public function getPredicates(): array { diff --git a/src/Sql/Select.php b/src/Sql/Select.php index 051284b9..d761a95e 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -35,6 +35,11 @@ * @property Where $where * @property Having $having * @property Join $joins + * @psalm-import-type Specification from AbstractSql + * @psalm-import-type JoinName from Join + * @psalm-type TableReference = string|TableIdentifier|array + * @psalm-type ColumnList = array + * @psalm-type Combination = array{select: Select, type: string, modifier: string} */ class Select extends AbstractPreparableSql { @@ -97,7 +102,7 @@ class Select extends AbstractPreparableSql final public const COMBINE_INTERSECT = 'intersect'; - /** @var string[]|array[] $specifications */ + /** @var array */ protected array $specifications = [ 'statementStart' => '%1$s', self::SELECT => [ @@ -141,18 +146,22 @@ class Select extends AbstractPreparableSql protected bool $prefixColumnsWithTable = true; + /** @var TableReference|null */ protected string|array|TableIdentifier|null $table = null; protected string|ExpressionInterface|null $quantifier = null; + /** @var ColumnList */ protected array $columns = [self::SQL_STAR]; protected ?Join $joins = null; protected ?Where $where = null; + /** @var ColumnList */ protected array $order = []; + /** @var list|null */ protected ?array $group = null; protected ?Having $having = null; @@ -161,10 +170,13 @@ class Select extends AbstractPreparableSql protected string|int|null $offset = null; + /** @var Combination|array{} */ protected array $combine = []; /** * Constructor + * + * @param TableReference|null $table */ public function __construct(array|string|TableIdentifier|null $table = null) { @@ -183,6 +195,8 @@ public function __construct(array|string|TableIdentifier|null $table = null) * array(string => value, ...) * key string will be use as alias, * value can be string or Expression objects + * + * @param ColumnList $columns */ public function columns(array $columns, bool $prefixColumnsWithTable = true): static { @@ -211,6 +225,7 @@ public function combine(Select $select, string $type = self::COMBINE_UNION, stri /** * Create from clause * + * @param TableReference $table * @throws Exception\InvalidArgumentException */ public function from(array|string|TableIdentifier $table): static @@ -245,6 +260,9 @@ public function getRawState(?string $key = null): mixed return null !== $key && array_key_exists($key, $rawState) ? $rawState[$key] : $rawState; } + /** + * @param string|ExpressionInterface|list $group + */ public function group(mixed $group): static { if (is_array($group)) { @@ -261,6 +279,7 @@ public function group(mixed $group): static /** * Create having clause * + * @param Having|PredicateInterface|array|Closure|string $predicate * @param string $combination One of the OP_* constants from Predicate\PredicateSet */ public function having( @@ -287,7 +306,9 @@ public function isTableReadOnly(): bool /** * Create join clause * - * @param string $type one of the JOIN_* constants + * @param JoinName $name + * @param string|array $columns + * @param string $type one of the JOIN_* constants * @throws Exception\InvalidArgumentException */ public function join( @@ -327,6 +348,9 @@ public function offset(int|string $offset): static return $this; } + /** + * @param ExpressionInterface|ColumnList|string $order + */ public function order(ExpressionInterface|array|string $order): static { if (is_string($order)) { @@ -405,7 +429,7 @@ public function reset(string $part): static } /** - * @param string|array $specification + * @param Specification $specification */ public function setSpecification(string $index, array|string $specification): static { @@ -420,7 +444,8 @@ public function setSpecification(string $index, array|string $specification): st /** * Create where clause * - * @param string $combination One of the OP_* constants from Predicate\PredicateSet + * @param PredicateInterface|array|string|Closure $predicate + * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @throws Exception\InvalidArgumentException */ public function where( @@ -436,6 +461,7 @@ public function where( return $this; } + /** @return array{0: string, 1: string}|null */ protected function processCombine( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -455,6 +481,7 @@ protected function processCombine( ]; } + /** @return array{0: list}|null */ protected function processGroup( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -481,6 +508,7 @@ protected function processGroup( return [$groups]; } + /** @return array{0: string}|null */ protected function processHaving( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -495,7 +523,7 @@ protected function processHaving( ]; } - /** @return string[][][]|null */ + /** @return array{0: array>}|null */ protected function processJoins( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -504,6 +532,7 @@ protected function processJoins( return $this->processJoin($this->joins, $platform, $driver, $parameterContainer); } + /** @return array{0: string}|null */ protected function processLimit( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -522,6 +551,7 @@ protected function processLimit( return [$platform->quoteValue($this->limit)]; } + /** @return array{0: string}|null */ protected function processOffset( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -540,6 +570,7 @@ protected function processOffset( return [$platform->quoteValue($this->offset)]; } + /** @return array{0: list>}|null */ protected function processOrder( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -579,6 +610,8 @@ protected function processOrder( /** * Process the select part + * + * @return list>> */ protected function processSelect( PlatformInterface $platform, @@ -684,6 +717,7 @@ protected function processStatementStart(): ?array return null; } + /** @return array{0: string}|null */ protected function processWhere( PlatformInterface $platform, ?DriverInterface $driver = null, @@ -699,8 +733,8 @@ protected function processWhere( } /** + * @param Select|TableReference|null $table * @return array{0: string|null, 1: string} - * @phpstan-return array{0: string|null, 1: string} */ #[Override] protected function resolveTable( diff --git a/src/Sql/Sql.php b/src/Sql/Sql.php index aa2c14d7..a0de5c0e 100644 --- a/src/Sql/Sql.php +++ b/src/Sql/Sql.php @@ -11,10 +11,12 @@ class Sql { protected AdapterInterface $adapter; + /** @var TableIdentifier|string|array|null */ protected TableIdentifier|string|array|null $table; protected Platform\PlatformDecoratorInterface $sqlPlatform; + /** @param TableIdentifier|string|array|null $table */ public function __construct( AdapterInterface $adapter, array|string|TableIdentifier|null $table = null, @@ -59,6 +61,7 @@ public function getSqlPlatform(): ?Platform\PlatformDecoratorInterface return $this->sqlPlatform; } + /** @return TableIdentifier|string|array|null */ public function getTable(): array|string|TableIdentifier|null { return $this->table; @@ -106,6 +109,7 @@ public function select(string|TableIdentifier|null $table = null): Select } /** + * @param TableIdentifier|string|array $table * @throws Exception\InvalidArgumentException */ public function setTable(array|string|TableIdentifier $table): self diff --git a/src/Sql/Update.php b/src/Sql/Update.php index 13d4e849..d82b585c 100644 --- a/src/Sql/Update.php +++ b/src/Sql/Update.php @@ -22,6 +22,8 @@ /** * @property Where $where + * @psalm-import-type Specification from AbstractSql + * @psalm-import-type JoinName from Join */ class Update extends AbstractPreparableSql { @@ -42,7 +44,7 @@ class Update extends AbstractPreparableSql /** @#-* */ - /** @var array|array */ + /** @var array */ protected array $specifications = [ self::SPECIFICATION_UPDATE => 'UPDATE %1$s', self::SPECIFICATION_JOIN => [ @@ -54,6 +56,7 @@ class Update extends AbstractPreparableSql self::SPECIFICATION_WHERE => 'WHERE %1$s', ]; + /** @var TableIdentifier|string|array */ protected TableIdentifier|string|array $table = ''; protected bool $emptyWhereProtection = true; @@ -89,6 +92,7 @@ public function getRawState(?string $key = null): mixed /** * Create join clause * + * @param JoinName $name * @throws Exception\InvalidArgumentException */ public function join(array|string|TableIdentifier $name, string $on, string $type = Join::JOIN_INNER): static @@ -101,8 +105,8 @@ public function join(array|string|TableIdentifier $name, string $on, string $typ /** * Set key/value pairs to update * - * @param array $values Associative array of key values - * @param string $flag One of the VALUES_* constants + * @param array $values Associative array of key values + * @param string|int $flag One of the VALUES_* constants, or a numeric priority * @throws Exception\InvalidArgumentException */ public function set(array $values, string|int $flag = self::VALUES_SET): static @@ -126,6 +130,8 @@ public function set(array $values, string|int $flag = self::VALUES_SET): static /** * Specify table for statement + * + * @param TableIdentifier|string|array $table */ public function table(TableIdentifier|string|array $table): static { @@ -136,6 +142,8 @@ public function table(TableIdentifier|string|array $table): static /** * Create where clause * + * @param PredicateInterface|array|Closure|string|Where $predicate + * @param string $combination One of the OP_* constants from Predicate\PredicateSet * @throws Exception\InvalidArgumentException */ public function where(