mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Add stubs for PDO SQLite extension methods
Putting these under a dummy PDO_SQLite_Ext class.
This commit is contained in:
parent
047474c3b4
commit
1afcced1f0
5 changed files with 57 additions and 14 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "php_pdo_sqlite.h"
|
||||
#include "php_pdo_sqlite_int.h"
|
||||
#include "zend_exceptions.h"
|
||||
#include "sqlite_driver_arginfo.h"
|
||||
|
||||
int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line) /* {{{ */
|
||||
{
|
||||
|
@ -516,7 +517,7 @@ static int php_sqlite3_collation_callback(void *context,
|
|||
|
||||
/* {{{ bool SQLite::sqliteCreateFunction(string name, callable callback [, int argcount, int flags])
|
||||
Registers a UDF with the sqlite db handle */
|
||||
static PHP_METHOD(SQLite, sqliteCreateFunction)
|
||||
PHP_METHOD(PDO_SQLite_Ext, sqliteCreateFunction)
|
||||
{
|
||||
struct pdo_sqlite_func *func;
|
||||
zend_fcall_info fci;
|
||||
|
@ -583,7 +584,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
|
|||
aggregate UDF.
|
||||
*/
|
||||
|
||||
static PHP_METHOD(SQLite, sqliteCreateAggregate)
|
||||
PHP_METHOD(PDO_SQLite_Ext, sqliteCreateAggregate)
|
||||
{
|
||||
struct pdo_sqlite_func *func;
|
||||
zend_fcall_info step_fci, fini_fci;
|
||||
|
@ -634,7 +635,7 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
|
|||
|
||||
/* {{{ bool SQLite::sqliteCreateCollation(string name, callable callback)
|
||||
Registers a collation with the sqlite db handle */
|
||||
static PHP_METHOD(SQLite, sqliteCreateCollation)
|
||||
PHP_METHOD(PDO_SQLite_Ext, sqliteCreateCollation)
|
||||
{
|
||||
struct pdo_sqlite_collation *collation;
|
||||
zend_fcall_info fci;
|
||||
|
@ -674,18 +675,11 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static const zend_function_entry dbh_methods[] = {
|
||||
PHP_ME(SQLite, sqliteCreateFunction, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(SQLite, sqliteCreateAggregate, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_ME(SQLite, sqliteCreateCollation, NULL, ZEND_ACC_PUBLIC)
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
static const zend_function_entry *get_driver_methods(pdo_dbh_t *dbh, int kind)
|
||||
{
|
||||
switch (kind) {
|
||||
case PDO_DBH_DRIVER_METHOD_KIND_DBH:
|
||||
return dbh_methods;
|
||||
return class_PDO_SQLite_Ext_methods;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
|
|
15
ext/pdo_sqlite/sqlite_driver.stub.php
Normal file
15
ext/pdo_sqlite/sqlite_driver.stub.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
/** @generate-function-entries */
|
||||
|
||||
// These are extension methods for PDO. This is not a real class.
|
||||
class PDO_SQLite_Ext {
|
||||
/** @return bool */
|
||||
public function sqliteCreateFunction(string $function_name, callable $callback, int $num_args = -1, int $flags = 0) {}
|
||||
|
||||
/** @return bool */
|
||||
public function sqliteCreateAggregate(string $function_name, callable $step_func, callable $finalize_func, int $num_args = -1) {}
|
||||
|
||||
/** @return bool */
|
||||
public function sqliteCreateCollation(string $name, callable $callback) {}
|
||||
}
|
34
ext/pdo_sqlite/sqlite_driver_arginfo.h
Normal file
34
ext/pdo_sqlite/sqlite_driver_arginfo.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 5134a0b80848f852557b1c22ec102573d79ed9a4 */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateFunction, 0, 0, 2)
|
||||
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_args, IS_LONG, 0, "-1")
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateAggregate, 0, 0, 3)
|
||||
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, step_func, IS_CALLABLE, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, finalize_func, IS_CALLABLE, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_args, IS_LONG, 0, "-1")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateCollation, 0, 0, 2)
|
||||
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
|
||||
ZEND_METHOD(PDO_SQLite_Ext, sqliteCreateFunction);
|
||||
ZEND_METHOD(PDO_SQLite_Ext, sqliteCreateAggregate);
|
||||
ZEND_METHOD(PDO_SQLite_Ext, sqliteCreateCollation);
|
||||
|
||||
|
||||
static const zend_function_entry class_PDO_SQLite_Ext_methods[] = {
|
||||
ZEND_ME(PDO_SQLite_Ext, sqliteCreateFunction, arginfo_class_PDO_SQLite_Ext_sqliteCreateFunction, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(PDO_SQLite_Ext, sqliteCreateAggregate, arginfo_class_PDO_SQLite_Ext_sqliteCreateAggregate, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(PDO_SQLite_Ext, sqliteCreateCollation, arginfo_class_PDO_SQLite_Ext_sqliteCreateCollation, ZEND_ACC_PUBLIC)
|
||||
ZEND_FE_END
|
||||
};
|
|
@ -20,5 +20,5 @@ try {
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
PDO::sqliteCreateAggregate(): Argument #2 must be a valid callback, function "a" not found or invalid function name
|
||||
PDO::sqliteCreateAggregate(): Argument #3 must be a valid callback, function "" not found or invalid function name
|
||||
PDO::sqliteCreateAggregate(): Argument #2 ($step_func) must be a valid callback, function "a" not found or invalid function name
|
||||
PDO::sqliteCreateAggregate(): Argument #3 ($finalize_func) must be a valid callback, function "" not found or invalid function name
|
||||
|
|
|
@ -18,4 +18,4 @@ try {
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
PDO::sqliteCreateFunction(): Argument #2 must be a valid callback, function "bar" not found or invalid function name
|
||||
PDO::sqliteCreateFunction(): Argument #2 ($callback) must be a valid callback, function "bar" not found or invalid function name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue