Skip to content

Commit

Permalink
Merge branch '3.0.x' into 3.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Mar 31, 2021
2 parents 012569d + ab91c62 commit 7de2292
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 36 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: "Static Analysis"

on:
Expand Down Expand Up @@ -34,7 +33,7 @@ jobs:
uses: "ramsey/composer-install@v1"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"
run: "vendor/bin/phpstan --error-format=checkstyle | cs2pr"

static-analysis-psalm:
name: "Static Analysis with Psalm"
Expand All @@ -50,6 +49,6 @@ jobs:
uses: actions/checkout@v2

- name: Psalm
uses: docker://vimeo/psalm-github-actions:4.5.2
uses: docker://vimeo/psalm-github-actions:4.6.4
with:
composer_require_dev: true
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@
"php": "^7.3 || ^8.0",
"composer/package-versions-deprecated": "^1.11.99",
"doctrine/cache": "^1.0",
"doctrine/deprecations": "^0.5.3",
"doctrine/event-manager": "^1.0"
},
"require-dev": {
"doctrine/coding-standard": "8.2.0",
"jetbrains/phpstorm-stubs": "2019.3",
"phpstan/phpstan": "0.12.80",
"jetbrains/phpstorm-stubs": "2020.2",
"phpstan/phpstan": "0.12.81",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "9.5.0",
"psalm/plugin-phpunit": "0.13.0",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
"vimeo/psalm": "4.5.2"
"vimeo/psalm": "4.6.4"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
Expand Down
14 changes: 1 addition & 13 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parameters:
- '~^Return type \(int\|false\) of method Doctrine\\DBAL\\Driver\\OCI8\\Connection\:\:lastInsertId\(\) should be compatible with return type \(string\) of method Doctrine\\DBAL\\Driver\\Connection::lastInsertId\(\)~'
- '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\Connection::lastInsertId\(\) should return string but returns int\|string\.$~'

# https://github.com/phpstan/phpstan/issues/2857
# https://github.com/doctrine/dbal/pull/3836
# TODO: remove in 4.0.0
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'

Expand All @@ -30,11 +30,6 @@ parameters:
# weird class name, represented in stubs as OCI_(Lob|Collection)
- '~unknown class OCI-(Lob|Collection)~'

# https://github.com/phpstan/phpstan/issues/3132
-
message: '~^Call to function in_array\(\) with arguments Doctrine\\DBAL\\Schema\\Column, array<string> and true will always evaluate to false\.$~'
path: %currentWorkingDirectory%/src/Schema/Table.php

# Requires a release of https://github.com/JetBrains/phpstorm-stubs/pull/553
-
message: '~^Call to function assert\(\) with true will always evaluate to true\.$~'
Expand Down Expand Up @@ -89,13 +84,6 @@ parameters:
paths:
- %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.php

# Caused by phpdoc annotations intended for Psalm
-
message: '~Unable to resolve the template type T in call to method static method Doctrine\\DBAL\\DriverManager::getConnection\(\)~'
paths:
- %currentWorkingDirectory%/src/Id/TableGenerator.php
- %currentWorkingDirectory%/src/Schema/SqliteSchemaManager.php

# Unlike Psalm, PHPStan doesn't understand the shape of the parse_str() return value
-
message: '~^Parameter #1 \$scheme of static method Doctrine\\DBAL\\DriverManager::parseDatabaseUrlScheme\(\) expects string\|null, int\|string\|null given\.$~'
Expand Down
12 changes: 2 additions & 10 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@
-->
<file name="src/Platforms/MySQLPlatform.php"/>
<!--
See https://github.com/vimeo/psalm/issues/5305
Requires a release of
https://github.com/JetBrains/phpstorm-stubs/commit/43ce0bb13e927b9eb69cc06c16ab22f548c4735b
-->
<file name="src/Driver/Mysqli/Connection.php"/>
</errorLevel>
Expand All @@ -261,15 +262,6 @@
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
</ReferenceConstraintViolation>
<TooFewArguments>
<errorLevel type="suppress">
<!--
Requires a release of
https://github.com/JetBrains/phpstorm-stubs/pull/727
-->
<file name="src/Driver/SQLSrv/Statement.php"/>
</errorLevel>
</TooFewArguments>
<TooManyArguments>
<errorLevel type="suppress">
<!-- See https://github.com/doctrine/dbal/pull/3562 -->
Expand Down
10 changes: 10 additions & 0 deletions src/Event/SchemaAlterTableAddColumnEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\Deprecations\Deprecation;

use function array_merge;
use function func_get_args;
Expand Down Expand Up @@ -67,6 +68,15 @@ public function getPlatform()
*/
public function addSql($sql)
{
if (is_array($sql)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3580',
'Passing multiple SQL statements as an array to SchemaAlterTableAddColumnEventaArrgs::addSql() ' .
'is deprecated. Pass each statement as an individual argument instead.'
);
}

$this->sql = array_merge($this->sql, is_array($sql) ? $sql : func_get_args());

return $this;
Expand Down
10 changes: 5 additions & 5 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;
use InvalidArgumentException;
use UnexpectedValueException;

Expand Down Expand Up @@ -58,9 +59,6 @@
use function strpos;
use function strtolower;
use function strtoupper;
use function trigger_error;

use const E_USER_DEPRECATED;

/**
* Base class for all DatabasePlatforms. The DatabasePlatforms are the central
Expand Down Expand Up @@ -245,12 +243,14 @@ public function getBinaryTypeDeclarationSQL(array $column)

if ($column['length'] > $maxLength) {
if ($maxLength > 0) {
@trigger_error(sprintf(
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3187',
'Binary column length %d is greater than supported by the platform (%d).'
. ' Reduce the column length or use a BLOB column instead.',
$column['length'],
$maxLength
), E_USER_DEPRECATED);
);
}

return $this->getBlobTypeDeclarationSQL($column);
Expand Down
19 changes: 19 additions & 0 deletions src/Query/Expression/CompositeExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Query\Expression;

use Countable;
use Doctrine\Deprecations\Deprecation;

use function array_merge;
use function count;
Expand Down Expand Up @@ -48,6 +49,12 @@ public function __construct($type, array $parts = [])
$this->type = $type;

$this->addMultiple($parts);

Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/3864',
'Do not use CompositeExpression constructor directly, use static and() and or() factory methods.'
);
}

/**
Expand Down Expand Up @@ -79,6 +86,12 @@ public static function or($part, ...$parts): self
*/
public function addMultiple(array $parts = [])
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3844',
'CompositeExpression::addMultiple() is deprecated, use CompositeExpression::with() instead.'
);

foreach ($parts as $part) {
$this->add($part);
}
Expand All @@ -97,6 +110,12 @@ public function addMultiple(array $parts = [])
*/
public function add($part)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3844',
'CompositeExpression::add() is deprecated, use CompositeExpression::with() instead.'
);

if ($part === null) {
return $this;
}
Expand Down
13 changes: 13 additions & 0 deletions src/Query/Expression/ExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Query\Expression;

use Doctrine\DBAL\Connection;
use Doctrine\Deprecations\Deprecation;

use function func_get_arg;
use function func_get_args;
Expand Down Expand Up @@ -71,6 +72,12 @@ public function or($expression, ...$expressions): CompositeExpression
*/
public function andX($x = null)
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/3851',
'ExpressionBuilder::andX() is deprecated, use ExpressionBuilder::and() instead.'
);

return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
}

Expand All @@ -84,6 +91,12 @@ public function andX($x = null)
*/
public function orX($x = null)
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/3851',
'ExpressionBuilder::orX() is deprecated, use ExpressionBuilder::or() instead.'
);

return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
}

Expand Down
39 changes: 38 additions & 1 deletion src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;

use function array_key_exists;
use function array_keys;
Expand Down Expand Up @@ -371,7 +372,7 @@ public function getSQL()
*
* @param int|string $key Parameter position or name
* @param mixed $value Parameter value
* @param int|string|Type|null $type One of the {@link ParameterType} constants or DBAL type
* @param int|string|Type|null $type Parameter type
*
* @return $this This QueryBuilder instance.
*/
Expand Down Expand Up @@ -585,6 +586,15 @@ public function select($select = null/*, string ...$selects*/)
return $this;
}

if (is_array($select)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::select is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$selects = is_array($select) ? $select : func_get_args();

return $this->add('select', $selects);
Expand Down Expand Up @@ -635,6 +645,15 @@ public function addSelect($select = null/*, string ...$selects*/)
return $this;
}

if (is_array($select)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::addSelect is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$selects = is_array($select) ? $select : func_get_args();

return $this->add('select', $selects, true);
Expand Down Expand Up @@ -1007,6 +1026,15 @@ public function groupBy($groupBy/*, string ...$groupBys*/)
return $this;
}

if (is_array($groupBy)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::groupBy is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$groupBy = is_array($groupBy) ? $groupBy : func_get_args();

return $this->add('groupBy', $groupBy, false);
Expand Down Expand Up @@ -1036,6 +1064,15 @@ public function addGroupBy($groupBy/*, string ...$groupBys*/)
return $this;
}

if (is_array($groupBy)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3837',
'Passing an array for the first argument to QueryBuilder::addGroupBy is deprecated, ' .
'pass each value as an individual variadic argument instead.'
);
}

$groupBy = is_array($groupBy) ? $groupBy : func_get_args();

return $this->add('groupBy', $groupBy, true);
Expand Down
11 changes: 11 additions & 0 deletions src/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\Deprecations\Deprecation;
use Throwable;

use function array_filter;
Expand All @@ -19,6 +20,7 @@
use function count;
use function func_get_args;
use function is_callable;
use function is_string;
use function preg_match;
use function str_replace;
use function strtolower;
Expand Down Expand Up @@ -219,6 +221,15 @@ public function listTableIndexes($table)
*/
public function tablesExist($names)
{
if (is_string($names)) {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/3580',
'The usage of a string $tableNames in AbstractSchemaManager::tablesExist is deprecated. ' .
'Pass a one-element array instead.'
);
}

$names = array_map('strtolower', (array) $names);

return count($names) === count(array_intersect($names, array_map('strtolower', $this->listTableNames())));
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Console/Command/RunSqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function configure()
->setDefinition([
new InputOption('connection', null, InputOption::VALUE_REQUIRED, 'The named database connection'),
new InputArgument('sql', InputArgument::REQUIRED, 'The SQL statement to execute.'),
new InputOption('depth', null, InputOption::VALUE_REQUIRED, 'Dumping depth of result set.', 7),
new InputOption('depth', null, InputOption::VALUE_REQUIRED, 'Dumping depth of result set.', '7'),
new InputOption('force-fetch', null, InputOption::VALUE_NONE, 'Forces fetching the result.'),
])
->setHelp(<<<EOT
Expand Down

0 comments on commit 7de2292

Please sign in to comment.