Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0b6ceb

Browse files
committed
Add stubs for PDO
1 parent f226089 commit a0b6ceb

File tree

7 files changed

+318
-160
lines changed

7 files changed

+318
-160
lines changed

Zend/tests/bug71428.2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ 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(int $first = PDO::FETCH_BOTH, int $second = PDO::FETCH_ORI_NEXT, int $third = 0);
99
}
1010

1111
class Statement extends PDOStatement implements StatementInterface {}
1212

1313
interface StatementInterface1 {
14-
public function fetch($first = null, $second = null, $third = null);
14+
public function fetch(int $first = PDO::FETCH_ASSOC, int $second = PDO::FETCH_ORI_PRIOR, int $third = 1);
1515
}
1616

1717
class Statement1 extends PDOStatement implements StatementInterface1 {}

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: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
/**
62+
* @param mixed $column
63+
* @param mixed $driverdata
64+
* @return bool
65+
*/
66+
public function bindColumn($column, &$param = null, int $type = 0, int $maxlen = 0, $driverdata = "") {}
67+
68+
/**
69+
* @param int|string $parameter
70+
* @param mixed $driver_options
71+
* @return bool
72+
*/
73+
public function bindParam($parameter, &$variable, int $data_type = PDO::PARAM_STR, ?int $length = null, $driver_options = null) {}
74+
75+
/**
76+
* @param int|string $parameter
77+
* @param mixed $value
78+
* @return bool
79+
*/
80+
public function bindValue($parameter, $value, int $data_type = PDO::PARAM_STR) {}
81+
82+
/** @return bool */
83+
public function closeCursor() {}
84+
85+
/** @return int */
86+
public function columnCount() {}
87+
88+
/** @return void */
89+
public function debugDumpParams() {}
90+
91+
/** @return string|null */
92+
public function errorCode() {}
93+
94+
/** @return array */
95+
public function errorInfo() {}
96+
97+
/** @return bool */
98+
public function execute(?array $input_parameters = null) {}
99+
100+
/** @return mixed */
101+
public function fetch(int $fetch_style = PDO::FETCH_BOTH, int $cursor_orientation = PDO::FETCH_ORI_NEXT, int $cursor_offset = 0) {}
102+
103+
/**
104+
* @param mixed $fetch_argument
105+
* @return array|false
106+
*/
107+
public function fetchAll(int $fetch_style = PDO::FETCH_BOTH, $fetch_argument = null, array $ctor_args = []) {}
108+
109+
/** @return mixed */
110+
public function fetchColumn(int $column_number = 0) {}
111+
112+
/** @return mixed */
113+
public function fetchObject(string $class_name = "stdClass", ?array $ctor_args = null) {}
114+
115+
/** @return int|bool|string|array */
116+
public function getAttribute(int $attribute) {}
117+
118+
/** @return array|false */
119+
public function getColumnMeta(int $column) {}
120+
121+
/** @return bool */
122+
public function nextRowset() {}
123+
124+
/** @return int */
125+
public function rowCount() {}
126+
127+
/**
128+
* @param mixed $value
129+
* @return bool
130+
*/
131+
public function setAttribute(int $attribute, $value) {}
132+
133+
/** @return bool */
134+
public function setFetchMode(int $mode) {}
135+
}

ext/pdo/pdo_arginfo.h

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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_INFO(0, column)
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_INFO(0, driverdata)
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+
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, 0)
95+
ZEND_ARG_TYPE_INFO(0, cursor_orientation, IS_LONG, 0)
96+
ZEND_ARG_TYPE_INFO(0, cursor_offset, IS_LONG, 0)
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+
#define arginfo_class_PDOStatement_setAttribute arginfo_class_PDO_setAttribute
125+
126+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setFetchMode, 0, 0, 1)
127+
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
128+
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)