Skip to content

Commit

Permalink
Merge pull request #5624 from greg0ire/cs-update
Browse files Browse the repository at this point in the history
Upgrade to doctrine/coding-standard 10
  • Loading branch information
greg0ire committed Aug 28, 2022
2 parents dfc38cd + ec507e2 commit a24b89d
Show file tree
Hide file tree
Showing 322 changed files with 1,828 additions and 2,862 deletions.
2 changes: 1 addition & 1 deletion bin/doctrine-dbal.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
STDERR,
'[Warning] The use of this script is discouraged.'
. ' You find instructions on how to boostrap the console runner in our documentation.'
. PHP_EOL
. PHP_EOL,
);

echo PHP_EOL . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"psr/log": "^1|^2|^3"
},
"require-dev": {
"doctrine/coding-standard": "9.0.2",
"doctrine/coding-standard": "10.0.0",
"jetbrains/phpstorm-stubs": "2022.2",
"phpstan/phpstan": "1.8.2",
"phpstan/phpstan-strict-rules": "^1.3",
Expand Down
4 changes: 1 addition & 3 deletions src/ArrayParameters/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use Throwable;

/**
* @internal
*/
/** @internal */
interface Exception extends Throwable
{
}
6 changes: 2 additions & 4 deletions src/ArrayParameters/Exception/MissingNamedParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

use function sprintf;

/**
* @psalm-immutable
*/
/** @psalm-immutable */
class MissingNamedParameter extends LogicException implements Exception
{
public static function new(string $name): self
{
return new self(
sprintf('Named parameter "%s" does not have a bound value.', $name)
sprintf('Named parameter "%s" does not have a bound value.', $name),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MissingPositionalParameter extends LogicException implements Exception
public static function new(int $index): self
{
return new self(
sprintf('Positional parameter at index %d does not have a bound value.', $index)
sprintf('Positional parameter at index %d does not have a bound value.', $index),
);
}
}
12 changes: 3 additions & 9 deletions src/Cache/ArrayResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
use function count;
use function reset;

/**
* @internal The class is internal to the caching layer implementation.
*/
/** @internal The class is internal to the caching layer implementation. */
final class ArrayResult implements Result
{
/** @var list<array<string, mixed>> */
Expand All @@ -20,9 +18,7 @@ final class ArrayResult implements Result
private int $columnCount = 0;
private int $num = 0;

/**
* @param list<array<string, mixed>> $data
*/
/** @param list<array<string, mixed>> $data */
public function __construct(array $data)
{
$this->data = $data;
Expand Down Expand Up @@ -108,9 +104,7 @@ public function free(): void
$this->data = [];
}

/**
* @return array<string, mixed>|false
*/
/** @return array<string, mixed>|false */
private function fetch()
{
if (! isset($this->data[$this->num])) {
Expand Down
12 changes: 3 additions & 9 deletions src/Cache/CacheException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@

use Doctrine\DBAL\Exception;

/**
* @psalm-immutable
*/
/** @psalm-immutable */
class CacheException extends Exception
{
/**
* @return CacheException
*/
/** @return CacheException */
public static function noCacheKey()
{
return new self('No cache key was set.');
}

/**
* @return CacheException
*/
/** @return CacheException */
public static function noResultDriverConfigured()
{
return new self('Trying to cache a query but no result driver is configured.');
Expand Down
12 changes: 5 additions & 7 deletions src/Cache/QueryCacheProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct($lifetime = 0, $cacheKey = null, ?object $resultCach
'Passing an instance of %s to %s as $resultCache is deprecated. Pass an instance of %s instead.',
Cache::class,
__METHOD__,
CacheItemPoolInterface::class
CacheItemPoolInterface::class,
);

$this->resultCache = CacheAdapter::wrap($resultCache);
Expand All @@ -58,7 +58,7 @@ public function __construct($lifetime = 0, $cacheKey = null, ?object $resultCach
'$resultCache: Expected either null or an instance of %s or %s, got %s.',
CacheItemPoolInterface::class,
Cache::class,
get_class($resultCache)
get_class($resultCache),
));
}
}
Expand All @@ -79,15 +79,13 @@ public function getResultCacheDriver()
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4620',
'%s is deprecated, call getResultCache() instead.',
__METHOD__
__METHOD__,
);

return $this->resultCache !== null ? DoctrineProvider::wrap($this->resultCache) : null;
}

/**
* @return int
*/
/** @return int */
public function getLifetime()
{
return $this->lifetime;
Expand Down Expand Up @@ -154,7 +152,7 @@ public function setResultCacheDriver(Cache $cache)
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4620',
'%s is deprecated, call setResultCache() instead.',
__METHOD__
__METHOD__,
);

return new QueryCacheProfile($this->lifetime, $this->cacheKey, CacheAdapter::wrap($cache));
Expand Down
14 changes: 6 additions & 8 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function setSQLLogger(?SQLLogger $logger = null): void
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4967',
'%s is deprecated, use setMiddlewares() and Logging\\Middleware instead.',
__METHOD__
__METHOD__,
);

$this->sqlLogger = $logger;
Expand All @@ -90,7 +90,7 @@ public function getSQLLogger(): ?SQLLogger
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4967',
'%s is deprecated.',
__METHOD__
__METHOD__,
);

return $this->sqlLogger;
Expand All @@ -115,7 +115,7 @@ public function getResultCacheImpl(): ?Cache
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4620',
'%s is deprecated, call getResultCache() instead.',
__METHOD__
__METHOD__,
);

return $this->resultCacheImpl;
Expand All @@ -141,7 +141,7 @@ public function setResultCacheImpl(Cache $cacheImpl): void
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/4620',
'%s is deprecated, call setResultCache() instead.',
__METHOD__
__METHOD__,
);

$this->resultCacheImpl = $cacheImpl;
Expand All @@ -158,7 +158,7 @@ public function setSchemaAssetsFilter(?callable $callable = null): void
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5483',
'Not passing an argument to %s is deprecated.',
__METHOD__
__METHOD__,
);
} elseif ($callable === null) {
Deprecation::trigger(
Expand Down Expand Up @@ -220,9 +220,7 @@ public function setMiddlewares(array $middlewares): self
return $this;
}

/**
* @return Middleware[]
*/
/** @return Middleware[] */
public function getMiddlewares(): array
{
return $this->middlewares;
Expand Down
36 changes: 16 additions & 20 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function getExpressionBuilder()
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4515',
'Connection::getExpressionBuilder() is deprecated,'
. ' use Connection::createExpressionBuilder() instead.'
. ' use Connection::createExpressionBuilder() instead.',
);

return $this->_expr;
Expand All @@ -315,7 +315,7 @@ public function connect()
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4966',
'Public access to Connection::connect() is deprecated.'
'Public access to Connection::connect() is deprecated.',
);

if ($this->_conn !== null) {
Expand Down Expand Up @@ -445,7 +445,7 @@ private function getServerVersion()
'doctrine/dbal',
'https://github.com/doctrine/dbal/pulls/4750',
'Not implementing the ServerInfoAwareConnection interface in %s is deprecated',
get_class($connection)
get_class($connection),
);

// Unable to detect platform version.
Expand Down Expand Up @@ -626,7 +626,7 @@ public function delete($table, array $criteria, array $types = [])
return $this->executeStatement(
'DELETE FROM ' . $table . ' WHERE ' . implode(' AND ', $conditions),
$values,
is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types
is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types,
);
}

Expand Down Expand Up @@ -738,7 +738,7 @@ public function insert($table, array $data, array $types = [])
'INSERT INTO ' . $table . ' (' . implode(', ', $columns) . ')' .
' VALUES (' . implode(', ', $set) . ')',
$values,
is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types
is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types,
);
}

Expand Down Expand Up @@ -1172,7 +1172,7 @@ public function lastInsertId($name = null)
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4687',
'The usage of Connection::lastInsertId() with a sequence name is deprecated.'
'The usage of Connection::lastInsertId() with a sequence name is deprecated.',
);
}

Expand Down Expand Up @@ -1233,7 +1233,7 @@ public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoint
Nesting transactions without enabling savepoints is deprecated.
Call %s::setNestTransactionsWithSavepoints(true) to enable savepoints.
DEPRECATION,
self::class
self::class,
);
}

Expand Down Expand Up @@ -1308,7 +1308,7 @@ public function beginTransaction()
Nesting transactions without enabling savepoints is deprecated.
Call %s::setNestTransactionsWithSavepoints(true) to enable savepoints.
DEPRECATION,
self::class
self::class,
);
}

Expand Down Expand Up @@ -1523,7 +1523,7 @@ public function getWrappedConnection()
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4966',
'Connection::getWrappedConnection() is deprecated.'
. ' Use Connection::getNativeConnection() to access the native connection.'
. ' Use Connection::getNativeConnection() to access the native connection.',
);

$this->connect();
Expand All @@ -1533,9 +1533,7 @@ public function getWrappedConnection()
return $this->_conn;
}

/**
* @return resource|object
*/
/** @return resource|object */
public function getNativeConnection()
{
$this->connect();
Expand All @@ -1544,7 +1542,7 @@ public function getNativeConnection()
if (! method_exists($this->_conn, 'getNativeConnection')) {
throw new LogicException(sprintf(
'The driver connection %s does not support accessing the native connection.',
get_class($this->_conn)
get_class($this->_conn),
));
}

Expand All @@ -1561,7 +1559,7 @@ public function createSchemaManager(): AbstractSchemaManager
{
return $this->_driver->getSchemaManager(
$this,
$this->getDatabasePlatform()
$this->getDatabasePlatform(),
);
}

Expand All @@ -1580,7 +1578,7 @@ public function getSchemaManager()
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4515',
'Connection::getSchemaManager() is deprecated, use Connection::createSchemaManager() instead.'
'Connection::getSchemaManager() is deprecated, use Connection::createSchemaManager() instead.',
);

return $this->_schemaManager ??= $this->createSchemaManager();
Expand Down Expand Up @@ -1677,7 +1675,7 @@ private function bindParameters(DriverStatement $stmt, array $params, array $typ
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5550',
'Using NULL as prepared statement parameter type is deprecated.'
. 'Omit or use Parameter::STRING instead'
. 'Omit or use Parameter::STRING instead',
);
}

Expand All @@ -1700,7 +1698,7 @@ private function bindParameters(DriverStatement $stmt, array $params, array $typ
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5550',
'Using NULL as prepared statement parameter type is deprecated.'
. 'Omit or use Parameter::STRING instead'
. 'Omit or use Parameter::STRING instead',
);
}

Expand Down Expand Up @@ -1763,9 +1761,7 @@ final public function convertExceptionDuringQuery(
return $this->handleDriverException($e, new Query($sql, $params, $types));
}

/**
* @internal
*/
/** @internal */
final public function convertException(Driver\Exception $e): DriverException
{
return $this->handleDriverException($e, null);
Expand Down

0 comments on commit a24b89d

Please sign in to comment.