Manual coding style fixes

parent 5e0eeef8
......@@ -146,7 +146,7 @@ class ConnectionTest extends DbalTestCase
{
$eventManager = new EventManager();
/** @var AbstractPlatform|MockObject $driver */
/** @var AbstractPlatform|MockObject $platform */
$platform = $this->createMock(AbstractPlatform::class);
$platform->expects($this->once())
->method('setEventManager')
......
......@@ -34,7 +34,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
$handler = static function () : bool {
self::fail('Never expected this to be called');
};
$default_handler = set_error_handler($handler);
set_error_handler($handler);
try {
new MysqliConnection(['host' => '255.255.255.255'], 'user', 'pass');
......
......@@ -39,6 +39,9 @@ class StatementIteratorTest extends DbalTestCase
});
}
/**
* @param Traversable<mixed> $iterator
*/
private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls) : void
{
foreach ($iterator as $i => $_) {
......
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Functional\DataAccess;
class FetchClass
{
/** @var int */
public $test_int;
/** @var string */
public $test_string;
/** @var string */
public $test_datetime;
}
......@@ -20,6 +20,7 @@ use Doctrine\DBAL\Platforms\TrimMode;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Types\Types;
use Doctrine\Tests\DBAL\Functional\DataAccess\FetchClass;
use Doctrine\Tests\DbalFunctionalTestCase;
use InvalidArgumentException;
use PDO;
......@@ -1106,11 +1107,11 @@ class DataAccessTest extends DbalFunctionalTestCase
$results = $stmt->fetchAll(
FetchMode::CUSTOM_OBJECT,
MyFetchClass::class
FetchClass::class
);
self::assertCount(1, $results);
self::assertInstanceOf(MyFetchClass::class, $results[0]);
self::assertInstanceOf(FetchClass::class, $results[0]);
self::assertEquals(1, $results[0]->test_int);
self::assertEquals('foo', $results[0]->test_string);
......@@ -1144,12 +1145,12 @@ class DataAccessTest extends DbalFunctionalTestCase
$sql = 'SELECT * FROM fetch_table';
$stmt = $this->connection->query($sql);
$stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, MyFetchClass::class);
$stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, FetchClass::class);
$results = $stmt->fetchAll();
self::assertCount(1, $results);
self::assertInstanceOf(MyFetchClass::class, $results[0]);
self::assertInstanceOf(FetchClass::class, $results[0]);
self::assertEquals(1, $results[0]->test_int);
self::assertEquals('foo', $results[0]->test_string);
......@@ -1166,7 +1167,7 @@ class DataAccessTest extends DbalFunctionalTestCase
$sql = 'SELECT * FROM fetch_table';
$stmt = $this->connection->query($sql);
$stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, MyFetchClass::class);
$stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, FetchClass::class);
$results = [];
while ($row = $stmt->fetch()) {
......@@ -1174,7 +1175,7 @@ class DataAccessTest extends DbalFunctionalTestCase
}
self::assertCount(1, $results);
self::assertInstanceOf(MyFetchClass::class, $results[0]);
self::assertInstanceOf(FetchClass::class, $results[0]);
self::assertEquals(1, $results[0]->test_int);
self::assertEquals('foo', $results[0]->test_string);
......@@ -1278,15 +1279,3 @@ class DataAccessTest extends DbalFunctionalTestCase
$connection->getWrappedConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
}
}
class MyFetchClass
{
/** @var int */
public $test_int;
/** @var string */
public $test_string;
/** @var string */
public $test_datetime;
}
......@@ -126,9 +126,9 @@ class ResultCacheTest extends DbalFunctionalTestCase
$data = $this->hydrateStmt($stmt, $fetchMode);
$stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$data_iterator = $this->hydrateStmtIterator($stmt, $fetchMode);
$iterator = $this->hydrateStmtIterator($stmt, $fetchMode);
self::assertEquals($data, $data_iterator);
self::assertEquals($data, $iterator);
}
public function testDontCloseNoCache() : void
......
......@@ -667,13 +667,13 @@ class QueryBuilderTest extends DbalTestCase
$qb->setParameter(':test', (object) 1);
$qb_clone = clone $qb;
$clone = clone $qb;
self::assertEquals((string) $qb, (string) $qb_clone);
self::assertEquals((string) $qb, (string) $clone);
$qb->andWhere('u.id = 1');
self::assertNotSame($qb->getParameters(), $qb_clone->getParameters());
self::assertNotSame($qb->getParameters(), $clone->getParameters());
}
public function testSimpleSelectWithoutTableAlias() : void
......
......@@ -97,13 +97,13 @@ class DumperTest extends DbalTestCase
*/
public function testExportParentAttributes(TestAsset\ParentClass $class, array $expected) : void
{
$print_r_class = print_r($class, true);
$print_r_expected = print_r($expected, true);
$printedClass = print_r($class, true);
$printedExpected = print_r($expected, true);
$print_r_class = substr($print_r_class, (int) strpos($print_r_class, '('));
$print_r_expected = substr($print_r_expected, (int) strpos($print_r_expected, '('));
$printedClass = substr($printedClass, (int) strpos($printedClass, '('));
$printedExpected = substr($printedExpected, (int) strpos($printedExpected, '('));
self::assertSame($print_r_class, $print_r_expected);
self::assertSame($printedClass, $printedExpected);
$var = Dumper::export($class, 3);
$var = (array) $var;
......
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