Unverified Commit 9f2e25c8 authored by Grégoire Paris's avatar Grégoire Paris Committed by GitHub

Merge pull request #3977 from greg0ire/psalm-6

Psalm 6
parents 2348831a 1bc66b34
......@@ -42,9 +42,10 @@
"jetbrains/phpstorm-stubs": "^2019.1",
"nikic/php-parser": "^4.4",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8.4.1",
"phpunit/phpunit": "^8.5.5",
"psalm/plugin-phpunit": "^0.10.0",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
"vimeo/psalm": "^3.11"
"vimeo/psalm": "^3.11.4"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
......
This diff is collapsed.
......@@ -1034,9 +1034,9 @@ class Connection implements DriverConnection
*
* This method supports PDO binding types as well as DBAL mapping types.
*
* @param string $query The SQL query.
* @param mixed[] $params The query parameters.
* @param int[]|string[] $types The parameter types.
* @param string $query The SQL query.
* @param array<mixed> $params The query parameters.
* @param array<int|string|null> $types The parameter types.
*
* @return int The number of affected rows.
*
......
......@@ -33,6 +33,8 @@ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
/**
* {@inheritdoc}
*
* @return DrizzlePlatform
*/
public function getDatabasePlatform()
{
......@@ -41,6 +43,8 @@ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
/**
* {@inheritdoc}
*
* @return DrizzleSchemaManager
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
......
......@@ -200,6 +200,8 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
/**
* {@inheritdoc}
*
* @return int
*/
public function errorCode()
{
......@@ -208,6 +210,8 @@ class MysqliConnection implements Connection, PingableConnection, ServerInfoAwar
/**
* {@inheritdoc}
*
* @return string
*/
public function errorInfo()
{
......
......@@ -401,6 +401,8 @@ class MysqliStatement implements IteratorAggregate, Statement
/**
* {@inheritdoc}
*
* @return string
*/
public function errorInfo()
{
......
......@@ -148,6 +148,8 @@ class OCI8Connection implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*
* @return int|false
*/
public function lastInsertId($name = null)
{
......
......@@ -56,12 +56,15 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
* @param string $prepareString
* @param array<int, int> $driverOptions
*
* @return Statement
* @return \PDOStatement
*/
public function prepare($prepareString, $driverOptions = [])
{
try {
return parent::prepare($prepareString, $driverOptions);
$statement = parent::prepare($prepareString, $driverOptions);
assert($statement instanceof \PDOStatement);
return $statement;
} catch (\PDOException $exception) {
throw new PDOException($exception);
}
......@@ -69,6 +72,8 @@ class PDOConnection extends PDO implements Connection, ServerInfoAwareConnection
/**
* {@inheritdoc}
*
* @return \PDOStatement
*/
public function query()
{
......
......@@ -115,11 +115,15 @@ final class DriverManager
* <b>driverClass</b>:
* The driver class to use.
*
* @param mixed[] $params The parameters.
* @param Configuration|null $config The configuration to use.
* @param EventManager|null $eventManager The event manager to use.
* @param array{wrapperClass?: class-string<T>} $params
* @param Configuration|null $config The configuration to use.
* @param EventManager|null $eventManager The event manager to use.
*
* @throws DBALException
*
* @phpstan-param mixed[] $params
* @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection)
* @template T of Connection
*/
public static function getConnection(
array $params,
......
......@@ -10,9 +10,9 @@ interface SQLLogger
/**
* Logs a SQL statement somewhere.
*
* @param string $sql The SQL to be executed.
* @param mixed[]|null $params The SQL parameters.
* @param int[]|string[]|null $types The SQL parameter types.
* @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.
*
* @return void
*/
......
......@@ -2816,8 +2816,8 @@ abstract class AbstractPlatform
}
/**
* @param string $table
* @param string|null $database
* @param string $table
* @param string $database
*
* @return string
*
......
......@@ -108,6 +108,8 @@ class Connection extends \Doctrine\DBAL\Connection
/**
* {@inheritdoc}
*
* @return Statement
*/
public function prepare($statement)
{
......
......@@ -118,9 +118,9 @@ class SQLParserUtils
/**
* 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 int[]|string[] $types The types the previous parameters are in.
* @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.
*
* @return mixed[]
*
......
......@@ -83,3 +83,15 @@ parameters:
# Needs Generics
- '~Method Doctrine\\DBAL\\Schema\\SchemaDiff::getNewTablesSortedByDependencies\(\) should return array<Doctrine\\DBAL\\Schema\\Table> but returns array<object>.~'
# 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%/lib/Doctrine/DBAL/Id/TableGenerator.php
- %currentWorkingDirectory%/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
-
message: '~Method Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Connection\:\:lastInsertId\(\) should return string but returns string\|false\|null\.~'
paths:
- %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="7"
errorLevel="6"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
......
......@@ -21,7 +21,7 @@ class QueryCacheProfileTest extends DbalTestCase
/** @var int[] */
private $params = [666];
/** @var string[] */
/** @var int[] */
private $types = [ParameterType::INTEGER];
/** @var string[] */
......
......@@ -22,7 +22,6 @@ use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Logging\EchoSQLLogger;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
......@@ -145,9 +144,7 @@ class ConnectionTest extends DbalTestCase
public function testConnectDispatchEvent() : void
{
$listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener'))
->addMethods(['postConnect'])
->getMock();
$listenerMock = $this->createMock(ConnectDispatchEventListener::class);
$listenerMock->expects($this->once())->method('postConnect');
$eventManager = new EventManager();
......@@ -762,7 +759,7 @@ class ConnectionTest extends DbalTestCase
*/
public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void
{
$driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
$driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class);
$driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class);
......@@ -883,7 +880,7 @@ class ConnectionTest extends DbalTestCase
*/
public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void
{
$driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
$driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class);
$connection = new Connection(['dbname' => 'foo'], $driverMock);
$originalException = new Exception('Original exception');
......@@ -949,3 +946,8 @@ class ConnectionTest extends DbalTestCase
$connection->executeCacheQuery($query, [], [], $queryCacheProfile);
}
}
interface ConnectDispatchEventListener
{
public function postConnect() : void;
}
......@@ -28,6 +28,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionProperty;
use function array_merge;
use function get_class;
......@@ -198,11 +199,12 @@ abstract class AbstractDriverTest extends DbalTestCase
*/
abstract protected function createSchemaManager(Connection $connection) : AbstractSchemaManager;
/**
* @return Connection&MockObject
*/
protected function getConnectionMock() : Connection
{
return $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
return $this->createMock(Connection::class);
}
/**
......@@ -214,7 +216,7 @@ abstract class AbstractDriverTest extends DbalTestCase
}
/**
* @return mixed[][]
* @return iterable<mixed[]>
*/
public static function exceptionConversionProvider() : iterable
{
......
......@@ -43,6 +43,8 @@ class StatementIteratorTest extends DbalTestCase
}
/**
* @param class-string<Statement> $class
*
* @dataProvider statementProvider()
*/
public function testStatementIterationCallsFetchOncePerStep(string $class) : void
......@@ -80,7 +82,7 @@ class StatementIteratorTest extends DbalTestCase
}
/**
* @return string[][]
* @return iterable<array{0: class-string<Statement>}>
*/
public static function statementProvider() : iterable
{
......
......@@ -107,6 +107,7 @@ class DriverManagerTest extends DbalTestCase
/**
* @requires extension pdo_sqlite
* @psalm-suppress InvalidArgument
*/
public function testInvalidWrapperClass() : void
{
......@@ -242,7 +243,7 @@ class DriverManagerTest extends DbalTestCase
}
/**
* @return array<string, array<int, mixed>>
* @return array<string, list<mixed>>
*/
public function databaseUrls() : iterable
{
......@@ -341,7 +342,7 @@ class DriverManagerTest extends DbalTestCase
],
],
'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'],
],
'simple URL with fallthrough scheme not defined in map' => [
......
......@@ -27,7 +27,7 @@ class StatementTest extends DbalFunctionalTestCase
public function testFailureToPrepareResultsInException() : void
{
// use the driver connection directly to avoid having exception wrapped
$stmt = $this->connection->getWrappedConnection()->prepare(null);
$stmt = $this->connection->getWrappedConnection()->prepare('');
// it's impossible to prepare the statement without bound variables for SQL Server,
// so the preparation happens before the first execution when variables are already in place
......
......@@ -21,7 +21,7 @@ use const CASE_LOWER;
*/
class ResultCacheTest extends DbalFunctionalTestCase
{
/** @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']];
/** @var DebugStack */
......@@ -195,7 +195,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
}
/**
* @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
{
......
......@@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BlobType;
......@@ -20,6 +21,9 @@ use function strtolower;
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
/** @var PostgreSqlSchemaManager */
protected $schemaManager;
protected function tearDown() : void
{
parent::tearDown();
......@@ -28,7 +32,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
return;
}
$this->connection->getConfiguration()->setFilterSchemaAssetsExpression(null);
$this->connection->getConfiguration()->setSchemaAssetsFilter(null);
}
/**
......
......@@ -60,7 +60,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$e = explode('\\', $class);
$testClass = end($e);
return strtolower(str_replace('SchemaManagerTest', null, $testClass));
return strtolower(str_replace('SchemaManagerTest', '', $testClass));
}
protected function setUp() : void
......@@ -369,10 +369,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this->getMockBuilder($this->getMockClass('ListTableColumnsDispatchEventListener'))
->addMethods(['onSchemaColumnDefinition'])
->getMock();
$listenerMock = $this->createMock(ListTableColumnsDispatchEventListener::class);
$listenerMock
->expects($this->exactly(7))
->method('onSchemaColumnDefinition');
......@@ -397,9 +394,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this->getMockBuilder($this->getMockClass('ListTableIndexesDispatchEventListener'))
->addMethods(['onSchemaIndexDefinition'])
->getMock();
$listenerMock = $this->createMock(ListTableIndexesDispatchEventListener::class);
$listenerMock
->expects($this->exactly(3))
->method('onSchemaIndexDefinition');
......@@ -1653,3 +1648,13 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
}
}
}
interface ListTableColumnsDispatchEventListener
{
public function onSchemaColumnDefinition() : void;
}
interface ListTableIndexesDispatchEventListener
{
public function onSchemaIndexDefinition() : void;
}
......@@ -98,7 +98,7 @@ EOS
new Schema\ForeignKeyConstraint(
['log'],
'log',
[null],
[''],
'FK_3',
['onUpdate' => 'SET NULL', 'onDelete' => 'NO ACTION', 'deferrable' => false, 'deferred' => false]
),
......
......@@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\DriverException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
......@@ -94,6 +95,7 @@ class WriteTest extends DbalFunctionalTestCase
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindValue(1, 1, Type::getType('integer'));
$stmt->bindValue(2, 'foo', Type::getType('string'));
$stmt->execute();
......@@ -106,6 +108,7 @@ class WriteTest extends DbalFunctionalTestCase
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindValue(1, 1, 'integer');
$stmt->bindValue(2, 'foo', 'string');
$stmt->execute();
......
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\VersionAwarePlatformDriver;
/**
* Remove me in 3.0.x
*/
interface FutureVersionAwarePlatformDriver extends VersionAwarePlatformDriver, Driver
{
}
......@@ -372,9 +372,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetCreateTableSqlDispatchEvent() : void
{
$listenerMock = $this->getMockBuilder($this->getMockClass('GetCreateTableSqlDispatchEvenListener'))
->addMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn'])
->getMock();
$listenerMock = $this->createMock(GetCreateTableSqlDispatchEventListener::class);
$listenerMock
->expects($this->once())
->method('onSchemaCreateTable');
......@@ -396,9 +394,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetDropTableSqlDispatchEvent() : void
{
$listenerMock = $this->getMockBuilder($this->getMockClass('GetDropTableSqlDispatchEventListener'))
->addMethods(['onSchemaDropTable'])
->getMock();
$listenerMock = $this->createMock(GetDropTableSqlDispatchEventListener::class);
$listenerMock
->expects($this->once())
->method('onSchemaDropTable');
......@@ -413,17 +409,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetAlterTableSqlDispatchEvent() : void
{
$events = [
'onSchemaAlterTable',
'onSchemaAlterTableAddColumn',
'onSchemaAlterTableRemoveColumn',
'onSchemaAlterTableChangeColumn',
'onSchemaAlterTableRenameColumn',
];
$listenerMock = $this->getMockBuilder($this->getMockClass('GetAlterTableSqlDispatchEvenListener'))
->addMethods($events)
->getMock();
$listenerMock = $this->createMock(GetAlterTableSqlDispatchEventListener::class);
$listenerMock
->expects($this->once())
->method('onSchemaAlterTable');
......@@ -1532,3 +1518,28 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
);
}
}
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,8 @@
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator;
......@@ -16,6 +18,14 @@ use function sprintf;
abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCase
{
/** @var PostgreSqlPlatform */
protected $platform;
/**
* @return PostgreSqlPlatform
*/
abstract public function createPlatform() : AbstractPlatform;
public function getGenerateTableSql() : string
{
return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
......
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Index;
......@@ -14,6 +15,9 @@ use function sprintf;
abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCase
{
/** @var SQLServerPlatform */
protected $platform;
public function getGenerateTableSql() : string
{
return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255), PRIMARY KEY (id))';
......
......@@ -22,6 +22,9 @@ use function uniqid;
class OraclePlatformTest extends AbstractPlatformTestCase
{
/** @var OraclePlatform */
protected $platform;
/**
* @return mixed[][]
*/
......@@ -76,6 +79,9 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$platform->assertValidIdentifier($identifier);
}
/**
* @return OraclePlatform
*/
public function createPlatform() : AbstractPlatform
{
return new OraclePlatform();
......
......@@ -8,6 +8,14 @@ use Doctrine\DBAL\Types\Types;
class PostgreSQL92PlatformTest extends AbstractPostgreSqlPlatformTestCase
{
/** @var PostgreSQL92Platform */
protected $platform;
/**
* {@inheritdoc}
*
* @return PostgreSQL92Platform
*/
public function createPlatform() : AbstractPlatform
{
return new PostgreSQL92Platform();
......
......@@ -52,7 +52,7 @@ class SQLAnywhere12PlatformTest extends SQLAnywhere11PlatformTest
);
self::assertEquals(
'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE',
$this->platform->getListSequencesSQL(null)
$this->platform->getListSequencesSQL('')
);
}
......
......@@ -348,14 +348,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
self::assertEquals(
'CONSTRAINT pk PRIMARY KEY CLUSTERED (a, b)',
$this->platform->getPrimaryKeyDeclarationSQL(
new Index(null, ['a', 'b'], true, true, ['clustered']),
new Index('', ['a', 'b'], true, true, ['clustered']),
'pk'
)
);
self::assertEquals(
'PRIMARY KEY (a, b)',
$this->platform->getPrimaryKeyDeclarationSQL(
new Index(null, ['a', 'b'], true, true)
new Index('', ['a', 'b'], true, true)
)
);
}
......@@ -391,12 +391,12 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)',
$this->platform->getUniqueConstraintDeclarationSQL(
'unique_constraint',
new Index(null, ['a', 'b'], true, false, ['clustered'])
new Index('', ['a', 'b'], true, false, ['clustered'])
)
);
self::assertEquals(
'UNIQUE (a, b)',
$this->platform->getUniqueConstraintDeclarationSQL(null, new Index(null, ['a', 'b'], true, false))
$this->platform->getUniqueConstraintDeclarationSQL('', new Index('', ['a', 'b'], true, false))
);
}
......@@ -517,6 +517,9 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
));
}
/**
* @psalm-suppress InvalidArgument
*/
public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void
{
$this->expectException(InvalidArgumentException::class);
......@@ -524,6 +527,9 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
$this->platform->getDropIndexSQL(['index'], 'table');
}
/**
* @psalm-suppress InvalidArgument
*/
public function testCannotGenerateDropIndexSQLWithInvalidTableParameter() : void
{
$this->expectException(InvalidArgumentException::class);
......@@ -596,7 +602,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
self::assertEquals(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
"REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))",
$this->platform->getTrimExpression('column', null, 'c')
$this->platform->getTrimExpression('column', TrimMode::UNSPECIFIED, 'c')
);
self::assertEquals(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
......
......@@ -13,6 +13,12 @@ use Doctrine\DBAL\Types\Type;
class SqlitePlatformTest extends AbstractPlatformTestCase
{
/** @var SqlitePlatform */
protected $platform;
/**
* @return SqlitePlatform
*/
public function createPlatform() : AbstractPlatform
{
return new SqlitePlatform();
......
......@@ -872,6 +872,7 @@ class ComparatorTest extends TestCase
/**
* @group DBAL-106
* @psalm-suppress NullArgument
*/
public function testDiffDecimalWithNullPrecision() : void
{
......
......@@ -10,6 +10,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function array_map;
......@@ -18,7 +19,7 @@ class MySqlSchemaManagerTest extends TestCase
/** @var AbstractSchemaManager */
private $manager;
/** @var Connection */
/** @var Connection&MockObject */
private $conn;
protected function setUp() : void
......
......@@ -5,6 +5,7 @@ namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Sharding\ShardingException;
use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class SQLAzureShardManagerTest extends TestCase
......@@ -81,6 +82,8 @@ class SQLAzureShardManagerTest extends TestCase
/**
* @param mixed[] $params
*
* @return Connection&MockObject
*/
private function createConnection(array $params) : Connection
{
......
......@@ -14,16 +14,17 @@ use Doctrine\DBAL\Statement;
use Doctrine\Tests\DbalTestCase;
use Exception;
use PDOStatement;
use PHPUnit\Framework\MockObject\MockObject;
class StatementTest extends DbalTestCase
{
/** @var Connection */
/** @var Connection&MockObject */
private $conn;
/** @var Configuration */
/** @var Configuration&MockObject */
private $configuration;
/** @var PDOStatement */
/** @var PDOStatement&MockObject */
private $pdoStatement;
protected function setUp() : void
......
......@@ -6,6 +6,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\ConsoleRunner;
use LogicException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Component\Console\Application;
......@@ -18,7 +19,7 @@ class RunSqlCommandTest extends TestCase
/** @var RunSqlCommand */
private $command;
/** @var Connection */
/** @var Connection&MockObject */
private $connectionMock;
protected function setUp() : void
......
......@@ -19,7 +19,7 @@ class TypeTest extends TestCase
}
/**
* @return string[][]
* @return iterable<string[]>
*/
public function defaultTypesProvider() : iterable
{
......@@ -28,7 +28,10 @@ class TypeTest extends TestCase
continue;
}
yield [$constant->getValue()];
$constantValue = $constant->getValue();
self::assertIsString($constantValue);
yield [$constantValue];
}
}
}
......@@ -16,7 +16,7 @@ class DbalPerformanceTestListener implements TestListener
{
use TestListenerDefaultImplementation;
/** @var string[][] */
/** @var array<string, array<string, float>> */
private $timings = [];
public function endTest(Test $test, float $time) : void
......
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