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

Skip to content

Commit 100552d

Browse files
kocsismatecmb69
authored andcommitted
Add stubs for PDO
1 parent a9e8cd2 commit 100552d

File tree

7 files changed

+311
-160
lines changed

7 files changed

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

ext/pdo/pdo_arginfo.h

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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, 2)
58+
ZEND_ARG_TYPE_MASK(0, column, MAY_BE_LONG|MAY_BE_STRING)
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_TYPE_MASK(0, parameter, MAY_BE_LONG|MAY_BE_STRING)
67+
ZEND_ARG_INFO(1, param)
68+
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
69+
ZEND_ARG_TYPE_INFO(0, maxlen, IS_LONG, 0)
70+
ZEND_ARG_INFO(0, driverdata)
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, 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, 1)
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_ARG_VARIADIC_INFO(0, params)
129+
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)