Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Php84/Resources/stubs/Pdo/Dblib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pdo;

use PDO;

if (\PHP_VERSION_ID < 80400) {
class Dblib
{
public const ATTR_CONNECTION_TIMEOUT = PDO::DBLIB_ATTR_CONNECTION_TIMEOUT;
public const ATTR_QUERY_TIMEOUT = PDO::DBLIB_ATTR_QUERY_TIMEOUT;
public const ATTR_STRINGIFY_UNIQUEIDENTIFIER = PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER;
public const ATTR_VERSION = PDO::DBLIB_ATTR_VERSION;
public const ATTR_TDS_VERSION = \PHP_VERSION_ID >= 70300 ? PDO::DBLIB_ATTR_TDS_VERSION : 1004;
public const ATTR_SKIP_EMPTY_ROWSETS = \PHP_VERSION_ID >= 70300 ? PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS : 1005;
public const ATTR_DATETIME_CONVERT = \PHP_VERSION_ID >= 70300 ? \PDO::DBLIB_ATTR_DATETIME_CONVERT : 1006;
}
}
22 changes: 22 additions & 0 deletions src/Php84/Resources/stubs/Pdo/Firebird.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pdo;

use PDO;

if (\PHP_VERSION_ID < 80400) {
class Firebird
{
public const ATTR_DATE_FORMAT = PDO::FB_ATTR_DATE_FORMAT;
public const ATTR_TIME_FORMAT = PDO::FB_ATTR_TIME_FORMAT;
public const ATTR_TIMESTAMP_FORMAT = PDO::FB_ATTR_TIMESTAMP_FORMAT;
}
}
38 changes: 38 additions & 0 deletions src/Php84/Resources/stubs/Pdo/Mysql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pdo;

use PDO;

if (\PHP_VERSION_ID < 80400) {
class Mysql
{
public const ATTR_COMPRESS = PDO::MYSQL_ATTR_COMPRESS;
public const ATTR_DIRECT_QUERY = PDO::MYSQL_ATTR_DIRECT_QUERY;
public const ATTR_FOUND_ROWS = PDO::MYSQL_ATTR_FOUND_ROWS;
public const ATTR_IGNORE_SPACE = PDO::MYSQL_ATTR_IGNORE_SPACE;
public const ATTR_INIT_COMMAND = PDO::MYSQL_ATTR_INIT_COMMAND;
public const ATTR_LOCAL_INFILE = PDO::MYSQL_ATTR_LOCAL_INFILE;
public const ATTR_LOCAL_INFILE_DIRECTORY = \PHP_VERSION_ID >= 80100 ? \PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY : 1015;
public const ATTR_MAX_BUFFER_SIZE = PDO::MYSQL_ATTR_MAX_BUFFER_SIZE;
public const ATTR_MULTI_STATEMENTS = PDO::MYSQL_ATTR_MULTI_STATEMENTS;
public const ATTR_READ_DEFAULT_FILE = PDO::MYSQL_ATTR_READ_DEFAULT_FILE;
public const ATTR_READ_DEFAULT_GROUP = PDO::MYSQL_ATTR_READ_DEFAULT_GROUP;
public const ATTR_SERVER_PUBLIC_KEY = PDO::MYSQL_ATTR_SERVER_PUBLIC_KEY;
public const ATTR_SSL_CA = PDO::MYSQL_ATTR_SSL_CA;
public const ATTR_SSL_CAPATH = PDO::MYSQL_ATTR_SSL_CAPATH;
public const ATTR_SSL_CERT = PDO::MYSQL_ATTR_SSL_CERT;
public const ATTR_SSL_CIPHER = PDO::MYSQL_ATTR_SSL_CIPHER;
public const ATTR_SSL_KEY = PDO::MYSQL_ATTR_SSL_KEY;
public const ATTR_SSL_VERIFY_SERVER_CERT = PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT;
public const ATTR_USE_BUFFERED_QUERY = PDO::MYSQL_ATTR_USE_BUFFERED_QUERY;
}
}
24 changes: 24 additions & 0 deletions src/Php84/Resources/stubs/Pdo/Odbc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pdo;

use PDO;

if (\PHP_VERSION_ID < 80400) {
class Odbc
{
public const ATTR_USE_CURSOR_LIBRARY = PDO::ODBC_ATTR_USE_CURSOR_LIBRARY;
public const ATTR_ASSUME_UTF8 = PDO::ODBC_ATTR_ASSUME_UTF8;
public const SQL_USE_IF_NEEDED = PDO::ODBC_SQL_USE_IF_NEEDED;
public const SQL_USE_DRIVER = PDO::ODBC_SQL_USE_DRIVER;
public const SQL_USE_ODBC = PDO::ODBC_SQL_USE_ODBC;
}
}
20 changes: 20 additions & 0 deletions src/Php84/Resources/stubs/Pdo/Pgsql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pdo;

use PDO;

if (\PHP_VERSION_ID < 80400) {
class Pgsql
{
public const ATTR_DISABLE_PREPARES = PDO::PGSQL_ATTR_DISABLE_PREPARES;
}
}
26 changes: 26 additions & 0 deletions src/Php84/Resources/stubs/Pdo/Sqlite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pdo;

use PDO;

if (\PHP_VERSION_ID < 80400) {
class Sqlite
{
public const ATTR_EXTENDED_RESULT_CODES = \PHP_VERSION_ID >= 70400 ? \PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES : 1002;
public const ATTR_OPEN_FLAGS = \PHP_VERSION_ID >= 70300 ? \PDO::SQLITE_ATTR_OPEN_FLAGS : 1000;
public const ATTR_READONLY_STATEMENT = \PHP_VERSION_ID >= 70400 ? \PDO::SQLITE_ATTR_READONLY_STATEMENT : 1001;
public const DETERMINISTIC = PDO::SQLITE_DETERMINISTIC;
public const OPEN_READONLY = \PHP_VERSION_ID >= 70300 ? \PDO::SQLITE_OPEN_READONLY : 1;
public const OPEN_READWRITE = \PHP_VERSION_ID >= 70300 ? \PDO::SQLITE_OPEN_READWRITE : 2;
public const OPEN_CREATE = \PHP_VERSION_ID >= 70300 ? \PDO::SQLITE_OPEN_CREATE : 4;
}
}
109 changes: 109 additions & 0 deletions tests/Php84/PdoTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Tests\Php84;

use PHPUnit\Framework\TestCase;

class PdoTest extends TestCase
{
/**
* @requires extension pdo_dblib
*/
public function testDblibConstants()
{
$this->assertSame(1000, \Pdo\Dblib::ATTR_CONNECTION_TIMEOUT);
$this->assertSame(1001, \Pdo\Dblib::ATTR_QUERY_TIMEOUT);
$this->assertSame(1002, \Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER);
$this->assertSame(1003, \Pdo\Dblib::ATTR_VERSION);
$this->assertSame(1004, \Pdo\Dblib::ATTR_TDS_VERSION);
$this->assertSame(1005, \Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS);
$this->assertSame(1006, \Pdo\Dblib::ATTR_DATETIME_CONVERT);
}

/**
* @requires extension pdo_firebird
*/
public function testFirebirdConstants()
{
$this->assertSame(1000, \Pdo\Firebird::ATTR_DATE_FORMAT);
$this->assertSame(1001, \Pdo\Firebird::ATTR_TIME_FORMAT);
$this->assertSame(1002, \Pdo\Firebird::ATTR_TIMESTAMP_FORMAT);
}

/**
* @requires extension pdo_mysql
*/
public function testMysqlConstants()
{
$this->assertSame(1000, \Pdo\Mysql::ATTR_USE_BUFFERED_QUERY);
$this->assertSame(1001, \Pdo\Mysql::ATTR_LOCAL_INFILE);
$this->assertSame(1002, \Pdo\Mysql::ATTR_INIT_COMMAND);
$this->assertSame(1003, \Pdo\Mysql::ATTR_COMPRESS);
$this->assertSame(1004, \Pdo\Mysql::ATTR_DIRECT_QUERY);
$this->assertSame(1005, \Pdo\Mysql::ATTR_FOUND_ROWS);
$this->assertSame(1006, \Pdo\Mysql::ATTR_IGNORE_SPACE);
$this->assertSame(1007, \Pdo\Mysql::ATTR_SSL_KEY);
$this->assertSame(1008, \Pdo\Mysql::ATTR_SSL_CERT);
$this->assertSame(1009, \Pdo\Mysql::ATTR_SSL_CA);
$this->assertSame(1010, \Pdo\Mysql::ATTR_SSL_CAPATH);
$this->assertSame(1011, \Pdo\Mysql::ATTR_SSL_CIPHER);
$this->assertSame(1012, \Pdo\Mysql::ATTR_SERVER_PUBLIC_KEY);
$this->assertSame(1013, \Pdo\Mysql::ATTR_MULTI_STATEMENTS);
$this->assertSame(1014, \Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT);
$this->assertSame(1015, \Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY);
}

/**
* @requires extension pdo_mysql
* @requires extension libmysqlclient
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is probably 'wrong' and will always be skipped; these constants are only defined when one is not using mysqlnd (see https://github.com/php/php-src/blob/0d4ff662e6d83fd3db0134fc826438307431335a/ext/pdo_mysql/pdo_mysql.stub.php#L22) which seems rare (see also https://www.php.net/manual/en/mysqlinfo.library.choosing.php).

I don't think there's any way to test this, so probably the best way to go here is just drop these or otherwise stick with just some comment as to why these are not tested.

Please let me know what would be the preferable course of action here.

*/
public function testMysqlConstantsMysqlnd()
{
$this->assertSame(1003, \Pdo\Mysql::ATTR_READ_DEFAULT_FILE);
$this->assertSame(1004, \Pdo\Mysql::ATTR_READ_DEFAULT_GROUP);
$this->assertSame(1005, \Pdo\Mysql::ATTR_MAX_BUFFER_SIZE);
}

/**
* @requires extension pdo_odbc
*/
public function testOdbcConstants()
{
$this->assertSame(0, \Pdo\Odbc::SQL_USE_IF_NEEDED);
$this->assertSame(1, \Pdo\Odbc::SQL_USE_ODBC);
$this->assertSame(2, \Pdo\Odbc::SQL_USE_DRIVER);
$this->assertSame(1000, \Pdo\Odbc::ATTR_USE_CURSOR_LIBRARY);
$this->assertSame(1001, \Pdo\Odbc::ATTR_ASSUME_UTF8);
}

/**
* @requires extension pdo_pgsql
*/
public function testPgsqlConstants()
{
$this->assertSame(1000, \Pdo\Pgsql::ATTR_DISABLE_PREPARES);
}

/**
* @requires extension pdo_sqlite
*/
public function testSqliteConstants()
{
$this->assertSame(1, \Pdo\Sqlite::OPEN_READONLY);
$this->assertSame(2, \Pdo\Sqlite::OPEN_READWRITE);
$this->assertSame(4, \Pdo\Sqlite::OPEN_CREATE);
$this->assertSame(1000, \Pdo\Sqlite::ATTR_OPEN_FLAGS);
$this->assertSame(1001, \Pdo\Sqlite::ATTR_READONLY_STATEMENT);
$this->assertSame(1002, \Pdo\Sqlite::ATTR_EXTENDED_RESULT_CODES);
$this->assertSame(2048, \Pdo\Sqlite::DETERMINISTIC);
}
}
Loading