Skip to content

Commit

Permalink
Merge pull request #4150 from morozov/coding-standard-8.1
Browse files Browse the repository at this point in the history
Update doctrine/coding-standard to 8.1
  • Loading branch information
morozov authored Jul 6, 2020
2 parents 7dc2138 + 8739b52 commit 61a0113
Show file tree
Hide file tree
Showing 324 changed files with 2,653 additions and 2,380 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"doctrine/event-manager": "^1.0"
},
"require-dev": {
"doctrine/coding-standard": "^7.0",
"doctrine/coding-standard": "^8.1",
"jetbrains/phpstorm-stubs": "^2019.1",
"nikic/php-parser": "^4.4",
"phpstan/phpstan": "^0.12.31",
Expand Down
41 changes: 18 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Cache/ArrayStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use InvalidArgumentException;
use IteratorAggregate;
use PDO;

use function array_merge;
use function array_values;
use function count;
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Cache/QueryCacheProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Cache;

use Doctrine\Common\Cache\Cache;

use function hash;
use function serialize;
use function sha1;
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use InvalidArgumentException;
use IteratorAggregate;
use PDO;

use function array_merge;
use function array_values;
use function assert;
Expand Down
7 changes: 4 additions & 3 deletions lib/Doctrine/DBAL/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\Common\Cache\Cache;
use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\Schema\AbstractAsset;

use function preg_match;

/**
Expand Down Expand Up @@ -101,7 +102,7 @@ public function getFilterSchemaAssetsExpression()
/**
* @param string $filterExpression
*/
private function buildSchemaAssetsFilterFromExpression($filterExpression) : callable
private function buildSchemaAssetsFilterFromExpression($filterExpression): callable
{
return static function ($assetName) use ($filterExpression) {
if ($assetName instanceof AbstractAsset) {
Expand All @@ -115,7 +116,7 @@ private function buildSchemaAssetsFilterFromExpression($filterExpression) : call
/**
* Sets the callable to use to filter schema assets.
*/
public function setSchemaAssetsFilter(?callable $callable = null) : ?callable
public function setSchemaAssetsFilter(?callable $callable = null): ?callable
{
$this->_attributes['filterSchemaAssetsExpression'] = null;

Expand All @@ -125,7 +126,7 @@ public function setSchemaAssetsFilter(?callable $callable = null) : ?callable
/**
* Returns the callable to use to filter schema assets.
*/
public function getSchemaAssetsFilter() : ?callable
public function getSchemaAssetsFilter(): ?callable
{
return $this->_attributes['filterSchemaAssetsExpressionCallable'] ?? null;
}
Expand Down
7 changes: 4 additions & 3 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Doctrine\DBAL\Types\Type;
use Exception;
use Throwable;

use function array_key_exists;
use function assert;
use function func_get_args;
Expand Down Expand Up @@ -382,7 +383,7 @@ public function connect()
*
* @throws DBALException If an invalid platform was specified for this connection.
*/
private function detectDatabasePlatform() : void
private function detectDatabasePlatform(): void
{
$version = $this->getDatabasePlatformVersion();

Expand Down Expand Up @@ -622,7 +623,7 @@ private function addIdentifierCondition(
array &$columns,
array &$values,
array &$conditions
) : void {
): void {
$platform = $this->getDatabasePlatform();

foreach ($identifier as $columnName => $value) {
Expand Down Expand Up @@ -1323,7 +1324,7 @@ public function commit()
/**
* Commits all current nesting transactions.
*/
private function commitAll() : void
private function commitAll(): void
{
while ($this->transactionNestingLevel !== 0) {
if ($this->autoCommit === false && $this->transactionNestingLevel === 1) {
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Events;
use InvalidArgumentException;

use function array_rand;
use function assert;
use function count;
Expand Down
9 changes: 5 additions & 4 deletions lib/Doctrine/DBAL/DBALException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Types\Type;
use Exception;
use Throwable;

use function array_map;
use function bin2hex;
use function get_class;
Expand Down Expand Up @@ -37,7 +38,7 @@ public static function notSupported($method)
return new self(sprintf("Operation '%s' is not supported by platform.", $method));
}

public static function invalidPlatformSpecified() : self
public static function invalidPlatformSpecified(): self
{
return new self(
"Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.'
Expand All @@ -47,7 +48,7 @@ public static function invalidPlatformSpecified() : self
/**
* @param mixed $invalidPlatform
*/
public static function invalidPlatformType($invalidPlatform) : self
public static function invalidPlatformType($invalidPlatform): self
{
if (is_object($invalidPlatform)) {
return new self(
Expand Down Expand Up @@ -285,12 +286,12 @@ public static function typeNotFound($name)
return new self('Type to be overwritten ' . $name . ' does not exist.');
}

public static function typeNotRegistered(Type $type) : self
public static function typeNotRegistered(Type $type): self
{
return new self(sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type)));
}

public static function typeAlreadyRegistered(Type $type) : self
public static function typeAlreadyRegistered(Type $type): self
{
return new self(
sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type))
Expand Down
29 changes: 17 additions & 12 deletions lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;

use function assert;
use function preg_match;
use function stripos;
Expand Down Expand Up @@ -143,13 +144,15 @@ public function createDatabasePlatformForVersion($version)
*
* @throws DBALException
*/
private function getOracleMysqlVersionNumber(string $versionString) : string
private function getOracleMysqlVersionNumber(string $versionString): string
{
if (! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/',
$versionString,
$versionParts
)) {
if (
! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/',
$versionString,
$versionParts
)
) {
throw DBALException::invalidPlatformVersionSpecified(
$versionString,
'<major_version>.<minor_version>.<patch_version>'
Expand All @@ -175,13 +178,15 @@ private function getOracleMysqlVersionNumber(string $versionString) : string
*
* @throws DBALException
*/
private function getMariaDbMysqlVersionNumber(string $versionString) : string
private function getMariaDbMysqlVersionNumber(string $versionString): string
{
if (! preg_match(
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
$versionString,
$versionParts
)) {
if (
! preg_match(
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
$versionString,
$versionParts
)
) {
throw DBALException::invalidPlatformVersionSpecified(
$versionString,
'^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private function __construct(string $string)
$this->string = $string;
}

public function __toString() : string
public function __toString(): string
{
return $this->string;
}
Expand All @@ -33,7 +33,7 @@ public function __toString() : string
*
* @param mixed[] $params
*/
public static function fromArray(array $params) : self
public static function fromArray(array $params): self
{
return new self(self::renderParams($params));
}
Expand All @@ -43,7 +43,7 @@ public static function fromArray(array $params) : self
*
* @param mixed[] $params
*/
public static function fromConnectionParameters(array $params) : self
public static function fromConnectionParameters(array $params): self
{
if (! empty($params['connectstring'])) {
return new self($params['connectstring']);
Expand Down Expand Up @@ -90,7 +90,7 @@ public static function fromConnectionParameters(array $params) : self
/**
* @param mixed[] $params
*/
private static function renderParams(array $params) : string
private static function renderParams(array $params): string
{
$chunks = [];

Expand All @@ -110,7 +110,7 @@ private static function renderParams(array $params) : string
/**
* @param mixed $value
*/
private static function renderValue($value) : string
private static function renderValue($value): string
{
if (is_array($value)) {
return self::renderParams($value);
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;

use function assert;
use function preg_match;
use function strpos;
Expand Down
13 changes: 8 additions & 5 deletions lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;

use function assert;
use function preg_match;
use function version_compare;
Expand Down Expand Up @@ -81,11 +82,13 @@ public function convertException($message, DriverException $exception)
*/
public function createDatabasePlatformForVersion($version)
{
if (! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
$version,
$versionParts
)) {
if (
! preg_match(
'/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+)(?:\.(?P<build>\d+))?)?)?/',
$version,
$versionParts
)
) {
throw DBALException::invalidPlatformVersionSpecified(
$version,
'<major_version>.<minor_version>.<patch_version>.<build_version>'
Expand Down
Loading

0 comments on commit 61a0113

Please sign in to comment.