Unverified Commit a04c608d authored by Grégoire Paris's avatar Grégoire Paris

Merge remote-tracking branch 'origin/2.11.x' into 3.0.x

parents 67944fce ce218349
...@@ -44,9 +44,10 @@ ...@@ -44,9 +44,10 @@
"phpstan/phpstan": "^0.12.18", "phpstan/phpstan": "^0.12.18",
"phpstan/phpstan-strict-rules": "^0.12.2", "phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "^9.1.1", "phpunit/phpunit": "^9.1.1",
"psalm/plugin-phpunit": "^0.10.0",
"slevomat/coding-standard": "^6.3.6", "slevomat/coding-standard": "^6.3.6",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
"vimeo/psalm": "^3.11" "vimeo/psalm": "^3.11.4"
}, },
"suggest": { "suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files." "symfony/console": "For helpful console commands such as SQL execution and import of files."
......
This diff is collapsed.
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
<!-- The SQLSRV_* functions are defined in the upper case by the sqlsrv extension and violate the standard <!-- The SQLSRV_* functions are defined in the upper case by the sqlsrv extension and violate the standard
see https://docs.microsoft.com/en-us/sql/connect/php/constants-microsoft-drivers-for-php-for-sql-server --> see https://docs.microsoft.com/en-us/sql/connect/php/constants-microsoft-drivers-for-php-for-sql-server -->
<rule ref="Squiz.PHP.LowercasePHPFunctions.UseStatementUppercase"> <rule ref="Squiz.PHP.LowercasePHPFunctions">
<exclude-pattern>src/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern> <exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
</rule> </rule>
</ruleset> </ruleset>
...@@ -120,5 +120,18 @@ parameters: ...@@ -120,5 +120,18 @@ parameters:
message: '~^Only numeric types are allowed in -, int<1, max>\|false given on the left side\.~' message: '~^Only numeric types are allowed in -, int<1, max>\|false given on the left side\.~'
paths: paths:
- %currentWorkingDirectory%/src/Platforms/SQLServer2012Platform.php - %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
-
message: '~Method Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Connection\:\:lastInsertId\(\) should return string but returns string\|false\|null\.~'
paths:
- %currentWorkingDirectory%/src/Driver/PDOSqlsrv/Connection.php
includes: includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon
<?xml version="1.0"?> <?xml version="1.0"?>
<psalm <psalm
totallyTyped="false" totallyTyped="false"
errorLevel="7" errorLevel="6"
resolveFromConfigFile="true" resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config" xmlns="https://getpsalm.org/schema/config"
......
...@@ -1218,8 +1218,8 @@ class Connection implements DriverConnection ...@@ -1218,8 +1218,8 @@ class Connection implements DriverConnection
* This method supports PDO binding types as well as DBAL mapping types. * This method supports PDO binding types as well as DBAL mapping types.
* *
* @param string $query The SQL query. * @param string $query The SQL query.
* @param mixed[] $params The query parameters. * @param array<mixed> $params The query parameters.
* @param int[]|string[] $types The parameter types. * @param array<int|string|null> $types The parameter types.
* *
* @throws DBALException * @throws DBALException
*/ */
......
...@@ -137,6 +137,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection ...@@ -137,6 +137,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @return int|false
*/ */
public function lastInsertId($name = null) public function lastInsertId($name = null)
{ {
......
...@@ -112,11 +112,15 @@ final class DriverManager ...@@ -112,11 +112,15 @@ final class DriverManager
* <b>driverClass</b>: * <b>driverClass</b>:
* The driver class to use. * The driver class to use.
* *
* @param mixed[] $params The parameters. * @param array{wrapperClass?: class-string<T>} $params
* @param Configuration|null $config The configuration to use. * @param Configuration|null $config The configuration to use.
* @param EventManager|null $eventManager The event manager to use. * @param EventManager|null $eventManager The event manager to use.
* *
* @throws DBALException * @throws DBALException
*
* @phpstan-param mixed[] $params
* @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection)
* @template T of Connection
*/ */
public static function getConnection( public static function getConnection(
array $params, array $params,
......
...@@ -12,7 +12,7 @@ interface SQLLogger ...@@ -12,7 +12,7 @@ interface SQLLogger
* *
* @param string $sql The SQL to be executed. * @param string $sql The SQL to be executed.
* @param mixed[]|null $params The SQL parameters. * @param mixed[]|null $params The SQL parameters.
* @param int[]|string[]|null $types The SQL parameter types. * @param array<int|string|null> $types The SQL parameter types.
* *
* @return void * @return void
*/ */
......
...@@ -2816,7 +2816,7 @@ abstract class AbstractPlatform ...@@ -2816,7 +2816,7 @@ abstract class AbstractPlatform
/** /**
* @param string $table * @param string $table
* @param string|null $database * @param string $database
* *
* @return string * @return string
* *
......
...@@ -120,7 +120,7 @@ class SQLParserUtils ...@@ -120,7 +120,7 @@ class SQLParserUtils
* *
* @param string $query The SQL query to execute. * @param string $query The SQL query to execute.
* @param mixed[] $params The parameters to bind to the query. * @param mixed[] $params The parameters to bind to the query.
* @param int[]|string[] $types The types the previous parameters are in. * @param array<string|int|null> $types The types the previous parameters are in.
* *
* @return mixed[] * @return mixed[]
* *
......
...@@ -21,7 +21,7 @@ class QueryCacheProfileTest extends TestCase ...@@ -21,7 +21,7 @@ class QueryCacheProfileTest extends TestCase
/** @var int[] */ /** @var int[] */
private $params = [666]; private $params = [666];
/** @var string[] */ /** @var int[] */
private $types = [ParameterType::INTEGER]; private $types = [ParameterType::INTEGER];
/** @var string[] */ /** @var string[] */
......
...@@ -143,9 +143,7 @@ class ConnectionTest extends TestCase ...@@ -143,9 +143,7 @@ class ConnectionTest extends TestCase
public function testConnectDispatchEvent() : void public function testConnectDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener')) $listenerMock = $this->createMock(ConnectDispatchEventListener::class);
->addMethods(['postConnect'])
->getMock();
$listenerMock->expects(self::once())->method('postConnect'); $listenerMock->expects(self::once())->method('postConnect');
$eventManager = new EventManager(); $eventManager = new EventManager();
...@@ -900,3 +898,8 @@ class ConnectionTest extends TestCase ...@@ -900,3 +898,8 @@ class ConnectionTest extends TestCase
$connection->executeCacheQuery($query, [], [], $queryCacheProfile); $connection->executeCacheQuery($query, [], [], $queryCacheProfile);
} }
} }
interface ConnectDispatchEventListener
{
public function postConnect() : void;
}
...@@ -27,6 +27,7 @@ use Doctrine\DBAL\Exception\UniqueConstraintViolationException; ...@@ -27,6 +27,7 @@ use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use ReflectionProperty; use ReflectionProperty;
use function array_merge; use function array_merge;
...@@ -198,11 +199,12 @@ abstract class AbstractDriverTest extends TestCase ...@@ -198,11 +199,12 @@ abstract class AbstractDriverTest extends TestCase
*/ */
abstract protected function createSchemaManager(Connection $connection) : AbstractSchemaManager; abstract protected function createSchemaManager(Connection $connection) : AbstractSchemaManager;
/**
* @return Connection&MockObject
*/
protected function getConnectionMock() : Connection protected function getConnectionMock() : Connection
{ {
return $this->getMockBuilder(Connection::class) return $this->createMock(Connection::class);
->disableOriginalConstructor()
->getMock();
} }
/** /**
...@@ -214,7 +216,7 @@ abstract class AbstractDriverTest extends TestCase ...@@ -214,7 +216,7 @@ abstract class AbstractDriverTest extends TestCase
} }
/** /**
* @return mixed[][] * @return iterable<mixed[]>
*/ */
public static function exceptionConversionProvider() : iterable public static function exceptionConversionProvider() : iterable
{ {
......
...@@ -43,6 +43,8 @@ class StatementIteratorTest extends TestCase ...@@ -43,6 +43,8 @@ class StatementIteratorTest extends TestCase
} }
/** /**
* @param class-string<Statement> $class
*
* @dataProvider statementProvider() * @dataProvider statementProvider()
*/ */
public function testStatementIterationCallsFetchOncePerStep(string $class) : void public function testStatementIterationCallsFetchOncePerStep(string $class) : void
...@@ -80,7 +82,7 @@ class StatementIteratorTest extends TestCase ...@@ -80,7 +82,7 @@ class StatementIteratorTest extends TestCase
} }
/** /**
* @return string[][] * @return iterable<array{0: class-string<Statement>}>
*/ */
public static function statementProvider() : iterable public static function statementProvider() : iterable
{ {
......
...@@ -67,6 +67,7 @@ class DriverManagerTest extends TestCase ...@@ -67,6 +67,7 @@ class DriverManagerTest extends TestCase
/** /**
* @requires extension pdo_sqlite * @requires extension pdo_sqlite
* @psalm-suppress InvalidArgument
*/ */
public function testInvalidWrapperClass() : void public function testInvalidWrapperClass() : void
{ {
...@@ -156,7 +157,7 @@ class DriverManagerTest extends TestCase ...@@ -156,7 +157,7 @@ class DriverManagerTest extends TestCase
} }
/** /**
* @return array<string, array<int, mixed>> * @return array<string, list<mixed>>
*/ */
public function databaseUrls() : iterable public function databaseUrls() : iterable
{ {
...@@ -255,7 +256,7 @@ class DriverManagerTest extends TestCase ...@@ -255,7 +256,7 @@ class DriverManagerTest extends TestCase
], ],
], ],
'query params from URL are used as extra params' => [ 'query params from URL are used as extra params' => [
'url' => 'mysql://foo:bar@localhost/dbname?charset=UTF-8', 'mysql://foo:bar@localhost/dbname?charset=UTF-8',
['charset' => 'UTF-8'], ['charset' => 'UTF-8'],
], ],
'simple URL with fallthrough scheme not defined in map' => [ 'simple URL with fallthrough scheme not defined in map' => [
......
...@@ -21,7 +21,7 @@ use const CASE_LOWER; ...@@ -21,7 +21,7 @@ use const CASE_LOWER;
*/ */
class ResultCacheTest extends FunctionalTestCase class ResultCacheTest extends FunctionalTestCase
{ {
/** @var array<int, array<int, int|string>> */ /** @var list<array{test_int: int, test_string: string}> */
private $expectedResult = [['test_int' => 100, 'test_string' => 'foo'], ['test_int' => 200, 'test_string' => 'bar'], ['test_int' => 300, 'test_string' => 'baz']]; private $expectedResult = [['test_int' => 100, 'test_string' => 'foo'], ['test_int' => 200, 'test_string' => 'bar'], ['test_int' => 300, 'test_string' => 'baz']];
/** @var DebugStack */ /** @var DebugStack */
...@@ -195,7 +195,7 @@ class ResultCacheTest extends FunctionalTestCase ...@@ -195,7 +195,7 @@ class ResultCacheTest extends FunctionalTestCase
} }
/** /**
* @param array<int, array<int, int|string>> $expectedResult * @param array<int, array<int, int|string>>|list<int> $expectedResult
*/ */
private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode) : void private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode) : void
{ {
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\BlobType;
...@@ -20,6 +21,9 @@ use function strtolower; ...@@ -20,6 +21,9 @@ use function strtolower;
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{ {
/** @var PostgreSqlSchemaManager */
protected $schemaManager;
protected function tearDown() : void protected function tearDown() : void
{ {
parent::tearDown(); parent::tearDown();
...@@ -28,7 +32,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -28,7 +32,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
return; return;
} }
$this->connection->getConfiguration()->setFilterSchemaAssetsExpression(null); $this->connection->getConfiguration()->setSchemaAssetsFilter(null);
} }
/** /**
......
...@@ -60,7 +60,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -60,7 +60,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$e = explode('\\', $class); $e = explode('\\', $class);
$testClass = end($e); $testClass = end($e);
return strtolower(str_replace('SchemaManagerTest', null, $testClass)); return strtolower(str_replace('SchemaManagerTest', '', $testClass));
} }
protected function setUp() : void protected function setUp() : void
...@@ -367,10 +367,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -367,10 +367,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$this->schemaManager->dropAndCreateTable($table); $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this->getMockBuilder($this->getMockClass('ListTableColumnsDispatchEventListener')) $listenerMock = $this->createMock(ListTableColumnsDispatchEventListener::class);
->addMethods(['onSchemaColumnDefinition'])
->getMock();
$listenerMock $listenerMock
->expects(self::exactly(7)) ->expects(self::exactly(7))
->method('onSchemaColumnDefinition'); ->method('onSchemaColumnDefinition');
...@@ -395,9 +392,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -395,9 +392,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$this->schemaManager->dropAndCreateTable($table); $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this->getMockBuilder($this->getMockClass('ListTableIndexesDispatchEventListener')) $listenerMock = $this->createMock(ListTableIndexesDispatchEventListener::class);
->addMethods(['onSchemaIndexDefinition'])
->getMock();
$listenerMock $listenerMock
->expects(self::exactly(3)) ->expects(self::exactly(3))
->method('onSchemaIndexDefinition'); ->method('onSchemaIndexDefinition');
...@@ -1651,3 +1646,13 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -1651,3 +1646,13 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
} }
} }
} }
interface ListTableColumnsDispatchEventListener
{
public function onSchemaColumnDefinition() : void;
}
interface ListTableIndexesDispatchEventListener
{
public function onSchemaIndexDefinition() : void;
}
...@@ -98,7 +98,7 @@ EOS ...@@ -98,7 +98,7 @@ EOS
new Schema\ForeignKeyConstraint( new Schema\ForeignKeyConstraint(
['log'], ['log'],
'log', 'log',
[null], [''],
'FK_3', 'FK_3',
['onUpdate' => 'SET NULL', 'onDelete' => 'NO ACTION', 'deferrable' => false, 'deferred' => false] ['onUpdate' => 'SET NULL', 'onDelete' => 'NO ACTION', 'deferrable' => false, 'deferred' => false]
), ),
......
...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\DriverException; ...@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\DriverException;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Throwable; use Throwable;
...@@ -94,6 +95,7 @@ class WriteTest extends FunctionalTestCase ...@@ -94,6 +95,7 @@ class WriteTest extends FunctionalTestCase
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql); $stmt = $this->connection->prepare($sql);
self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindValue(1, 1, Type::getType('integer')); $stmt->bindValue(1, 1, Type::getType('integer'));
$stmt->bindValue(2, 'foo', Type::getType('string')); $stmt->bindValue(2, 'foo', Type::getType('string'));
$stmt->execute(); $stmt->execute();
...@@ -106,6 +108,7 @@ class WriteTest extends FunctionalTestCase ...@@ -106,6 +108,7 @@ class WriteTest extends FunctionalTestCase
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql); $stmt = $this->connection->prepare($sql);
self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindValue(1, 1, 'integer'); $stmt->bindValue(1, 1, 'integer');
$stmt->bindValue(2, 'foo', 'string'); $stmt->bindValue(2, 'foo', 'string');
$stmt->execute(); $stmt->execute();
......
...@@ -367,9 +367,7 @@ abstract class AbstractPlatformTestCase extends TestCase ...@@ -367,9 +367,7 @@ abstract class AbstractPlatformTestCase extends TestCase
public function testGetCreateTableSqlDispatchEvent() : void public function testGetCreateTableSqlDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder($this->getMockClass('GetCreateTableSqlDispatchEvenListener')) $listenerMock = $this->createMock(GetCreateTableSqlDispatchEventListener::class);
->addMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn'])
->getMock();
$listenerMock $listenerMock
->expects(self::once()) ->expects(self::once())
->method('onSchemaCreateTable'); ->method('onSchemaCreateTable');
...@@ -391,9 +389,7 @@ abstract class AbstractPlatformTestCase extends TestCase ...@@ -391,9 +389,7 @@ abstract class AbstractPlatformTestCase extends TestCase
public function testGetDropTableSqlDispatchEvent() : void public function testGetDropTableSqlDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder($this->getMockClass('GetDropTableSqlDispatchEventListener')) $listenerMock = $this->createMock(GetDropTableSqlDispatchEventListener::class);
->addMethods(['onSchemaDropTable'])
->getMock();
$listenerMock $listenerMock
->expects(self::once()) ->expects(self::once())
->method('onSchemaDropTable'); ->method('onSchemaDropTable');
...@@ -408,17 +404,7 @@ abstract class AbstractPlatformTestCase extends TestCase ...@@ -408,17 +404,7 @@ abstract class AbstractPlatformTestCase extends TestCase
public function testGetAlterTableSqlDispatchEvent() : void public function testGetAlterTableSqlDispatchEvent() : void
{ {
$events = [ $listenerMock = $this->createMock(GetAlterTableSqlDispatchEventListener::class);
'onSchemaAlterTable',
'onSchemaAlterTableAddColumn',
'onSchemaAlterTableRemoveColumn',
'onSchemaAlterTableChangeColumn',
'onSchemaAlterTableRenameColumn',
];
$listenerMock = $this->getMockBuilder($this->getMockClass('GetAlterTableSqlDispatchEvenListener'))
->addMethods($events)
->getMock();
$listenerMock $listenerMock
->expects(self::once()) ->expects(self::once())
->method('onSchemaAlterTable'); ->method('onSchemaAlterTable');
...@@ -1527,3 +1513,28 @@ abstract class AbstractPlatformTestCase extends TestCase ...@@ -1527,3 +1513,28 @@ abstract class AbstractPlatformTestCase extends TestCase
); );
} }
} }
interface GetCreateTableSqlDispatchEventListener
{
public function onSchemaCreateTable() : void;
public function onSchemaCreateTableColumn() : void;
}
interface GetAlterTableSqlDispatchEventListener
{
public function onSchemaAlterTable() : void;
public function onSchemaAlterTableAddColumn() : void;
public function onSchemaAlterTableRemoveColumn() : void;
public function onSchemaAlterTableChangeColumn() : void;
public function onSchemaAlterTableRenameColumn() : void;
}
interface GetDropTableSqlDispatchEventListener
{
public function onSchemaDropTable() : void;
}
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace Doctrine\DBAL\Tests\Platforms; namespace Doctrine\DBAL\Tests\Platforms;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
...@@ -16,6 +19,12 @@ use function sprintf; ...@@ -16,6 +19,12 @@ use function sprintf;
abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCase abstract class AbstractPostgreSQLPlatformTestCase extends AbstractPlatformTestCase
{ {
/** @var PostgreSQL94Platform|PostgreSQL100Platform */
protected $platform;
/** @return PostgreSQL94Platform|PostgreSQL100Platform */
abstract public function createPlatform() : AbstractPlatform;
public function getGenerateTableSql() : string public function getGenerateTableSql() : string
{ {
return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Tests\Platforms; namespace Doctrine\DBAL\Tests\Platforms;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Index;
...@@ -14,6 +15,9 @@ use Doctrine\DBAL\Types\Type; ...@@ -14,6 +15,9 @@ use Doctrine\DBAL\Types\Type;
abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCase abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCase
{ {
/** @var SQLServer2012Platform */
protected $platform;
public function getGenerateTableSql() : string public function getGenerateTableSql() : string
{ {
return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255), PRIMARY KEY (id))'; return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255), PRIMARY KEY (id))';
......
...@@ -22,6 +22,9 @@ use function uniqid; ...@@ -22,6 +22,9 @@ use function uniqid;
class OraclePlatformTest extends AbstractPlatformTestCase class OraclePlatformTest extends AbstractPlatformTestCase
{ {
/** @var OraclePlatform */
protected $platform;
/** /**
* @return mixed[][] * @return mixed[][]
*/ */
...@@ -76,6 +79,9 @@ class OraclePlatformTest extends AbstractPlatformTestCase ...@@ -76,6 +79,9 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$platform->assertValidIdentifier($identifier); $platform->assertValidIdentifier($identifier);
} }
/**
* @return OraclePlatform
*/
public function createPlatform() : AbstractPlatform public function createPlatform() : AbstractPlatform
{ {
return new OraclePlatform(); return new OraclePlatform();
......
...@@ -349,14 +349,14 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase ...@@ -349,14 +349,14 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase
self::assertEquals( self::assertEquals(
'CONSTRAINT pk PRIMARY KEY CLUSTERED (a, b)', 'CONSTRAINT pk PRIMARY KEY CLUSTERED (a, b)',
$this->platform->getPrimaryKeyDeclarationSQL( $this->platform->getPrimaryKeyDeclarationSQL(
new Index(null, ['a', 'b'], true, true, ['clustered']), new Index('', ['a', 'b'], true, true, ['clustered']),
'pk' 'pk'
) )
); );
self::assertEquals( self::assertEquals(
'PRIMARY KEY (a, b)', 'PRIMARY KEY (a, b)',
$this->platform->getPrimaryKeyDeclarationSQL( $this->platform->getPrimaryKeyDeclarationSQL(
new Index(null, ['a', 'b'], true, true) new Index('', ['a', 'b'], true, true)
) )
); );
} }
...@@ -392,12 +392,12 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase ...@@ -392,12 +392,12 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase
'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)', 'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)',
$this->platform->getUniqueConstraintDeclarationSQL( $this->platform->getUniqueConstraintDeclarationSQL(
'unique_constraint', 'unique_constraint',
new Index(null, ['a', 'b'], true, false, ['clustered']) new Index('', ['a', 'b'], true, false, ['clustered'])
) )
); );
self::assertEquals( self::assertEquals(
'UNIQUE (a, b)', 'UNIQUE (a, b)',
$this->platform->getUniqueConstraintDeclarationSQL(null, new Index(null, ['a', 'b'], true, false)) $this->platform->getUniqueConstraintDeclarationSQL('', new Index('', ['a', 'b'], true, false))
); );
} }
...@@ -621,6 +621,9 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase ...@@ -621,6 +621,9 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase
)); ));
} }
/**
* @psalm-suppress InvalidArgument
*/
public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void
{ {
$this->expectException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
...@@ -628,6 +631,9 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase ...@@ -628,6 +631,9 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase
$this->platform->getDropIndexSQL(['index'], 'table'); $this->platform->getDropIndexSQL(['index'], 'table');
} }
/**
* @psalm-suppress InvalidArgument
*/
public function testCannotGenerateDropIndexSQLWithInvalidTableParameter() : void public function testCannotGenerateDropIndexSQLWithInvalidTableParameter() : void
{ {
$this->expectException(InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
...@@ -700,7 +706,7 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase ...@@ -700,7 +706,7 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase
self::assertEquals( self::assertEquals(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " . "REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
"REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))", "REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))",
$this->platform->getTrimExpression('column', null, 'c') $this->platform->getTrimExpression('column', TrimMode::UNSPECIFIED, 'c')
); );
self::assertEquals( self::assertEquals(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " . "REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
...@@ -922,7 +928,7 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase ...@@ -922,7 +928,7 @@ class SQLAnywhere16PlatformTest extends AbstractPlatformTestCase
); );
self::assertEquals( self::assertEquals(
'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE', 'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE',
$this->platform->getListSequencesSQL(null) $this->platform->getListSequencesSQL('')
); );
} }
......
...@@ -13,6 +13,12 @@ use Doctrine\DBAL\Types\Type; ...@@ -13,6 +13,12 @@ use Doctrine\DBAL\Types\Type;
class SqlitePlatformTest extends AbstractPlatformTestCase class SqlitePlatformTest extends AbstractPlatformTestCase
{ {
/** @var SqlitePlatform */
protected $platform;
/**
* @return SqlitePlatform
*/
public function createPlatform() : AbstractPlatform public function createPlatform() : AbstractPlatform
{ {
return new SqlitePlatform(); return new SqlitePlatform();
......
...@@ -872,6 +872,7 @@ class ComparatorTest extends TestCase ...@@ -872,6 +872,7 @@ class ComparatorTest extends TestCase
/** /**
* @group DBAL-106 * @group DBAL-106
* @psalm-suppress NullArgument
*/ */
public function testDiffDecimalWithNullPrecision() : void public function testDiffDecimalWithNullPrecision() : void
{ {
......
...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; ...@@ -10,6 +10,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\Schema\MySqlSchemaManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use function array_map; use function array_map;
...@@ -18,7 +19,7 @@ class MySqlSchemaManagerTest extends TestCase ...@@ -18,7 +19,7 @@ class MySqlSchemaManagerTest extends TestCase
/** @var AbstractSchemaManager */ /** @var AbstractSchemaManager */
private $manager; private $manager;
/** @var Connection */ /** @var Connection&MockObject */
private $conn; private $conn;
protected function setUp() : void protected function setUp() : void
......
...@@ -12,18 +12,18 @@ use Doctrine\DBAL\Logging\SQLLogger; ...@@ -12,18 +12,18 @@ use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Statement; use Doctrine\DBAL\Statement;
use Exception; use Exception;
use PDOStatement; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class StatementTest extends TestCase class StatementTest extends TestCase
{ {
/** @var Connection */ /** @var Connection&MockObject */
private $conn; private $conn;
/** @var Configuration */ /** @var Configuration&MockObject */
private $configuration; private $configuration;
/** @var PDOStatement */ /** @var DriverStatement&MockObject */
private $driverStatement; private $driverStatement;
protected function setUp() : void protected function setUp() : void
......
...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection; ...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand; use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\ConsoleRunner; use Doctrine\DBAL\Tools\Console\ConsoleRunner;
use LogicException; use LogicException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use RuntimeException; use RuntimeException;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
...@@ -18,7 +19,7 @@ class RunSqlCommandTest extends TestCase ...@@ -18,7 +19,7 @@ class RunSqlCommandTest extends TestCase
/** @var RunSqlCommand */ /** @var RunSqlCommand */
private $command; private $command;
/** @var Connection */ /** @var Connection&MockObject */
private $connectionMock; private $connectionMock;
protected function setUp() : void protected function setUp() : void
......
...@@ -19,7 +19,7 @@ class TypeTest extends TestCase ...@@ -19,7 +19,7 @@ class TypeTest extends TestCase
} }
/** /**
* @return string[][] * @return iterable<string[]>
*/ */
public function defaultTypesProvider() : iterable public function defaultTypesProvider() : iterable
{ {
...@@ -28,7 +28,10 @@ class TypeTest extends TestCase ...@@ -28,7 +28,10 @@ class TypeTest extends TestCase
continue; continue;
} }
yield [$constant->getValue()]; $constantValue = $constant->getValue();
self::assertIsString($constantValue);
yield [$constantValue];
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment