diff --git a/analyzer-baseline.toml b/analyzer-baseline.toml index 1c9e3f0c1..6b637c508 100644 --- a/analyzer-baseline.toml +++ b/analyzer-baseline.toml @@ -172,7 +172,7 @@ count = 1 file = "src/RowGateway/AbstractRowGateway.php" code = "possibly-null-array-access" message = "Cannot perform array access on possibly `null` value." -count = 4 +count = 3 [[issues]] file = "src/RowGateway/AbstractRowGateway.php" @@ -282,60 +282,6 @@ code = "missing-return-type" message = "Function `__unset` is missing a return type hint." count = 1 -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Sql\Platform\Platform` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "mixed-array-assignment" -message = "Unsafe array assignment on type `mixed`." -count = 1 - -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "mixed-return-statement" -message = 'Could not infer a precise return type for function `PhpDb\Sql\Platform\Platform::getDecorators`. Saw type `mixed`.' -count = 1 - -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "non-existent-method" -message = 'Method `getSqlString` does not exist on type `PhpDb\Sql\Platform\PlatformDecoratorInterface`.' -count = 1 - -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "non-existent-method" -message = 'Method `getSqlString` does not exist on type `PhpDb\Sql\PreparableSqlInterface`.' -count = 1 - -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "non-existent-method" -message = 'Method `prepareStatement` does not exist on type `PhpDb\Sql\Platform\PlatformDecoratorInterface`.' -count = 1 - -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "non-existent-method" -message = 'Method `prepareStatement` does not exist on type `PhpDb\Sql\SqlInterface`.' -count = 1 - -[[issues]] -file = "src/Sql/Platform/Platform.php" -code = "possibly-undefined-string-array-index" -message = "Possibly undefined array key `string` accessed on `array`." -count = 1 - -[[issues]] -file = "src/Sql/Platform/PlatformDecoratorInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\Sql\Platform\PlatformDecoratorInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - [[issues]] file = "src/Sql/Select.php" code = "missing-return-type" @@ -414,12 +360,6 @@ code = "invalid-property-assignment-value" message = "Invalid type for property `$lastInsertValue`: expected `int`, but got `false|int|null|string`." count = 1 -[[issues]] -file = "src/TableGateway/AbstractTableGateway.php" -code = "invalid-return-statement" -message = 'Invalid return type for function `PhpDb\TableGateway\AbstractTableGateway::executeSelect`: expected `PhpDb\ResultSet\ResultSetInterface`, but found `PhpDb\ResultSet\ResultSetInterface|null`.' -count = 1 - [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "invalid-return-statement" @@ -544,7 +484,7 @@ count = 6 file = "src/TableGateway/AbstractTableGateway.php" code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." -count = 9 +count = 8 [[issues]] file = "src/TableGateway/AbstractTableGateway.php" @@ -558,12 +498,6 @@ code = "mixed-clone" message = "Cannot statically verify `clone` on a `mixed` type." count = 1 -[[issues]] -file = "src/TableGateway/AbstractTableGateway.php" -code = "nullable-return-statement" -message = 'Function `PhpDb\TableGateway\AbstractTableGateway::executeSelect` is declared to return `PhpDb\ResultSet\ResultSetInterface` but possibly returns a nullable value (inferred as `PhpDb\ResultSet\ResultSetInterface|null`).' -count = 1 - [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "nullable-return-statement" @@ -588,17 +522,11 @@ code = "nullable-return-statement" message = 'Function `PhpDb\TableGateway\AbstractTableGateway::getTable` is declared to return `PhpDb\Sql\TableIdentifier|array|string` but possibly returns a nullable value (inferred as `PhpDb\Sql\TableIdentifier|array|null|string`).' count = 1 -[[issues]] -file = "src/TableGateway/AbstractTableGateway.php" -code = "overly-wide-return-type" -message = "Declared return type `false|int|null|string` for `getlastinsertvalue` has unused branches: `false`, `string`, `null`." -count = 1 - [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "possible-method-access-on-null" message = "Attempting to call a method on `null`." -count = 28 +count = 27 [[issues]] file = "src/TableGateway/AbstractTableGateway.php" @@ -630,12 +558,6 @@ code = "possibly-undefined-int-array-index" message = 'Possibly undefined array index accessed on `list`.' count = 3 -[[issues]] -file = "src/TableGateway/AbstractTableGateway.php" -code = "possibly-undefined-string-array-index" -message = '''Possibly undefined array key `string('table')` accessed on `array|string>`.''' -count = 1 - [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "possibly-undefined-string-array-index" diff --git a/src/Adapter/Adapter.php b/src/Adapter/Adapter.php index 44b3da65a..9811980c4 100644 --- a/src/Adapter/Adapter.php +++ b/src/Adapter/Adapter.php @@ -108,8 +108,8 @@ public function getHelpers(): array self::FUNCTION_QUOTE_IDENTIFIER => static fn(string $value): string => $platform->quoteIdentifier( $value, ), - self::FUNCTION_QUOTE_VALUE => $platform->quoteValue(...), - default => null, + self::FUNCTION_QUOTE_VALUE => $platform->quoteValue(...), + default => null, }; if (null !== $function) { $functions[] = $function; diff --git a/src/Adapter/Driver/Pdo/Result.php b/src/Adapter/Driver/Pdo/Result.php index ba50d5d95..3ffa5bee0 100644 --- a/src/Adapter/Driver/Pdo/Result.php +++ b/src/Adapter/Driver/Pdo/Result.php @@ -307,9 +307,9 @@ private function resolveRowCount(): int $rowCount = $this->rowCount; return match (true) { - is_int($rowCount) => $rowCount, + is_int($rowCount) => $rowCount, $rowCount instanceof Closure => (int) $rowCount(), - default => $this->resource->rowCount(), + default => $this->resource->rowCount(), }; } } diff --git a/src/Adapter/Driver/Pdo/Statement.php b/src/Adapter/Driver/Pdo/Statement.php index 5fde4e85b..aaa4a7c82 100644 --- a/src/Adapter/Driver/Pdo/Statement.php +++ b/src/Adapter/Driver/Pdo/Statement.php @@ -285,7 +285,7 @@ private function toPdoType(mixed $errata, mixed $value): int is_int($value) => PDO::PARAM_INT, is_bool($value) => PDO::PARAM_BOOL, null === $value => PDO::PARAM_NULL, - default => PDO::PARAM_STR, + default => PDO::PARAM_STR, }; } diff --git a/src/Adapter/ParameterContainer.php b/src/Adapter/ParameterContainer.php index 4322ffac4..a7cee484b 100644 --- a/src/Adapter/ParameterContainer.php +++ b/src/Adapter/ParameterContainer.php @@ -260,8 +260,8 @@ public function offsetSet(mixed $offset, mixed $value, mixed $errata = null, mix ? substr($offset, offset: 1) : $offset] ?? $offset, - null === $offset => (string) count($this->data), - default => throw Exception\InvalidArgumentException::forInvalidKeyType(), + null === $offset => (string) count($this->data), + default => throw Exception\InvalidArgumentException::forInvalidKeyType(), }; $isNewPosition = is_int($offset) @@ -310,8 +310,6 @@ public function offsetSetMaxLength(string|int $name, mixed $maxLength): void /** * Bind a parameter to another by reference. Referencing a name that is not set creates it * as null, so the two stay bound when either is set later. - * - * @mago-expect analysis:possibly-undefined-string-array-index */ public function offsetSetReference(string|int $name, string|int $from): void { diff --git a/src/Adapter/Profiler/Profiler.php b/src/Adapter/Profiler/Profiler.php index 79e3c9c30..069f93996 100644 --- a/src/Adapter/Profiler/Profiler.php +++ b/src/Adapter/Profiler/Profiler.php @@ -41,7 +41,7 @@ public function getLastProfile(): ?array { $lastIndex = array_key_last($this->profiles); - return null === $lastIndex ? null : $this->profiles[$lastIndex] ?? null; + return null === $lastIndex ? null : $this->profiles[$lastIndex]; } /** diff --git a/src/Container/AdapterInterfaceFactory.php b/src/Container/AdapterInterfaceFactory.php index 49bd22a93..34db50154 100644 --- a/src/Container/AdapterInterfaceFactory.php +++ b/src/Container/AdapterInterfaceFactory.php @@ -23,6 +23,12 @@ final class AdapterInterfaceFactory * @throws ContainerException If the config service, the adapter configuration or its driver is missing. * @throws ContainerExceptionInterface If a dependency cannot be built. * @throws NotFoundExceptionInterface If a dependency cannot be resolved. + * + * Mago reads ServiceManager::get()'s class-string conditional return as `object` + * for the 'config' id, which is an array (or null) at runtime. + * + * @mago-expect analysis:docblock-type-mismatch + * @mago-expect analysis:redundant-null-coalesce */ public function __invoke( ContainerInterface&ServiceManager $container, diff --git a/src/Metadata/Source/AbstractSource.php b/src/Metadata/Source/AbstractSource.php index 3c08c5b71..784732157 100644 --- a/src/Metadata/Source/AbstractSource.php +++ b/src/Metadata/Source/AbstractSource.php @@ -108,10 +108,11 @@ abstract class AbstractSource implements MetadataInterface public function __construct( protected AdapterInterface&SchemaAwareInterface $adapter, ) { - $currentSchema = $this->adapter->getCurrentSchema(); - $this->defaultSchema = false !== $currentSchema && '' !== $currentSchema - ? $currentSchema - : self::DEFAULT_SCHEMA; + $currentSchema = $this->adapter->getCurrentSchema(); + $this->defaultSchema = + false !== $currentSchema && '' !== $currentSchema + ? $currentSchema + : self::DEFAULT_SCHEMA; } /** @@ -694,7 +695,6 @@ protected function loadTriggerData(string $schema): void * on every iteration, which does not terminate in useful time on Mago * 1.47.5 and later. * - * @mago-expect analysis:mixed-assignment * @mago-expect lint:no-isset */ protected function prepareDataHierarchy(string $type, string ...$keys): void @@ -706,6 +706,7 @@ protected function prepareDataHierarchy(string $type, string ...$keys): void $data[$key] = []; } + /** @var array $data */ $data = &$data[$key]; } } diff --git a/src/ResultSet/AbstractResultSet.php b/src/ResultSet/AbstractResultSet.php index 8b5e6438c..c9faa6f2b 100644 --- a/src/ResultSet/AbstractResultSet.php +++ b/src/ResultSet/AbstractResultSet.php @@ -213,10 +213,10 @@ public function getFieldCount(): int $this->fieldCount = match (true) { $row instanceof Countable => $row->count(), - is_array($row) => count($row), - is_object($row) => count(get_mangled_object_vars($row)), - null === $row => 0, - default => 1, + is_array($row) => count($row), + is_object($row) => count(get_mangled_object_vars($row)), + null === $row => 0, + default => 1, }; return $this->fieldCount; diff --git a/src/ResultSet/RowPrototypeResultSetInterface.php b/src/ResultSet/RowPrototypeResultSetInterface.php index 2b1f316db..38d7f82e4 100644 --- a/src/ResultSet/RowPrototypeResultSetInterface.php +++ b/src/ResultSet/RowPrototypeResultSetInterface.php @@ -13,5 +13,7 @@ interface RowPrototypeResultSetInterface { public function getRowPrototype(): RowPrototypeInterface; - public function setRowPrototype(RowPrototypeInterface $rowPrototype): ResultSetInterface&RowPrototypeResultSetInterface; + public function setRowPrototype( + RowPrototypeInterface $rowPrototype, + ): ResultSetInterface&RowPrototypeResultSetInterface; } diff --git a/src/Sql/AbstractSql.php b/src/Sql/AbstractSql.php index a392f00ff..494056903 100644 --- a/src/Sql/AbstractSql.php +++ b/src/Sql/AbstractSql.php @@ -246,7 +246,7 @@ protected function processExpression( null === $namedParameterPrefix || '' === $namedParameterPrefix => $parameterContainer ? 'expr' . $this->processInfo['expressionCount']++ . 'Param' : '', - default => $this->processInfo['paramPrefix'] + default => $this->processInfo['paramPrefix'] . str_replace([' ', "\t", "\n", "\r"], replace: '__', subject: $namedParameterPrefix), }; @@ -258,7 +258,7 @@ protected function processExpression( foreach ($expressionValues as $vIndex => $argument) { $values[] = match (true) { - $argument instanceof Value => $parameterContainer instanceof ParameterContainer + $argument instanceof Value => $parameterContainer instanceof ParameterContainer && $driver instanceof DriverInterface ? $this->processExpressionParameterName( $argument->getValue(), @@ -268,9 +268,9 @@ protected function processExpression( $parameterContainer, ) : $platform->quoteValue((string) $argument->getValue()), - $argument instanceof Identifier => IdentifierQuoter::quote($argument->getValue(), $platform), - $argument instanceof Literal => $argument->getValue(), - $argument instanceof Identifiers => $this->processIdentifiersArgument($argument, $platform), + $argument instanceof Identifier => IdentifierQuoter::quote($argument->getValue(), $platform), + $argument instanceof Literal => $argument->getValue(), + $argument instanceof Identifiers => $this->processIdentifiersArgument($argument, $platform), $argument instanceof SelectArgument => $this->processExpressionOrSelect( $argument, $namedParameterPrefix, @@ -327,7 +327,7 @@ protected function processExpressionOrSelect( $parameterContainer, "{$namedParameterPrefix}{$vIndex}subpart", ), - default => throw Exception\InvalidArgumentException::forInvalidArgumentType(), + default => throw Exception\InvalidArgumentException::forInvalidArgumentType(), }; } @@ -384,15 +384,15 @@ protected function processJoin( } $joinName = match (true) { - $joinName instanceof Expression => $joinName->getExpression(), + $joinName instanceof Expression => $joinName->getExpression(), $joinName instanceof TableIdentifier => $this->quoteJoinTableIdentifier($joinName, $platform), - $joinName instanceof Select => "({$this->processSubSelect( + $joinName instanceof Select => "({$this->processSubSelect( $joinName, $platform, $driver, $parameterContainer, )})", - default => $platform->quoteIdentifier($joinName), + default => $platform->quoteIdentifier($joinName), }; $joinSpecArgArray[$j] = [ @@ -620,8 +620,8 @@ private function formatParameterList(array $parameterSpecification, array $value { $count = count($values); $format = $parameterSpecification[$count] ?? throw Exception\RuntimeException::forUnsupportedParameterCountOf( - $count, - ); + $count, + ); return vsprintf($format, $this->flattenParameterList($values)); } diff --git a/src/Sql/Ddl/AlterTable.php b/src/Sql/Ddl/AlterTable.php index eaee0bccb..a5f03343f 100644 --- a/src/Sql/Ddl/AlterTable.php +++ b/src/Sql/Ddl/AlterTable.php @@ -295,9 +295,9 @@ protected function processTableOptions(PlatformInterface $adapterPlatform): ?arr $key = strtoupper($key); $value = match (true) { $value instanceof Literal => $value->getLiteral(), - is_bool($value) => $value ? '1' : '0', - is_int($value) => (string) $value, - default => $adapterPlatform->quoteTrustedValue($value), + is_bool($value) => $value ? '1' : '0', + is_int($value) => (string) $value, + default => $adapterPlatform->quoteTrustedValue($value), }; $sqls[] = "{$key} = {$value}"; } diff --git a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php index e8f0c1507..f9af9f5bb 100644 --- a/src/Sql/Ddl/Column/AbstractPrecisionColumn.php +++ b/src/Sql/Ddl/Column/AbstractPrecisionColumn.php @@ -61,7 +61,7 @@ protected function getLengthExpression(): string return match (true) { null === $this->decimal => (string) $this->length, null === $this->length => throw InvalidArgumentException::forMissingDecimalDigits($this->name, $this->type), - default => "{$this->length},{$this->decimal}", + default => "{$this->length},{$this->decimal}", }; } } diff --git a/src/Sql/Ddl/CreateTable.php b/src/Sql/Ddl/CreateTable.php index ee512e4aa..36e82525e 100644 --- a/src/Sql/Ddl/CreateTable.php +++ b/src/Sql/Ddl/CreateTable.php @@ -219,9 +219,9 @@ protected function processTableOptions(PlatformInterface $adapterPlatform): ?arr $key = strtoupper($key); $value = match (true) { $value instanceof Literal => $value->getLiteral(), - is_bool($value) => $value ? '1' : '0', - is_int($value) => (string) $value, - default => $adapterPlatform->quoteTrustedValue($value), + is_bool($value) => $value ? '1' : '0', + is_int($value) => (string) $value, + default => $adapterPlatform->quoteTrustedValue($value), }; $parts[] = "{$key} = {$value}"; } diff --git a/src/Sql/Expression.php b/src/Sql/Expression.php index 86401f018..67e459215 100644 --- a/src/Sql/Expression.php +++ b/src/Sql/Expression.php @@ -143,10 +143,10 @@ public function setParameters( foreach ($parameters as $parameter) { $this->parameters[] = match (true) { - is_array($parameter) => new Values($parameter), + is_array($parameter) => new Values($parameter), $parameter instanceof ExpressionInterface => new SelectArgument($parameter), - $parameter instanceof ArgumentInterface => $parameter, - default => new Value($parameter), + $parameter instanceof ArgumentInterface => $parameter, + default => new Value($parameter), }; } diff --git a/src/Sql/IdentifierPiece.php b/src/Sql/IdentifierPiece.php index b446d1a08..a3ef0743b 100644 --- a/src/Sql/IdentifierPiece.php +++ b/src/Sql/IdentifierPiece.php @@ -56,8 +56,8 @@ public static function of(string $piece, ?self $previous, bool $spaced, Platform 1 === preg_match(self::OPERATOR, $piece) || (! $isName && 1 === preg_match(self::EXPRESSION_CHARACTERS, $piece)) => self::Unquotable, - $isName => self::Name, - default => self::Whole, + $isName => self::Name, + default => self::Whole, }; } } diff --git a/src/Sql/IdentifierShape.php b/src/Sql/IdentifierShape.php index bb76cc076..b150d7d40 100644 --- a/src/Sql/IdentifierShape.php +++ b/src/Sql/IdentifierShape.php @@ -73,8 +73,8 @@ public static function of(string $name, PlatformInterface $platform): self return match (true) { null === $previous, IdentifierPiece::Dot === $previous => self::EmptyPart, - $whole => $keyword ? self::Unquotable : self::Whole, - default => self::Fragment, + $whole => $keyword ? self::Unquotable : self::Whole, + default => self::Fragment, }; } } diff --git a/src/Sql/Predicate/CustomSpecification.php b/src/Sql/Predicate/CustomSpecification.php index 305e7d36d..9b728df47 100644 --- a/src/Sql/Predicate/CustomSpecification.php +++ b/src/Sql/Predicate/CustomSpecification.php @@ -85,10 +85,10 @@ public static function expand(string $specification, array $arguments): string $isPlain = '' === $positional; $index = $isPlain ? $sequential++ : (int) $positional - 1; $run = $placeholders[$index] ?? throw InvalidArgumentException::forSpecificationArgumentOutOfRange( - $specification, - $index + 1, - count($arguments), - ); + $specification, + $index + 1, + count($arguments), + ); $plain ??= $isPlain; if ($plain !== $isPlain) { diff --git a/src/Sql/Predicate/In.php b/src/Sql/Predicate/In.php index 317d1685e..defd09407 100644 --- a/src/Sql/Predicate/In.php +++ b/src/Sql/Predicate/In.php @@ -107,8 +107,8 @@ public function setValueSet(array|Select|ArgumentInterface $valueSet): static { $this->valueSet = match (true) { $valueSet instanceof ArgumentInterface => $valueSet, - $valueSet instanceof Select => new ArgumentSelect($valueSet), - default => new Values($valueSet), + $valueSet instanceof Select => new ArgumentSelect($valueSet), + default => new Values($valueSet), }; return $this; diff --git a/src/Sql/Predicate/Operator.php b/src/Sql/Predicate/Operator.php index 1344e0625..64baa73be 100644 --- a/src/Sql/Predicate/Operator.php +++ b/src/Sql/Predicate/Operator.php @@ -119,9 +119,9 @@ public function getRight(): ?ArgumentInterface public function setLeft(string|ArgumentInterface|ExpressionInterface|SqlInterface $left): static { $this->left = match (true) { - $left instanceof ArgumentInterface => $left, + $left instanceof ArgumentInterface => $left, $left instanceof ExpressionInterface, $left instanceof SqlInterface => new Select($left), - default => new Identifier($left), + default => new Identifier($left), }; return $this; @@ -144,9 +144,9 @@ public function setRight( bool|string|int|float|ArgumentInterface|ExpressionInterface|SqlInterface|null $right, ): static { $this->right = match (true) { - $right instanceof ArgumentInterface => $right, + $right instanceof ArgumentInterface => $right, $right instanceof ExpressionInterface, $right instanceof SqlInterface => new Select($right), - default => new Value($right), + default => new Value($right), }; return $this; diff --git a/src/Sql/Predicate/PredicateSet.php b/src/Sql/Predicate/PredicateSet.php index a3f791dd9..30827f937 100644 --- a/src/Sql/Predicate/PredicateSet.php +++ b/src/Sql/Predicate/PredicateSet.php @@ -66,8 +66,8 @@ public function addPredicate(PredicateInterface $predicate, ?string $combination match ($combination) { self::OP_AND => $this->andPredicate($predicate), - self::OP_OR => $this->orPredicate($predicate), - default => throw Exception\InvalidArgumentException::forInvalidCombination(), + self::OP_OR => $this->orPredicate($predicate), + default => throw Exception\InvalidArgumentException::forInvalidCombination(), }; return $this; @@ -177,11 +177,11 @@ private function createColumnPredicate(string $key, mixed $value): PredicateInte $key, $value instanceof SqlInterface ? new Select($value) : $value, ), - null === $value => new IsNull($key), - is_array($value) => new In($key, $value), + null === $value => new IsNull($key), + is_array($value) => new In($key, $value), $value instanceof PredicateInterface => throw Exception\InvalidArgumentException::forPredicateWithStringKey(), - default => new Operator($key, Operator::OP_EQ, $value), + default => new Operator($key, Operator::OP_EQ, $value), }; } @@ -196,7 +196,7 @@ private function createListPredicate(mixed $value): PredicateInterface return match (true) { $value instanceof PredicateInterface => $value, $value instanceof Expression => new PredicateExpression($value->getExpression(), $value->getParameters()), - ! is_string($value) => throw Exception\InvalidArgumentException::forInvalidListPredicate(), + ! is_string($value) => throw Exception\InvalidArgumentException::forInvalidListPredicate(), str_contains($value, Expression::PLACEHOLDER) => new PredicateExpression($value), default => new Literal($value), }; diff --git a/src/Sql/Select.php b/src/Sql/Select.php index ad4f10620..754dfc831 100644 --- a/src/Sql/Select.php +++ b/src/Sql/Select.php @@ -413,18 +413,18 @@ public function reset(string $part): static } match ($part) { - self::TABLE => $this->table = null, + self::TABLE => $this->table = null, self::QUANTIFIER => $this->quantifier = null, - self::COLUMNS => $this->columns = [], - self::JOINS => $this->joins = null, - self::WHERE => $this->where = null, - self::GROUP => $this->group = null, - self::HAVING => $this->having = null, - self::LIMIT => $this->limit = null, - self::OFFSET => $this->offset = null, - self::ORDER => $this->order = [], - self::COMBINE => $this->combine = [], - default => null, + self::COLUMNS => $this->columns = [], + self::JOINS => $this->joins = null, + self::WHERE => $this->where = null, + self::GROUP => $this->group = null, + self::HAVING => $this->having = null, + self::LIMIT => $this->limit = null, + self::OFFSET => $this->offset = null, + self::ORDER => $this->order = [], + self::COMBINE => $this->combine = [], + default => null, }; return $this; @@ -676,11 +676,11 @@ protected function processSelect( is_string($columnIndexOrAs) ? $columnIndexOrAs : 'column', ); $columnAs = match (true) { - is_string($columnIndexOrAs) => $platform->quoteIdentifier($columnIndexOrAs), + is_string($columnIndexOrAs) => $platform->quoteIdentifier($columnIndexOrAs), stripos($columnName, needle: ' as ') === false => is_string($column) ? $platform->quoteIdentifier($column) : 'Expression' . $expr++, - default => null, + default => null, }; $columns[] = null === $columnAs ? [$columnName] : [$columnName, $columnAs]; @@ -707,10 +707,10 @@ protected function processSelect( is_string($jKey) ? $jKey : 'column', ); $jColumnAs = match (true) { - is_string($jKey) => $platform->quoteIdentifier($jKey), + is_string($jKey) => $platform->quoteIdentifier($jKey), self::SQL_STAR === $jColumn => null, - is_string($jColumn) => $platform->quoteIdentifier($jColumn), - default => 'Expression' . $expr++, + is_string($jColumn) => $platform->quoteIdentifier($jColumn), + default => 'Expression' . $expr++, }; if (null !== $jColumnAs) { diff --git a/src/TableGateway/TableGateway.php b/src/TableGateway/TableGateway.php index 3fe7b0ddc..515eecf75 100644 --- a/src/TableGateway/TableGateway.php +++ b/src/TableGateway/TableGateway.php @@ -33,8 +33,8 @@ public function __construct( $this->featureSet = match (true) { $features instanceof Feature\FeatureInterface => new Feature\FeatureSet([$features]), - is_array($features) => new Feature\FeatureSet($features), - default => $features, + is_array($features) => new Feature\FeatureSet($features), + default => $features, }; $this->resultSetPrototype = $resultSetPrototype; diff --git a/test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php b/test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php index 9c784ecf8..8a323b8e6 100644 --- a/test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php +++ b/test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php @@ -68,7 +68,7 @@ private function buildDsn(): string return match ($pdoDriver) { 'sqlite' => "sqlite:{$database}", - 'mysql' => sprintf( + 'mysql' => sprintf( 'mysql:host=%s;dbname=%s', $this->connectionParameters['hostname'] ?? 'localhost', $database, diff --git a/test/unit/Sql/AbstractSqlFunctionalTestCase.php b/test/unit/Sql/AbstractSqlFunctionalTestCase.php index b9fa11841..e00b98130 100644 --- a/test/unit/Sql/AbstractSqlFunctionalTestCase.php +++ b/test/unit/Sql/AbstractSqlFunctionalTestCase.php @@ -138,8 +138,8 @@ protected static function dataProviderCommonProcessMethods(): array ->where(['x' => 20]), 'expected' => [ 'sql92' => [ - 'string' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = \'10\') AS "b" ON "d"="e" WHERE "x" = \'20\'', - 'prepare' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = ?) AS "b" ON "d"="e" WHERE "x" = ?', + 'string' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = \'10\') AS "b" ON "d"="e" WHERE "x" = \'20\'', + 'prepare' => 'SELECT "a".*, "b".* FROM "a" INNER JOIN (SELECT "c".* FROM "c" WHERE "cc" = ?) AS "b" ON "d"="e" WHERE "x" = ?', 'parameters' => ['subselect1where1' => 10, 'where1' => 20], ], ], @@ -176,8 +176,8 @@ protected static function dataProviderCommonProcessMethods(): array ->where(['aa' => 'AA']), 'expected' => [ 'sql92' => [ - 'string' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = \'CC\') AS "b" WHERE "bb" = \'BB\') AS "a" WHERE "aa" = \'AA\'', - 'prepare' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = ?) AS "b" WHERE "bb" = ?) AS "a" WHERE "aa" = ?', + 'string' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = \'CC\') AS "b" WHERE "bb" = \'BB\') AS "a" WHERE "aa" = \'AA\'', + 'prepare' => 'SELECT "a".* FROM (SELECT "b".* FROM (SELECT "c".* FROM "c" WHERE "cc" = ?) AS "b" WHERE "bb" = ?) AS "a" WHERE "aa" = ?', 'parameters' => ['subselect2where1' => 'CC', 'subselect1where1' => 'BB', 'where1' => 'AA'], ], ], diff --git a/test/unit/Sql/SelectTest.php b/test/unit/Sql/SelectTest.php index ad74ce0bb..d8dabf212 100644 --- a/test/unit/Sql/SelectTest.php +++ b/test/unit/Sql/SelectTest.php @@ -543,8 +543,8 @@ public static function providerData(): array 'c2' => [1, 2, 3], new IsNotNull('c3'), ]); - $sqlPrep33 = 'SELECT "table".* FROM "table" WHERE "c1" IS NULL AND "c2" IN (?, ?, ?) AND "c3" IS NOT NULL'; - $sqlStr33 = 'SELECT "table".* FROM "table" WHERE "c1" IS NULL AND "c2" IN (\'1\', \'2\', \'3\') AND "c3" IS NOT NULL'; + $sqlPrep33 = 'SELECT "table".* FROM "table" WHERE "c1" IS NULL AND "c2" IN (?, ?, ?) AND "c3" IS NOT NULL'; + $sqlStr33 = 'SELECT "table".* FROM "table" WHERE "c1" IS NULL AND "c2" IN (\'1\', \'2\', \'3\') AND "c3" IS NOT NULL'; $internalTests33 = [ 'processSelect' => [[['"table".*']], '"table"'], 'processWhere' => ['"c1" IS NULL AND "c2" IN (?, ?, ?) AND "c3" IS NOT NULL'], @@ -686,8 +686,8 @@ public static function providerData(): array $select44Other = new Select(); $select44Other->from('bar')->where('c = d'); $select44->combine($select44Other, Select::COMBINE_UNION, 'ALL'); - $sqlPrep44 = '( SELECT "foo".* FROM "foo" WHERE a = b ) UNION ALL ( SELECT "bar".* FROM "bar" WHERE c = d )'; - $sqlStr44 = '( SELECT "foo".* FROM "foo" WHERE a = b ) UNION ALL ( SELECT "bar".* FROM "bar" WHERE c = d )'; + $sqlPrep44 = '( SELECT "foo".* FROM "foo" WHERE a = b ) UNION ALL ( SELECT "bar".* FROM "bar" WHERE c = d )'; + $sqlStr44 = '( SELECT "foo".* FROM "foo" WHERE a = b ) UNION ALL ( SELECT "bar".* FROM "bar" WHERE c = d )'; $internalTests44 = [ 'processCombine' => ['UNION ALL', 'SELECT "bar".* FROM "bar" WHERE c = d'], ];