Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 2.13.0 into 3.0.x #4563

Merged
merged 45 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
71b7bf5
Update PHPStan to 0.12.81
morozov Mar 9, 2021
df90ef6
Merge pull request #4542 from morozov/phpstan-0.12.81
morozov Mar 9, 2021
b4e8f9c
Remove incomplete details of QueryBuilder::setParameter($type)
andrew-demb Mar 16, 2021
c85d9d5
Merge pull request #4543 from andrew-demb/patch-1
morozov Mar 16, 2021
70797f3
Upgrade Psalm to 4.6.4
morozov Mar 15, 2021
4297f50
Improve forward compatibility between 2.x and 3.0
mdumoulin Mar 5, 2021
b49127c
Merge pull request #4529 from mdumoulin/improve-v2-forward-compatibility
morozov Mar 17, 2021
12bac17
Merge pull request #4549 from morozov/psalm-4.6.4
morozov Mar 17, 2021
3f44415
Secure connection parameters for mysqli are non-nullable strings
morozov Dec 13, 2020
4330e8b
Update JetBrains PhpStorm stubs to v2020.2
morozov Dec 13, 2020
b366d93
Merge pull request #4465 from morozov/phpstorm-stubs-2020.2
morozov Mar 20, 2021
3f2e3f2
[GH-4019] Trigger deprecations for fetch mode deprecation to fetch* A…
beberlei Mar 6, 2021
59148f4
[GH-4054] Convert MasterSlaveConnection to Doctrine deprecations API.
beberlei Mar 6, 2021
f4773bd
[GH-3187] Convert binary column maxlength deprecation to Doctrine API.
beberlei Mar 6, 2021
0e1dfa6
[GH-3956] Convert CLI HelperSet deprecations to Doctrine API.
beberlei Mar 6, 2021
c98bccb
[GH-2846] Convert unknown Column options deprecation to Doctrine API.
beberlei Mar 6, 2021
2f74737
[GH-4213] Add deprecation to SchemaSynchronizer API.
beberlei Mar 6, 2021
705d3a2
[GH-4163] Add deprecation for Connection::exec, executeUpdate, query …
beberlei Mar 6, 2021
f33960f
[GH-3088] Deprecate usage of PDO Fetch Mode and Param constants.
beberlei Mar 6, 2021
7b6554e
[GH-4132] Add deprecation for AbstractPlatform::fixSchemaElementName
beberlei Mar 6, 2021
8021e49
[GH-4229] Trigger deprecation for more AbstractPlatform deprecations.
beberlei Mar 6, 2021
19120c9
[GH-4114] Add deprecation for ServerInfoAwareConnection::requiresQuer…
beberlei Mar 6, 2021
70b0552
[GH-4119] Add deprecation to Connection::ping.
beberlei Mar 6, 2021
d1c94b0
[GH-4112] Add deprecation for Driver\AbstractException::getErrorCode.
beberlei Mar 6, 2021
07972ce
[GH-3823] Deprecate Connection::project
beberlei Mar 6, 2021
ec232ef
[GH-3507] Add deprecation triggers to errorInfo/errorCode APIs.
beberlei Mar 6, 2021
24625f0
Reintroduce Support for PHP 7.1 and 7.2
beberlei Mar 22, 2021
6d7cd0d
Merge pull request #4386 from beberlei/DBAL-Support-PHP7.2
beberlei Mar 27, 2021
74f4a28
[GH-3935] Add deprecation trigger for EchoSQLLogger.
beberlei Mar 6, 2021
69a67af
[GH-3595] Trigger deprecation messages for Sharding APIs.
beberlei Mar 6, 2021
d0b88d5
[GH-3851] Trigger deprecation for ExpressionBuilder::andX/orX
beberlei Mar 6, 2021
7bcd6eb
[GH-3844] Add deprecation message for CompositeExpression::add/addMul…
beberlei Mar 6, 2021
6b90962
[GH-3837] Trigger deprecation for QueryBuilder::select/addSelect/grou…
beberlei Mar 6, 2021
d314a78
[GH-3580] Several deprecation triggers.
beberlei Mar 6, 2021
f3e971a
[GH-3554] Trigger deprecation for passing user provided PDO instance.
beberlei Mar 6, 2021
7f777ae
[GH-3572] Deprecation trigger for LoggerChain::addLogger
beberlei Mar 6, 2021
b620d18
[GH-3316] Deprecate Configuration::get/setFilterSchemaAssetsExpressio…
beberlei Mar 6, 2021
9ee8278
[GH-3255] Trigger deprecation for Type::getDefaultLength
beberlei Mar 7, 2021
6a736f1
[GH-3258] Trigger deprecation for Type::__toString().
beberlei Mar 7, 2021
5a85231
[GH-4049] Trigger deprecation message for Statement::closeCursor
beberlei Mar 7, 2021
ad31968
Merge pull request #4535 from beberlei/Deprecations
beberlei Mar 27, 2021
6c367ff
[GH-4554] Deprecate all Statement::fetch* in favor of Result::fetch*
beberlei Mar 27, 2021
3125de1
Merge pull request #4555 from beberlei/GH-4554-DeprecateStatementFetch
beberlei Mar 28, 2021
67d56d3
Merge 2.12.x up into 2.13.x
beberlei Mar 28, 2021
ab91c62
Merge branch '2.13.x' into 3.0.x
morozov Mar 30, 2021
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
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 @@ -227,7 +227,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 @@ -241,15 +242,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 @@ -269,7 +270,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 @@ -483,6 +484,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 @@ -533,6 +543,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 @@ -905,6 +924,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 @@ -934,6 +962,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 @@ -205,6 +207,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