8000 Add stubs for PDO · php/php-src@c7c2832 · GitHub
[go: up one dir, main page]

Skip to content

Commit c7c2832

Browse files
committed
Add stubs for PDO
1 parent 170ed1f commit c7c2832

File tree

6 files changed

+312
-158
lines changed

6 files changed

+312
-158
lines changed

Zend/tests/bug71428.2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bug #71428.2: inheritance of ye olde dynamic interfaces
55
--FILE--
66
<?php
77
interface StatementInterface {
8-
public function fetch($first = null, $second, $third);
8+
public function fetch($first = PDO::FETCH_BOTH, $second = PDO::FETCH_ORI_NEXT, $third = 0);
99
}
1010

1111
class Statement extends PDOStatement implements StatementInterface {}

ext/pdo/pdo.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "php_pdo_int.h"
3030
#include "zend_exceptions.h"
3131
#include "ext/spl/spl_exceptions.h"
32+
#include "pdo_arginfo.h"
3233

3334
zend_class_entry *pdo_dbh_ce, *pdo_dbstmt_ce, *pdo_row_ce;
3435

@@ -96,11 +97,6 @@ PHP_FUNCTION(pdo_drivers)
9697
}
9798
/* }}} */
9899

99-
/* {{{ arginfo */
100-
ZEND_BEGIN_ARG_INFO(arginfo_pdo_drivers, 0)
101-
ZEND_END_ARG_INFO()
102-
/* }}} */
103-
104100
/* {{{ pdo_functions[] */
105101
const zend_function_entry pdo_functions[] = {
106102
PHP_FE(pdo_drivers, arginfo_pdo_drivers)

ext/pdo/pdo.stub.php

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
3+
/* pdo.c */
4+
5+
function pdo_drivers(): array {}
6+
7+
/* pdo_dbh.c */
8+
9+
class PDO {
10+
public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {}
11+
12+
/** @return bool */
13+
public function beginTransaction() {}
14+
15+
/** @return bool */
16+
public function commit() {}
17+
18+
/** @return string|null */
19+
public function errorCode() {}
20+
21+
/** @return array */
22+
public function errorInfo() {}
23+
24+
/** @return int|false */
25+
public function exec(string $statement) {}
26+
27+
/** @return mixed */
28+
public function getAttribute(int $attribute) {}
29+
30+
/** @return array */
31+
public static function getAvailableDrivers() {}
32+
33+
/** @return bool */
34+
public function inTransaction() {}
35+
36+
/** @return string|false */
37+
public function lastInsertId(?string $name = null) {}
38+
39+
/** @return PDOStatement|false */
40+
public function prepare(string $statement, array $driver_options = []) {}
41+
42+
/** @return PDOStatement|false */
43+
public function query(string $statement) {}
44+
45+
/** @return string|false */
46+
public function quote(string $string, int $parameter_type = PDO::PARAM_STR) {}
47+
48+
/** @return bool */
49+
public function rollBack() {}
50+
51+
/**
52+
* @param mixed $value
53+
* @return bool
54+
*/
55+
public function setAttribute(int $attribute, $value) {}
56+
}
57+
58+
/* pdo_stmt.c */
59+
60+
class PDOStatement implements Traversable {
61+
/** @return bool */
62+
public function bindColumn(mixed $column, &$param = null, int $type = 0, int $maxlen = 0, mixed $driverdata = "") {}
63+
64+
/**
65+
* @param int|string $parameter
66+
* @param mixed $driver_options
67+
* @return bool
68+
*/
69+
public function bindParam($parameter, &$variable, int $data_type = PDO::PARAM_STR, ?int $length = null, $driver_options = null) {}
70+
71+
/**
72+
* @param int|string $parameter
73+
* @param mixed $value
74+
* @return bool
75+
*/
76+
public function bindValue($parameter, $value, int $data_type = PDO::PARAM_STR) {}
77+
78+
/** @return bool */
79+
public function closeCursor() {}
80+
81+
/** @return int */
82+
public function columnCount() {}
83+
84+
/** @return void */
85+
public function debugDumpParams() {}
86+
87+
/** @return string|null */
88+
public function errorCode() {}
89+
90+
/** @return array */
91+
public function errorInfo() {}
92+
93+
/** @return bool */
94+
public function execute(?array $input_parameters = null) {}
95+
96+
/** @return mixed */
97+
public function fetch(?int $fetch_style = PDO::FETCH_BOTH, ?int $cursor_orientation = PDO::FETCH_ORI_NEXT, ?int $cursor_offset = 0) {}
98+
99+
/**
100+
* @param mixed $fetch_argument
101+
* @return array|false
102+
*/
103+
public function fetchAll(int $fetch_style = PDO::FETCH_BOTH, $fetch_argument = null, array $ctor_args = []) {}
104+
105+
/** @return mixed */
106+
public function fetchColumn(int $column_number = 0) {}
107+
108+
/** @return mixed */
109+
public function fetchObject(string $class_name = "stdClass", ?array $ctor_args = null) {}
110+
111+
/** @return int|bool|string|array */
112+
public function getAttribute(int $attribute) {}
113+
114+
/** @return array|false */
115+
public function getColumnMeta(int $column) {}
116+
117+
/** @return bool */
118+
public function nextRowset() {}
119+
120+
/** @return int */
121+
public function rowCount() {}
122+
123+
/** @return bool */
124+
public function setAttribute(int $attribute, mixed $value) {}
125+
126+
/** @return bool */
127+
public function setFetchMode(int $mode) {}
128+
}

ext/pdo/pdo_arginfo.h

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/* This is a generated file, edit the .stub.php file instead. */
2+
3+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pdo_drivers, 0, 0, IS_ARRAY, 0)
4+
ZEND_END_ARG_INFO()
5+
6+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO___construct, 0, 0, 1)
7+
ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0)
8+
ZEND_ARG_TYPE_INFO(0, username, IS_STRING, 1)
9+
ZEND_ARG_TYPE_INFO(0, passwd, IS_STRING, 1)
10+
ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 1)
11+
ZEND_END_ARG_INFO()
12+
13+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_beginTransaction, 0, 0, 0)
14+
ZEND_END_ARG_INFO()
15+
16+
#define arginfo_class_PDO_commit arginfo_class_PDO_beginTransaction
17+
18+
#define arginfo_class_PDO_errorCode arginfo_class_PDO_beginTransaction
19+
20+
#define arginfo_class_PDO_errorInfo arginfo_class_PDO_beginTransaction
21+
22+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_exec, 0, 0, 1)
23+
ZEND_ARG_TYPE_INFO(0, statement, IS_STRING, 0)
24+
ZEND_END_ARG_INFO()
25+
26+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_getAttribute, 0, 0, 1)
27+
ZEND_ARG_TYPE_INFO(0, attribute, IS_LONG, 0)
28+
ZEND_END_ARG_INFO()
29+
30+
#define arginfo_class_PDO_getAvailableDrivers arginfo_class_PDO_beginTransaction
31+
32+
#define arginfo_class_PDO_inTransaction arginfo_class_PDO_beginTransaction
33+
34+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_lastInsertId, 0, 0, 0)
35+
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)
36+
ZEND_END_ARG_INFO()
37+
38+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_prepare, 0, 0, 1)
39+
ZEND_ARG_TYPE_INFO(0, statement, IS_STRING, 0)
40+
ZEND_ARG_TYPE_INFO(0, driver_options, IS_ARRAY, 0)
41+
ZEND_END_ARG_INFO()
42+
43+
#define arginfo_class_PDO_query arginfo_class_PDO_exec
44+
45+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_quote, 0, 0, 1)
46+
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
47+
ZEND_ARG_TYPE_INFO(0, parameter_type, IS_LONG, 0)
48+
ZEND_END_ARG_INFO()
49+
50+
#define arginfo_class_PDO_rollBack arginfo_class_PDO_beginTransaction
51+
52+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_setAttribute, 0, 0, 2)
53+
ZEND_ARG_TYPE_INFO(0, attribute, IS_LONG, 0)
54+
ZEND_ARG_INFO(0, value)
55+
ZEND_END_ARG_INFO()
56+
57+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindColumn, 0, 0, 1)
58+
ZEND_ARG_OBJ_INFO(0, column, mixed, 0)
59+
ZEND_ARG_INFO(1, param)
60+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
61+
ZEND_ARG_TYPE_INFO(0, maxlen, IS_LONG, 0)
62+
ZEND_ARG_OBJ_INFO(0, driverdata, mixed, 0)
63+
ZEND_END_ARG_INFO()
64+
65+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindParam, 0, 0, 2)
66+
ZEND_ARG_INFO(0, parameter)
67+
ZEND_ARG_INFO(1, variable)
68+
ZEND_ARG_TYPE_INFO(0, data_type, IS_LONG, 0)
69+
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 1)
70+
ZEND_ARG_INFO(0, driver_options)
71+
ZEND_END_ARG_INFO()
72+
73+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindValue, 0, 0, 2)
74+
ZEND_ARG_INFO(0, parameter)
75+
ZEND_ARG_INFO(0, value)
76+
ZEND_ARG_TYPE_INFO(0, data_type, IS_LONG, 0)
77+
ZEND_END_ARG_INFO()
78+
1241
79+
#define arginfo_class_PDOStatement_closeCursor arginfo_class_PDO_beginTransaction
80+
81+
#define arginfo_class_PDOStatement_columnCount arginfo_class_PDO_beginTransaction
82+
83+
#define arginfo_class_PDOStatement_debugDumpParams arginfo_class_PDO_beginTransaction
84+
85+
#define arginfo_class_PDOStatement_errorCode arginfo_class_PDO_beginTransaction
86+
87+
#define arginfo_class_PDOStatement_errorInfo arginfo_class_PDO_beginTransaction
88+
89+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_execute, 0, 0, 0)
90+
ZEND_ARG_TYPE_INFO(0, input_parameters, IS_ARRAY, 1)
91+
ZEND_END_ARG_INFO()
92+
93+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetch, 0, 0, 0)
94+
ZEND_ARG_TYPE_INFO(0, fetch_style, IS_LONG, 1)
95+
ZEND_ARG_TYPE_INFO(0, cursor_orientation, IS_LONG, 1)
96+
ZEND_ARG_TYPE_INFO(0, cursor_offset, IS_LONG, 1)
97+
ZEND_END_ARG_INFO()
98+
99+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchAll, 0, 0, 0)
100+
ZEND_ARG_TYPE_INFO(0, fetch_style, IS_LONG, 0)
101+
ZEND_ARG_INFO(0, fetch_argument)
102+
ZEND_ARG_TYPE_INFO(0, ctor_args, IS_ARRAY, 0)
103+
ZEND_END_ARG_INFO()
104+
105+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchColumn, 0, 0, 0)
106+
ZEND_ARG_TYPE_INFO(0, column_number, IS_LONG, 0)
107+
ZEND_END_ARG_INFO()
108+
109+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchObject, 0, 0, 0)
110+
ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0)
111+
ZEND_ARG_TYPE_INFO(0, ctor_args, IS_ARRAY, 1)
112+
ZEND_END_ARG_INFO()
113+
114+
#define arginfo_class_PDOStatement_getAttribute arginfo_class_PDO_getAttribute
115+
116+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_getColumnMeta, 0, 0, 1)
117+
ZEND_ARG_TYPE_INFO(0, column, IS_LONG, 0)
118+
ZEND_END_ARG_INFO()
119+
120+
#define arginfo_class_PDOStatement_nextRowset arginfo_class_PDO_beginTransaction
121+
122+
#define arginfo_class_PDOStatement_rowCount arginfo_class_PDO_beginTransaction
123+
124+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setAttribute, 0, 0, 2)
125+
ZEND_ARG_TYPE_INFO(0, attribute, IS_LONG, 0)
126+
ZEND_ARG_OBJ_INFO(0, value, mixed, 0)
127+
ZEND_END_ARG_INFO()
128+
129+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setFetchMode, 0, 0, 1)
130+
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
131+
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)
0