Skip to content

Commit

Permalink
Merge branch '2.11.x' into 3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Oct 10, 2020
2 parents 0f78de8 + 4e3d016 commit 8374e40
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 118 deletions.
9 changes: 5 additions & 4 deletions src/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 Doctrine\DBAL\Types\Type;

use function hash;
use function serialize;
Expand Down Expand Up @@ -68,10 +69,10 @@ public function getCacheKey()
/**
* Generates the real cache key from query, params, types and connection parameters.
*
* @param string $sql
* @param mixed[] $params
* @param int[]|string[] $types
* @param mixed[] $connectionParams
* @param string $sql
* @param array<int, mixed>|array<string, mixed> $params
* @param array<int, Type|int|string|null>|array<string, Type|int|string|null> $types
* @param array<string, mixed> $connectionParams
*
* @return string[]
*/
Expand Down
148 changes: 73 additions & 75 deletions src/Connection.php

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/Logging/SQLLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Doctrine\DBAL\Logging;

use Doctrine\DBAL\Types\Type;

/**
* Interface for SQL loggers.
*/
Expand All @@ -10,9 +12,9 @@ interface SQLLogger
/**
* Logs a SQL statement somewhere.
*
* @param string $sql The SQL to be executed.
* @param mixed[]|null $params The SQL parameters.
* @param array<int|string|null> $types The SQL parameter types.
* @param string $sql SQL statement
* @param array<int, mixed>|array<string, mixed>|null $params Statement parameters
* @param array<int, Type|int|string|null>|array<string, Type|int|string|null>|null $types Parameter types
*
* @return void
*/
Expand Down
34 changes: 18 additions & 16 deletions src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Types\Type;

use function array_key_exists;
use function array_keys;
Expand Down Expand Up @@ -89,14 +90,14 @@ class QueryBuilder
/**
* The query parameters.
*
* @var mixed[]
* @var array<int, mixed>|array<string, mixed>
*/
private $params = [];

/**
* The parameter type map of this query.
*
* @var int[]|string[]
* @var array<int, int|string|Type|null>|array<string, int|string|Type|null>
*/
private $paramTypes = [];

Expand Down Expand Up @@ -266,9 +267,9 @@ public function getSQL()
* ->setParameter(':user_id', 1);
* </code>
*
* @param string|int $key The parameter position or name.
* @param mixed $value The parameter value.
* @param string|int|null $type One of the {@link ParameterType} constants.
* @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
*
* @return $this This QueryBuilder instance.
*/
Expand Down Expand Up @@ -297,8 +298,8 @@ public function setParameter($key, $value, $type = null)
* ));
* </code>
*
* @param mixed[] $params The query parameters to set.
* @param int[]|string[] $types The query parameters types to set.
* @param array<int, mixed>|array<string, mixed> $params Parameters to set
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $types Parameter types
*
* @return $this This QueryBuilder instance.
*/
Expand All @@ -313,7 +314,7 @@ public function setParameters(array $params, array $types = [])
/**
* Gets all defined query parameters for the query being constructed indexed by parameter index or name.
*
* @return mixed[] The currently defined query parameters indexed by parameter index or name.
* @return array<int, mixed>|array<string, mixed> The currently defined query parameters
*/
public function getParameters()
{
Expand All @@ -335,7 +336,8 @@ public function getParameter($key)
/**
* Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
*
* @return int[]|string[] The currently defined query parameter types indexed by parameter index or name.
* @return array<int, int|string|Type|null>|array<string, int|string|Type|null> The currently defined
* query parameter types
*/
public function getParameterTypes()
{
Expand All @@ -345,9 +347,9 @@ public function getParameterTypes()
/**
* Gets a (previously set) query parameter type of the query being constructed.
*
* @param mixed $key The key (index or name) of the bound parameter type.
* @param int|string $key The key of the bound parameter type
*
* @return mixed The value of the bound parameter type.
* @return int|string|Type|null The value of the bound parameter type
*/
public function getParameterType($key)
{
Expand Down Expand Up @@ -1286,9 +1288,9 @@ public function __toString()
*
* @link http://www.zetacomponents.org
*
* @param mixed $value
* @param mixed $type
* @param string $placeHolder The name to bind with. The string must start with a colon ':'.
* @param mixed $value
* @param int|string|Type|null $type
* @param string $placeHolder The name to bind with. The string must start with a colon ':'.
*
* @return string the placeholder name used.
*/
Expand Down Expand Up @@ -1321,8 +1323,8 @@ public function createNamedParameter($value, $type = ParameterType::STRING, $pla
* ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', ParameterType::STRING))
* </code>
*
* @param mixed $value
* @param int $type
* @param mixed $value
* @param int|string|Type|null $type
*
* @return string
*/
Expand Down
8 changes: 5 additions & 3 deletions src/SQLParserUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Doctrine\DBAL;

use Doctrine\DBAL\Types\Type;

use function array_fill;
use function array_fill_keys;
use function array_key_exists;
Expand Down Expand Up @@ -106,9 +108,9 @@ private static function collectPlaceholders(
/**
* For a positional query this method can rewrite the sql statement with regard to array parameters.
*
* @param string $query The SQL query to execute.
* @param mixed[] $params The parameters to bind to the query.
* @param array<string|int|null> $types The types the previous parameters are in.
* @param string $query SQL query
* @param mixed[] $params Query parameters
* @param array<int, Type|int|string|null>|array<string, Type|int|string|null> $types Parameter types
*
* @return mixed[]
*
Expand Down
10 changes: 9 additions & 1 deletion src/Tools/Console/Command/ReservedWordsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use function assert;
use function count;
use function implode;
use function is_array;
use function is_string;

class ReservedWordsCommand extends Command
Expand Down Expand Up @@ -121,7 +122,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$conn = $this->getConnection($input);

$keywordLists = (array) $input->getOption('list');
$keywordLists = $input->getOption('list');

if (is_string($keywordLists)) {
$keywordLists = [$keywordLists];
} elseif (! is_array($keywordLists)) {
$keywordLists = [];
}

if (count($keywordLists) === 0) {
$keywordLists = array_keys($this->keywordListClasses);
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Functional/Schema/Db2SchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BooleanType;

class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function supportsPlatform(AbstractPlatform $platform): bool
{
return $platform instanceof DB2Platform;
}

public function testGetBooleanColumn(): void
{
$table = new Table('boolean_column_test');
Expand Down
6 changes: 6 additions & 0 deletions tests/Functional/Schema/MySqlSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Tests\Functional\Schema;

use DateTime;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
Expand All @@ -15,6 +16,11 @@

class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function supportsPlatform(AbstractPlatform $platform): bool
{
return $platform instanceof MySqlPlatform;
}

protected function setUp(): void
{
parent::setUp();
Expand Down
7 changes: 7 additions & 0 deletions tests/Functional/Schema/OracleSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\TestUtil;
Expand All @@ -15,6 +17,11 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
/** @var bool */
private static $privilegesGranted = false;

protected function supportsPlatform(AbstractPlatform $platform): bool
{
return $platform instanceof OraclePlatform;
}

protected function setUp(): void
{
parent::setUp();
Expand Down
5 changes: 5 additions & 0 deletions tests/Functional/Schema/PostgreSqlSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/** @var PostgreSqlSchemaManager */
protected $schemaManager;

protected function supportsPlatform(AbstractPlatform $platform): bool
{
return $platform instanceof PostgreSQL94Platform;
}

protected function tearDown(): void
{
parent::tearDown();
Expand Down
6 changes: 4 additions & 2 deletions tests/Functional/Schema/SQLServerSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Table;
Expand All @@ -12,9 +14,9 @@

class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function getPlatformName(): string
protected function supportsPlatform(AbstractPlatform $platform): bool
{
return 'mssql';
return $platform instanceof SQLServer2012Platform;
}

public function testDropColumnConstraints(): void
Expand Down
20 changes: 6 additions & 14 deletions tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractAsset;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Column;
Expand Down Expand Up @@ -36,11 +37,9 @@
use function array_values;
use function count;
use function current;
use function end;
use function explode;
use function get_class;
use function in_array;
use function sprintf;
use function str_replace;
use function strcasecmp;
use function strlen;
use function strtolower;
Expand All @@ -51,23 +50,16 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
/** @var AbstractSchemaManager */
protected $schemaManager;

protected function getPlatformName(): string
{
$class = static::class;
$e = explode('\\', $class);
$testClass = end($e);

return strtolower(str_replace('SchemaManagerTest', '', $testClass));
}
abstract protected function supportsPlatform(AbstractPlatform $platform): bool;

protected function setUp(): void
{
parent::setUp();

$dbms = $this->getPlatformName();
$platform = $this->connection->getDatabasePlatform();

if ($this->connection->getDatabasePlatform()->getName() !== $dbms) {
self::markTestSkipped(static::class . ' requires the use of ' . $dbms);
if (! $this->supportsPlatform($platform)) {
self::markTestSkipped(sprintf('Skipping since connected to %s', get_class($platform)));
}

$this->schemaManager = $this->connection->getSchemaManager();
Expand Down
7 changes: 7 additions & 0 deletions tests/Functional/Schema/SqliteSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Doctrine\DBAL\Tests\Functional\Schema;

use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BlobType;
Expand All @@ -13,6 +15,11 @@

class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function supportsPlatform(AbstractPlatform $platform): bool
{
return $platform instanceof SqlitePlatform;
}

/**
* SQLITE does not support databases.
*/
Expand Down

0 comments on commit 8374e40

Please sign in to comment.