Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@
'no_unused_imports' => true,
'ordered_class_elements' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'fully_qualified_strict_types' => [
'import_symbols' => true
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
])
->setFinder($finder);
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Bug #1127: Fix `AbstractSchema::hasTable()` and `AbstractSchema::hasView()` methods to support names quoted with curly
brackets `{{%table}}` (@batyrmastyr)
- Enh #1145: Explicitly import classes, functions, and constants in "use" section (@mspirkov)

## 2.0.0 December 05, 2025

Expand Down
7 changes: 4 additions & 3 deletions src/Cache/SchemaCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Psr\SimpleCache\InvalidArgumentException;
use RuntimeException;
use Yiisoft\Db\Exception\PsrInvalidArgumentException;
use Yiisoft\Db\Schema\AbstractSchema;

use function in_array;
use function is_int;
Expand All @@ -22,13 +23,13 @@
/**
* Implements a cache for the database schema information.
*
* The {@see \Yiisoft\Db\Schema\AbstractSchema} retrieves information about the database schema from the database server
* and stores it in the cache for faster access. When the {@see \Yiisoft\Db\Schema\AbstractSchema} needs to retrieve
* The {@see AbstractSchema} retrieves information about the database schema from the database server
* and stores it in the cache for faster access. When the {@see AbstractSchema} needs to retrieve
* information about the database schema, it first checks the cache using {@see SchemaCache}. If the information is
* not in the cache, the Schema retrieves it from the database server and stores it in the cache using the
* {@see SchemaCache}.
*
* {@see \Yiisoft\Db\Schema\AbstractSchema} uses this implementation to cache table metadata.
* {@see AbstractSchema} uses this implementation to cache table metadata.
*/
final class SchemaCache
{
Expand Down
4 changes: 2 additions & 2 deletions src/Driver/Pdo/AbstractPdoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(PdoConnectionInterface $db)
}

/**
* This method mainly sets {@see pdoStatement} to be `null`.
* This method mainly sets {@see PDOStatement} to be `null`.
*/
public function cancel(): void
{
Expand Down Expand Up @@ -165,7 +165,7 @@ public function prepare(?bool $forRead = null): void
/**
* Binds pending parameters registered via {@see bindValue()} and {@see bindValues()}.
*
* Note that this method requires an active {@see pdoStatement}.
* Note that this method requires an active {@see PDOStatement}.
*/
protected function bindPendingParams(): void
{
Expand Down
3 changes: 2 additions & 1 deletion src/Driver/Pdo/PdoDataReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Yiisoft\Db\Query\DataReaderInterface;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\Schema\Column\ColumnInterface;
use Yiisoft\Db\Command\AbstractCommand;

use function is_string;

Expand All @@ -21,7 +22,7 @@
*
* A data reader is an object that can be used to read a forward-only stream of rows from a database.
*
* It's typically used in combination with a command object, such as a {@see \Yiisoft\Db\Command\AbstractCommand},
* It's typically used in combination with a command object, such as a {@see AbstractCommand},
* to execute a SELECT statement and read the results.
*
* The class provides methods for accessing the data returned by the query.
Expand Down
4 changes: 3 additions & 1 deletion src/Exception/PsrInvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Yiisoft\Db\Exception;

use Psr\SimpleCache\InvalidArgumentException;

/**
* Represents an exception that's caused by invalid operations of cache.
*/
final class PsrInvalidArgumentException extends Exception implements \Psr\SimpleCache\InvalidArgumentException {}
final class PsrInvalidArgumentException extends Exception implements InvalidArgumentException {}
3 changes: 2 additions & 1 deletion src/Expression/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Stringable;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Query\QueryInterface;

/**
* Represents a DB expression that doesn't need escaping or quoting.
Expand All @@ -22,7 +23,7 @@
* ```
*
* Expression objects are mainly created for passing raw SQL expressions to methods of
* {@see \Yiisoft\Db\Query\QueryInterface} and related classes.
* {@see QueryInterface} and related classes.
*
* @psalm-import-type ParamsType from ConnectionInterface
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Helper\DbArrayHelper;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;

use function array_column;
use function array_combine;
Expand Down Expand Up @@ -71,7 +72,7 @@
* $rows = $command->queryAll();
* ```
*
* Query internally uses the {@see \Yiisoft\Db\QueryBuilder\AbstractQueryBuilder} class to generate the SQL statement.
* Query internally uses the {@see AbstractQueryBuilder} class to generate the SQL statement.
*
* @psalm-import-type SelectValue from QueryPartsInterface
* @psalm-import-type IndexBy from QueryInterface
Expand Down
3 changes: 2 additions & 1 deletion src/Query/QueryExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
use Yiisoft\Db\Expression\ExpressionBuilderInterface;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;

/**
* Used internally to build a {@see Query} object using unified {@see \Yiisoft\Db\QueryBuilder\AbstractQueryBuilder}
* Used internally to build a {@see Query} object using unified {@see AbstractQueryBuilder}
* expression building interface.
*
* @implements ExpressionBuilderInterface<QueryInterface>
Expand Down
3 changes: 2 additions & 1 deletion src/QueryBuilder/Condition/ConditionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

use InvalidArgumentException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\QueryBuilder\QueryBuilder;

/**
* Should be implemented by classes that represent a condition in the {@see \Yiisoft\Db\QueryBuilder\QueryBuilder}.
* Should be implemented by classes that represent a condition in the {@see QueryBuilder}.
*/
interface ConditionInterface extends ExpressionInterface
{
Expand Down
4 changes: 3 additions & 1 deletion src/Schema/Column/JsonColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Yiisoft\Db\Schema\Column;

use JsonException;

use function is_string;
use function json_decode;

Expand All @@ -17,7 +19,7 @@
final class JsonColumn extends AbstractJsonColumn
{
/**
* @throws \JsonException
* @throws JsonException
*/
public function phpTypecast(mixed $value): mixed
{
Expand Down
6 changes: 4 additions & 2 deletions src/Schema/Quoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use InvalidArgumentException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Command\AbstractCommand;
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;

use function addcslashes;
use function array_map;
Expand All @@ -27,9 +29,9 @@
* It provides a set of methods for quoting different types of names, such as table names, column names, and schema
* names.
*
* The Quoter class is used by {@see \Yiisoft\Db\QueryBuilder\AbstractQueryBuilder} to quote names.
* The Quoter class is used by {@see AbstractQueryBuilder} to quote names.
*
* It's also used by {@see \Yiisoft\Db\Command\AbstractCommand} to quote names in SQL statements before passing them to
* It's also used by {@see AbstractCommand} to quote names in SQL statements before passing them to
* database servers.
*/
class Quoter implements QuoterInterface
Expand Down
3 changes: 2 additions & 1 deletion src/Transaction/TransactionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Connection\ConnectionInterface;

/**
* Defines the interface for a database transaction.
Expand Down Expand Up @@ -69,7 +70,7 @@ interface TransactionInterface
*
* @throws Exception
* @throws Throwable If DB connection fails or the current transaction is active.
* @throws InvalidConfigException If {@see \Yiisoft\Db\Connection\ConnectionInterface} is `null` or invalid.
* @throws InvalidConfigException If {@see ConnectionInterface} is `null` or invalid.
* @throws NotSupportedException If the DBMS doesn't support nested transactions or the transaction is active.
*/
public function begin(?string $isolationLevel = null): void;
Expand Down
10 changes: 6 additions & 4 deletions tests/Db/Driver/Pdo/PdoDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use PHPUnit\Framework\TestCase;
use Yiisoft\Db\Tests\Support\Assert;
use Yiisoft\Db\Tests\Support\Stub\StubPdoDriver;
use SensitiveParameterValue;
use TypeError;

/**
* @group db
Expand Down Expand Up @@ -71,14 +73,14 @@ public function testSensitiveParameter(): void
$dsn = 'sqlite::memory:';
try {
new StubPdoDriver($dsn, password: null);
} catch (\TypeError $e) {
$this->assertTrue($e->getTrace()[0]['args'][2] instanceof \SensitiveParameterValue);
} catch (TypeError $e) {
$this->assertTrue($e->getTrace()[0]['args'][2] instanceof SensitiveParameterValue);
}
$pdoDriver = new StubPdoDriver($dsn);
try {
$pdoDriver->password(null);
} catch (\TypeError $e) {
$this->assertTrue($e->getTrace()[0]['args'][0] instanceof \SensitiveParameterValue);
} catch (TypeError $e) {
$this->assertTrue($e->getTrace()[0]['args'][0] instanceof SensitiveParameterValue);
}
}
}
3 changes: 2 additions & 1 deletion tests/Db/Helper/DbArrayHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPUnit\Framework\TestCase;
use Yiisoft\Db\Helper\DbArrayHelper;
use Yiisoft\Db\Tests\Provider\DbArrayHelperProvider;
use Exception;

/**
* @group db
Expand Down Expand Up @@ -60,7 +61,7 @@ public function testArrangeWithNonExistingKey(): void

set_error_handler(static function (int $errno, string $errstr) {
restore_error_handler();
throw new \Exception('E_WARNING: ' . $errstr, $errno);
throw new Exception('E_WARNING: ' . $errstr, $errno);
}, E_WARNING);

$this->expectExceptionMessage('E_WARNING: Undefined array key "non-existing-key"');
Expand Down
8 changes: 4 additions & 4 deletions tests/Provider/QueryBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ public static function multiOperandFunctionBuilder(): iterable
];
yield 'Greatest with 4 operands' => [
Greatest::class,
static fn(Connectioninterface $db) => [1, 1.5, '(1 + 2)', $db->select(10)],
static fn(ConnectionInterface $db) => [1, 1.5, '(1 + 2)', $db->select(10)],
"GREATEST(1, 1.5, (1 + 2), (SELECT 10))",
10,
];
Expand All @@ -1908,7 +1908,7 @@ public static function multiOperandFunctionBuilder(): iterable
];
yield 'Least with 4 operands' => [
Least::class,
static fn(Connectioninterface $db) => [1, 1.5, '(1 + 2)', $db->select(10)],
static fn(ConnectionInterface $db) => [1, 1.5, '(1 + 2)', $db->select(10)],
"LEAST(1, 1.5, (1 + 2), (SELECT 10))",
1,
];
Expand All @@ -1931,7 +1931,7 @@ public static function multiOperandFunctionBuilder(): iterable
];
yield 'Longest with 3 operands' => [
Longest::class,
static fn(Connectioninterface $db) => [
static fn(ConnectionInterface $db) => [
new Value('short'),
$db->select(new Expression("'longest'")),
new Param('string', DataType::STRING),
Expand Down Expand Up @@ -1962,7 +1962,7 @@ public static function multiOperandFunctionBuilder(): iterable
];
yield 'Shortest with 3 operands' => [
Shortest::class,
static fn(Connectioninterface $db) => [
static fn(ConnectionInterface $db) => [
new Value('short'),
$db->select(new Expression("'longest'")),
new Param('string', DataType::STRING),
Expand Down
Loading