-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Driver\PDO; | ||
|
||
use PDO; | ||
|
||
use const PHP_VERSION_ID; | ||
|
||
/** @internal */ | ||
trait PDOConnect | ||
{ | ||
private function doConnect( | ||
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 14 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
|
||
string $dsn, | ||
string|null $username = null, | ||
string|null $password = null, | ||
array|null $options = null, | ||
): PDO { | ||
if (PHP_VERSION_ID < 80400) { | ||
return new PDO($dsn, $username, $password, $options); | ||
} | ||
|
||
return PDO::connect($dsn, $username, $password, $options); | ||
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedMethod
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with PHPStan (8.3)
Check failure on line 24 in src/Driver/PDO/PDOConnect.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedMethod
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Driver\PDO; | ||
|
||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Tests\TestUtil; | ||
use Pdo\Mysql; | ||
use Pdo\Oci; | ||
use Pdo\Pgsql; | ||
use Pdo\Sqlite; | ||
use Pdo\Sqlsrv; | ||
use PHPUnit\Framework\Attributes\RequiresPhp; | ||
|
||
#[RequiresPhp('8.4')] | ||
final class PDOSubclassTest extends FunctionalTestCase | ||
{ | ||
public function testMySQLSubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_mysql')) { | ||
self::markTestSkipped('This test requires the pdo_mysql driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Mysql::class, $this->connection->getNativeConnection()); | ||
Check failure on line 25 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
Check failure on line 25 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
|
||
} | ||
|
||
public function testOCISubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_oci')) { | ||
self::markTestSkipped('This test requires the pdo_oci driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Oci::class, $this->connection->getNativeConnection()); | ||
Check failure on line 34 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
Check failure on line 34 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
|
||
} | ||
|
||
public function testPgSQLSubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_pgsql')) { | ||
self::markTestSkipped('This test requires the pdo_pgsql driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Pgsql::class, $this->connection->getNativeConnection()); | ||
Check failure on line 43 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
Check failure on line 43 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
|
||
} | ||
|
||
public function testSQLiteSubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_sqlite')) { | ||
self::markTestSkipped('This test requires the pdo_sqlite driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Sqlite::class, $this->connection->getNativeConnection()); | ||
Check failure on line 52 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
Check failure on line 52 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
|
||
} | ||
|
||
public function testSQLSrvSubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_sqlsrv')) { | ||
self::markTestSkipped('This test requires the pdo_sqlsrv driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Sqlsrv::class, $this->connection->getNativeConnection()); | ||
Check failure on line 61 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
Check failure on line 61 in tests/Functional/Driver/PDO/PDOSubclassTest.php GitHub Actions / Static Analysis with Psalm (8.3)UndefinedClass
|
||
} | ||
} |