diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-07-21 12:33:25 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-07-21 12:49:36 +0200 |
commit | 1afcced1f0dfc8afd12bef4fb2cb08048edfd8af (patch) | |
tree | 08f01a71d30e64a25089ff6fff99b74fa1ba0c92 | |
parent | 047474c3b4dddd997ee3b8f66d0c4f091a40c02c (diff) | |
download | php-git-1afcced1f0dfc8afd12bef4fb2cb08048edfd8af.tar.gz |
Add stubs for PDO SQLite extension methods
Putting these under a dummy PDO_SQLite_Ext class.
-rw-r--r-- | ext/pdo_sqlite/sqlite_driver.c | 16 | ||||
-rw-r--r-- | ext/pdo_sqlite/sqlite_driver.stub.php | 15 | ||||
-rw-r--r-- | ext/pdo_sqlite/sqlite_driver_arginfo.h | 34 | ||||
-rw-r--r-- | ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt | 4 | ||||
-rw-r--r-- | ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt | 2 |
5 files changed, 57 insertions, 14 deletions
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c index c0962ff3f9..090cb41c08 100644 --- a/ext/pdo_sqlite/sqlite_driver.c +++ b/ext/pdo_sqlite/sqlite_driver.c @@ -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; diff --git a/ext/pdo_sqlite/sqlite_driver.stub.php b/ext/pdo_sqlite/sqlite_driver.stub.php new file mode 100644 index 0000000000..eafd3c0c48 --- /dev/null +++ b/ext/pdo_sqlite/sqlite_driver.stub.php @@ -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) {} +} diff --git a/ext/pdo_sqlite/sqlite_driver_arginfo.h b/ext/pdo_sqlite/sqlite_driver_arginfo.h new file mode 100644 index 0000000000..1eb797e7cc --- /dev/null +++ b/ext/pdo_sqlite/sqlite_driver_arginfo.h @@ -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 +}; diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt index 04e4e3076b..5660288af3 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt @@ -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 diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt index d0a87201dc..958ea0c484 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt @@ -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 |