Skip to content

The portability spans two different architecture layers and doesn't properly implement the wrapper API #4156

@morozov

Description

@morozov
Q A
BC Break no
Version 3.0.0-dev

As reported by PHPStan in #4094 (2.10.x),

dbal/phpstan.neon.dist

Lines 99 to 102 in 15d9be0

-
message: '~Method Doctrine\\DBAL\\Portability\\Connection::prepare\(\) should return Doctrine\\DBAL\\Statement but returns Doctrine\\DBAL\\Portability\\Statement\.~'
paths:
- %currentWorkingDirectory%/lib/Doctrine/DBAL/Portability/Connection.php

In 3.0.x where the driver and wrapper APIs started diverging (#4045), it results in the following:

$conn = DriverManager::getConnection([
    'driver' => 'pdo_sqlite',
]);

foreach ($conn->prepare('SELECT 1')->execute()->iterateColumn() as $value) {
    var_dump($value);
}

// string(1) "1"

$conn = DriverManager::getConnection([
    'driver' => 'pdo_sqlite',
    'wrapperClass' => \Doctrine\DBAL\Portability\Connection::class,
    'portability'  => \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL,
    'fetch_case'   => \Doctrine\DBAL\ColumnCase::LOWER,
]);

foreach ($conn->prepare('SELECT 1')->execute()->iterateColumn() as $value) {
    var_dump($value);
}

// Fatal error: Call to undefined method Doctrine\DBAL\Portability\Result::iterateColumn()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions