Skip to content

Amend PDO driver-specific class names #14069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion ext/pdo_dblib/pdo_dblib.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ PHP_MINIT_FUNCTION(pdo_dblib)
return FAILURE;
}

PdoDblib_ce = register_class_PdoDblib(pdo_dbh_ce);
PdoDblib_ce = register_class_Pdo_Dblib(pdo_dbh_ce);
PdoDblib_ce->create_object = pdo_dbh_new;

if (FAILURE == php_pdo_register_driver(&pdo_dblib_driver)) {
Expand Down
4 changes: 3 additions & 1 deletion ext/pdo_dblib/pdo_dblib.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

/** @generate-class-entries */

namespace Pdo;

/**
* @strict-properties
* @not-serializable
*/
class PdoDblib extends PDO
class Dblib extends PDO
{
/** @cvalue PDO_DBLIB_ATTR_CONNECTION_TIMEOUT */
public const int ATTR_CONNECTION_TIMEOUT = UNKNOWN;
Expand Down
10 changes: 5 additions & 5 deletions ext/pdo_dblib/pdo_dblib_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ext/pdo_dblib/tests/pdodblib_001.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
PdoDblib basic
Pdo\Dblib basic
--EXTENSIONS--
pdo_dblib
--SKIPIF--
Expand All @@ -11,7 +11,7 @@ getDbConnection();
<?php

require __DIR__ . '/config.inc';
$db = getDbConnection(PdoDblib::class);
$db = getDbConnection(Pdo\Dblib::class);

$db->query("CREATE TABLE #pdo_dblib_001(name VARCHAR(32)); ");
$db->query("INSERT INTO #pdo_dblib_001 VALUES('PHP'), ('PHP6');");
Expand Down
6 changes: 3 additions & 3 deletions ext/pdo_dblib/tests/pdodblib_002.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
PdoDblib create through PDO::connect
Pdo\Dblib create through PDO::connect
--EXTENSIONS--
pdo_dblib
--SKIPIF--
Expand All @@ -13,8 +13,8 @@ getDbConnection();
require __DIR__ . '/config.inc';

$db = connectToDb();
if (!$db instanceof PdoDblib) {
echo "Wrong class type. Should be PdoDblib but is " . get_class($db) . "\n";
if (!$db instanceof Pdo\Dblib) {
echo "Wrong class type. Should be Pdo\Dblib but is " . get_class($db) . "\n";
}

$db->query("CREATE TABLE #pdo_dblib_002(name VARCHAR(32))");
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_firebird/pdo_firebird.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
return FAILURE;
}

PdoFirebird_ce = register_class_PdoFirebird(pdo_dbh_ce);
PdoFirebird_ce = register_class_Pdo_Firebird(pdo_dbh_ce);
PdoFirebird_ce->create_object = pdo_dbh_new;

#ifdef ZEND_SIGNALS
Expand Down
4 changes: 3 additions & 1 deletion ext/pdo_firebird/pdo_firebird.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

/** @generate-class-entries */

namespace Pdo;

/**
* @strict-properties
* @not-serializable
*/
class PdoFirebird extends PDO
class Firebird extends PDO
{
/** @cvalue PDO_FB_ATTR_DATE_FORMAT */
public const int ATTR_DATE_FORMAT = UNKNOWN;
Expand Down
10 changes: 5 additions & 5 deletions ext/pdo_firebird/pdo_firebird_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ext/pdo_firebird/tests/pdofirebird_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ See https://github.com/FirebirdSQL/firebird/issues/7849
require_once __DIR__ . "/testdb.inc";

$db = connectToDb();
if (!$db instanceof PdoFirebird) {
echo "Wrong class type. Should be PdoFirebird but is " . get_class($db) . "\n";
if (!$db instanceof Pdo\Firebird) {
echo "Wrong class type. Should be Pdo\Firebird but is " . get_class($db) . "\n";
}

$db->query('CREATE TABLE pdofirebird_002 (idx INT NOT NULL PRIMARY KEY, name VARCHAR(20))');
Expand Down
4 changes: 2 additions & 2 deletions ext/pdo_firebird/tests/testdb.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function getDbConnection($class = PDO::class): PDO {
return new $class(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS);
}

function connectToDb(): PdoFirebird {
return PdoFirebird::connect(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS);
function connectToDb(): Pdo\Firebird {
return Pdo\Firebird::connect(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS);
}

?>
8 changes: 3 additions & 5 deletions ext/pdo_mysql/pdo_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ static const MYSQLND_REVERSE_API pdo_mysql_reverse_api = {
};
#endif

/* proto string PDO::mysqlGetWarningCount()
* Returns the number of SQL warnings during the execution of the last statement
*/
PHP_METHOD(PdoMysql, getWarningCount)
/* Returns the number of SQL warnings during the execution of the last statement */
PHP_METHOD(Pdo_Mysql, getWarningCount)
{
pdo_dbh_t *dbh;
pdo_mysql_db_handle *H;
Expand Down Expand Up @@ -151,7 +149,7 @@ static PHP_MINIT_FUNCTION(pdo_mysql)
mysqlnd_reverse_api_register_api(&pdo_mysql_reverse_api);
#endif

pdo_mysql_ce = register_class_PdoMysql(pdo_dbh_ce);
pdo_mysql_ce = register_class_Pdo_Mysql(pdo_dbh_ce);
pdo_mysql_ce->create_object = pdo_dbh_new;

if (php_pdo_register_driver(&pdo_mysql_driver) == FAILURE) {
Expand Down
4 changes: 3 additions & 1 deletion ext/pdo_mysql/pdo_mysql.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

/** @generate-class-entries */

namespace Pdo;

/**
* @strict-properties
* @not-serializable
*/
class PdoMysql extends PDO
class Mysql extends PDO
{
/** @cvalue PDO_MYSQL_ATTR_USE_BUFFERED_QUERY */
public const int ATTR_USE_BUFFERED_QUERY = UNKNOWN;
Expand Down
16 changes: 8 additions & 8 deletions ext/pdo_mysql/pdo_mysql_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/pdo_mysql/tests/pdomysql_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MySQLPDOTest::skip();

require_once __DIR__ . '/inc/mysql_pdo_test.inc';

$db = MySQLPDOTest::factory(PdoMysql::class);
$db = MySQLPDOTest::factory(Pdo\Mysql::class);

$db->query('CREATE TABLE pdomysql_001 (id INT, name TEXT)');

Expand Down
4 changes: 2 additions & 2 deletions ext/pdo_mysql/tests/pdomysql_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ MySQLPDOTest::skip();
require_once __DIR__ . '/inc/mysql_pdo_test.inc';

$db = Pdo::connect(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS);
if (!$db instanceof PdoMysql) {
echo "Wrong class type. Should be PdoMysql but is " . get_class($db) . "\n";
if (!$db instanceof Pdo\Mysql) {
echo "Wrong class type. Should be Pdo\Mysql but is " . get_class($db) . "\n";
}

$db->exec('CREATE TABLE pdomysql_002(id INT NOT NULL PRIMARY KEY, name VARCHAR(10))');
Expand Down
4 changes: 2 additions & 2 deletions ext/pdo_mysql/tests/pdomysql_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ MySQLPDOTest::skip();
require_once __DIR__ . '/inc/mysql_pdo_test.inc';

$db = Pdo::connect(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS);
if (!$db instanceof PdoMysql) {
echo "Wrong class type. Should be PdoMysql but is " . get_class($db) . "\n";
if (!$db instanceof Pdo\Mysql) {
echo "Wrong class type. Should be Pdo\Mysql but is " . get_class($db) . "\n";
}

$assertWarnings = function ($db, $q, $count) {
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_odbc/pdo_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PHP_MINIT_FUNCTION(pdo_odbc)
REGISTER_PDO_CLASS_CONST_LONG("ODBC_SQL_USE_DRIVER", SQL_CUR_USE_DRIVER);
REGISTER_PDO_CLASS_CONST_LONG("ODBC_SQL_USE_ODBC", SQL_CUR_USE_ODBC);

pdo_odbc_ce = register_class_PdoOdbc(pdo_dbh_ce);
pdo_odbc_ce = register_class_Pdo_Odbc(pdo_dbh_ce);
pdo_odbc_ce->create_object = pdo_dbh_new;

return php_pdo_register_driver_specific_ce(&pdo_odbc_driver, pdo_odbc_ce);
Expand Down
46 changes: 25 additions & 21 deletions ext/pdo_odbc/pdo_odbc.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@

/** @generate-class-entries */

/**
* @var string
* @cvalue PDO_ODBC_TYPE
*/
const PDO_ODBC_TYPE = UNKNOWN;
namespace {
/**
* @var string
* @cvalue PDO_ODBC_TYPE
*/
const PDO_ODBC_TYPE = UNKNOWN;
}

/**
* @strict-properties
* @not-serializable
*/
class PdoOdbc extends PDO
{
/** @cvalue PDO_ODBC_ATTR_USE_CURSOR_LIBRARY */
public const int ATTR_USE_CURSOR_LIBRARY = UNKNOWN;
namespace Pdo {
/**
* @strict-properties
* @not-serializable
*/
class Odbc extends PDO
{
/** @cvalue PDO_ODBC_ATTR_USE_CURSOR_LIBRARY */
public const int ATTR_USE_CURSOR_LIBRARY = UNKNOWN;

/** @cvalue PDO_ODBC_ATTR_ASSUME_UTF8 */
public const int ATTR_ASSUME_UTF8 = UNKNOWN;
/** @cvalue PDO_ODBC_ATTR_ASSUME_UTF8 */
public const int ATTR_ASSUME_UTF8 = UNKNOWN;

/** @cvalue SQL_CUR_USE_IF_NEEDED */
public const int SQL_USE_IF_NEEDED = UNKNOWN;
/** @cvalue SQL_CUR_USE_IF_NEEDED */
public const int SQL_USE_IF_NEEDED = UNKNOWN;

/** @cvalue SQL_CUR_USE_DRIVER */
public const int SQL_USE_DRIVER = UNKNOWN;
/** @cvalue SQL_CUR_USE_DRIVER */
public const int SQL_USE_DRIVER = UNKNOWN;

/** @cvalue SQL_CUR_USE_ODBC */
public const int SQL_USE_ODBC = UNKNOWN;
/** @cvalue SQL_CUR_USE_ODBC */
public const int SQL_USE_ODBC = UNKNOWN;
}
}
10 changes: 5 additions & 5 deletions ext/pdo_odbc/pdo_odbc_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/pdo_odbc/tests/pdoodbc_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PDOTest::skip();

require 'ext/pdo/tests/pdo_test.inc';
$config = PDOTest::get_config(__DIR__ . "/common.phpt");
$db = new PdoOdbc($config['ENV']['PDOTEST_DSN'], $config['ENV']['PDOTEST_USER'], $config['ENV']['PDOTEST_PASS']);
$db = new Pdo\Odbc($config['ENV']['PDOTEST_DSN'], $config['ENV']['PDOTEST_USER'], $config['ENV']['PDOTEST_PASS']);

$db->query("CREATE TABLE pdoodbc_001 (id INT, name TEXT)");
$db->query("INSERT INTO pdoodbc_001 VALUES (NULL, 'PHP'), (NULL, 'PHP6')");
Expand Down
6 changes: 3 additions & 3 deletions ext/pdo_odbc/tests/pdoodbc_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ PDOTest::skip();

require 'ext/pdo/tests/pdo_test.inc';
$config = PDOTest::get_config(__DIR__ . "/common.phpt");
$db = PdoOdbc::connect($config['ENV']['PDOTEST_DSN'], $config['ENV']['PDOTEST_USER'], $config['ENV']['PDOTEST_PASS']);
if (!$db instanceof PdoOdbc) {
echo "Wrong class type. Should be PdoOdbc but is " . get_class($db) . "\n";
$db = Pdo\Odbc::connect($config['ENV']['PDOTEST_DSN'], $config['ENV']['PDOTEST_USER'], $config['ENV']['PDOTEST_PASS']);
if (!$db instanceof Pdo\Odbc) {
echo "Wrong class type. Should be Pdo\Odbc but is " . get_class($db) . "\n";
}

$db->exec('CREATE TABLE pdoodbc_002(id INT NOT NULL PRIMARY KEY, name VARCHAR(10))');
Expand Down
Loading
Loading