Skip to content

Commit 2803c8f

Browse files
committed
Add all the missing parameter types to stubs
Closes GH-5955
1 parent f3d6203 commit 2803c8f

32 files changed

+308
-263
lines changed

ext/dom/php_dom.stub.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ public function __construct(string $data = "") {}
1818

1919
interface DOMParentNode
2020
{
21-
/** @var ...DOMNode|string $nodes */
21+
/** @param DOMNode|string $nodes */
2222
public function append(...$nodes): void;
2323

24-
/** @var ...DOMNode|string $nodes */
24+
/** @param DOMNode|string $nodes */
2525
public function prepend(...$nodes): void;
2626
}
2727

2828
interface DOMChildNode
2929
{
3030
public function remove(): void;
3131

32-
/** @var ...DOMNode|string $nodes */
32+
/** @param DOMNode|string $nodes */
3333
public function before(... $nodes): void;
3434

35-
/** @var ...DOMNode|string $nodes */
35+
/** @param DOMNode|string $nodes */
3636
public function after(...$nodes): void;
3737

38-
/** @var ...DOMNode|string $nodes */
38+
/** @param DOMNode|string $nodes */
3939
public function replaceWith(...$nodes): void;
4040
}
4141

@@ -116,10 +116,10 @@ public function __construct() {}
116116
/** @return bool */
117117
public function appendXML(string $data) {}
118118

119-
/** @var ...DOMNode|string $nodes */
119+
/** @param DOMNode|string $nodes */
120120
public function append(...$nodes): void {}
121121

122-
/** @var ...DOMNode|string $nodes */
122+
/** @param DOMNode|string $nodes */
123123
public function prepend(...$nodes): void {}
124124
}
125125

@@ -151,15 +151,15 @@ public function deleteData(int $offset, int $count) {}
151151
/** @return bool */
152152
public function replaceData(int $offset, int $count, string $data) {}
153153

154-
/** @var ...DOMNode|string $nodes */
154+
/** @param DOMNode|string $nodes */
155155
public function replaceWith(...$nodes): void {}
156156

157157
public function remove(): void {}
158158

159-
/** @var ...DOMNode|string $nodes */
159+
/** @param DOMNode|string $nodes */
160160
public function before(... $nodes): void {}
161161

162-
/** @var ...DOMNode|string $nodes */
162+
/** @param DOMNode|string $nodes */
163163
public function after(...$nodes): void {}
164164
}
165165

@@ -231,19 +231,19 @@ public function setIdAttributeNode(DOMAttr $attr, bool $isId) {}
231231

232232
public function remove(): void {}
233233

234-
/** @var ...DOMNode|string $nodes */
234+
/** @param DOMNode|string $nodes */
235235
public function before(... $nodes): void {}
236236

237-
/** @var ...DOMNode|string $nodes */
237+
/** @param DOMNode|string $nodes */
238238
public function after(...$nodes): void {}
239239

240-
/** @var ...DOMNode|string $nodes */
240+
/** @param DOMNode|string $nodes */
241241
public function replaceWith(...$nodes): void {}
242242

243-
/** @var ...DOMNode|string $nodes */
243+
/** @param DOMNode|string $nodes */
244244
public function append(...$nodes): void {}
245245

246-
/** @var ...DOMNode|string $nodes */
246+
/** @param DOMNode|string $nodes */
247247
public function prepend(...$nodes): void {}
248248
}
249249

@@ -348,10 +348,10 @@ public function xinclude(int $options = 0) {}
348348
/** @return DOMNode|false */
349349
public function adoptNode(DOMNode $node) {}
350350

351-
/** @var ...DOMNode|string $nodes */
351+
/** @param DOMNode|string $nodes */
352352
public function append(...$nodes): void {}
353353

354-
/** @var ...DOMNode|string $nodes */
354+
/** @param DOMNode|string $nodes */
355355
public function prepend(...$nodes): void {}
356356
}
357357

ext/dom/php_dom_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 3ecc7d640235675f1f573f043e68f11a4fca0bad */
2+
* Stub hash: 6d25769eb3f8686042dccc55d8d8bd5e3852676f */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
55
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)

ext/ffi/ffi.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,7 @@ ZEND_METHOD(FFI, free) /* {{{ */
37473747
ZEND_METHOD(FFI, cast) /* {{{ */
37483748
{
37493749
zend_string *type_def = NULL;
3750-
zval *ztype = NULL;
3750+
zend_object *ztype = NULL;
37513751
zend_ffi_type *old_type, *type, *type_ptr;
37523752
zend_ffi_cdata *old_cdata, *cdata;
37533753
zend_bool is_const = 0;
@@ -3756,12 +3756,8 @@ ZEND_METHOD(FFI, cast) /* {{{ */
37563756

37573757
ZEND_FFI_VALIDATE_API_RESTRICTION();
37583758
ZEND_PARSE_PARAMETERS_START(2, 2)
3759-
if (Z_TYPE_P(EX_VAR_NUM(0)) == IS_STRING) {
3760-
Z_PARAM_STR(type_def)
3761-
} else {
3762-
Z_PARAM_OBJECT_OF_CLASS(ztype, zend_ffi_ctype_ce)
3763-
}
3764-
Z_PARAM_ZVAL(zv);
3759+
Z_PARAM_STR_OR_OBJ_OF_CLASS(type_def, ztype, zend_ffi_ctype_ce)
3760+
Z_PARAM_ZVAL(zv)
37653761
ZEND_PARSE_PARAMETERS_END();
37663762

37673763
arg = zv;
@@ -3818,7 +3814,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */
38183814

38193815
type_ptr = dcl.type;
38203816
} else {
3821-
zend_ffi_ctype *ctype = (zend_ffi_ctype*)Z_OBJ_P(ztype);
3817+
zend_ffi_ctype *ctype = (zend_ffi_ctype*) ztype;
38223818

38233819
type_ptr = type = ctype->type;
38243820
if (ZEND_FFI_TYPE_IS_OWNED(type)) {

ext/ffi/ffi.stub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public static function new($type, bool $owned = true, bool $persistent = false):
1717
public static function free(FFI\CData $ptr): void {}
1818

1919
/**
20-
* @param FFI\CType|string $type
20+
* @param FFI\CData|string|int|null $ptr
2121
* @prefer-ref $ptr
2222
*/
23-
public static function cast($type, $ptr): ?FFI\CData {}
23+
public static function cast(FFI\CType|string $type, $ptr): ?FFI\CData {}
2424

2525
public static function type(string $type): ?FFI\CType {}
2626

@@ -39,9 +39,9 @@ public static function sizeof(object $ptr): ?int {}
3939
public static function alignof(object $ptr): ?int {}
4040

4141
/**
42+
* @param FFI\CData|string $src
4243
* @prefer-ref $dst
4344
* @prefer-ref $src
44-
* @param string|FFI\CData $dst
4545
*/
4646
public static function memcpy(FFI\CData $dst, $src, int $size): void {}
4747

ext/ffi/ffi_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: e66d306e0dbe08ec3d66935c69ab9e36b9b8165a */
2+
* Stub hash: a486305cd865e2798f7d9916760a3ec3c6f114b0 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"")
@@ -25,7 +25,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_free, 0, 1, IS_VOID, 0
2525
ZEND_END_ARG_INFO()
2626

2727
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cast, 0, 2, FFI\\CData, 1)
28-
ZEND_ARG_INFO(0, type)
28+
ZEND_ARG_OBJ_TYPE_MASK(0, type, FFI\\CType, MAY_BE_STRING, NULL)
2929
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr)
3030
ZEND_END_ARG_INFO()
3131

ext/gd/gd.stub.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ function imagettfbbox(float $size, float $angle, string $font_file, string $text
224224
function imagettftext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text): array|false {}
225225
#endif
226226

227-
function imagefilter(GdImage $im, int $filtertype, $arg1 = UNKNOWN, $arg2 = UNKNOWN, $arg3 = UNKNOWN, $arg4 = UNKNOWN): bool {}
227+
/** @param array|int|float|bool $filter_args */
228+
function imagefilter(GdImage $im, int $filtertype, ...$filter_args): bool {}
228229

229230
function imageconvolution(GdImage $im, array $matrix3x3, float $div, float $offset): bool {}
230231

ext/gd/gd_arginfo.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: a792b0c5497013c85cca83c4baab928a5191f3b9 */
2+
* Stub hash: 540beb37f18b81102e7977447399757e865285c2 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0)
55
ZEND_END_ARG_INFO()
@@ -502,10 +502,7 @@ ZEND_END_ARG_INFO()
502502
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilter, 0, 2, _IS_BOOL, 0)
503503
ZEND_ARG_OBJ_INFO(0, im, GdImage, 0)
504504
ZEND_ARG_TYPE_INFO(0, filtertype, IS_LONG, 0)
505-
ZEND_ARG_INFO(0, arg1)
506-
ZEND_ARG_INFO(0, arg2)
507-
ZEND_ARG_INFO(0, arg3)
508-
ZEND_ARG_INFO(0, arg4)
505+
ZEND_ARG_VARIADIC_INFO(0, filter_args)
509506
ZEND_END_ARG_INFO()
510507

511508
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageconvolution, 0, 4, _IS_BOOL, 0)

ext/pcre/php_pcre.stub.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@
22

33
/** @generate-function-entries */
44

5+
/** @param array $subpatterns */
56
function preg_match(string $pattern, string $subject, &$subpatterns = null, int $flags = 0, int $offset = 0): int|false {}
67

8+
/** @param array $subpatterns */
79
function preg_match_all(string $pattern, string $subject, &$subpatterns = null, int $flags = 0, int $offset = 0): int|false|null {}
810

11+
/** @param int $count */
912
function preg_replace(string|array $regex, string|array $replace, string|array $subject, int $limit = -1, &$count = null): string|array|null {}
1013

14+
/** @param int $count */
1115
function preg_filter(string|array $regex, string|array $replace, string|array $subject, int $limit = -1, &$count = null): string|array|null {}
1216

17+
/** @param int $count */
1318
function preg_replace_callback(string|array $regex, callable $callback, string|array $subject, int $limit = -1, &$count = null, int $flags = 0): string|array|null {}
1419

15-
/** @param string|array $subject */
20+
/**
21+
* @param array|string $subject
22+
* @param int $count
23+
*/
1624
function preg_replace_callback_array(array $pattern, $subject, int $limit = -1, &$count = null, int $flags = 0): string|array|null {}
1725

1826
function preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array|false {}

ext/pcre/php_pcre_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 88e664fe3f4714ab7760a99bffef5c11eafcf0aa */
2+
* Stub hash: 8e8fea5b33408e8a1a39c1b1ae71f16fe1bdd391 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_preg_match, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)

ext/pdo/pdo_stmt.c

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,32 +1435,34 @@ PHP_METHOD(PDOStatement, fetchAll)
14351435
}
14361436
/* }}} */
14371437

1438-
static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) /* {{{ */
1438+
static void register_bound_param(INTERNAL_FUNCTION_PARAMETERS, int is_param) /* {{{ */
14391439
{
14401440
struct pdo_bound_param_data param;
14411441
zend_long param_type = PDO_PARAM_STR;
14421442
zval *parameter, *driver_params = NULL;
14431443

14441444
memset(&param, 0, sizeof(param));
1445-
param.paramno = -1;
1446-
1447-
if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
1448-
"lz|llz!", &param.paramno, &parameter, &param_type, &param.max_value_len,
1449-
&driver_params)) {
1450-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|llz!", &param.name,
1451-
&parameter, &param_type, &param.max_value_len,
1452-
&driver_params)) {
1453-
return 0;
1454-
}
1455-
}
1445+
1446+
ZEND_PARSE_PARAMETERS_START(2, 5)
1447+
Z_PARAM_STR_OR_LONG(param.name, param.paramno)
1448+
Z_PARAM_ZVAL(parameter)
1449+
Z_PARAM_OPTIONAL
1450+
Z_PARAM_LONG(param_type)
1451+
Z_PARAM_LONG(param.max_value_len)
1452+
Z_PARAM_ZVAL_OR_NULL(driver_params)
1453+
ZEND_PARSE_PARAMETERS_END();
1454+
1455+
PHP_STMT_GET_OBJ;
14561456

14571457
param.param_type = (int) param_type;
14581458

1459-
if (param.paramno > 0) {
1459+
if (param.name) {
1460+
param.paramno = -1;
1461+
} else if (param.paramno > 0) {
14601462
--param.paramno; /* make it zero-based internally */
1461-
} else if (!param.name) {
1463+
} else {
14621464
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "Columns/Parameters are 1-based");
1463-
return 0;
1465+
RETURN_FALSE;
14641466
}
14651467

14661468
if (driver_params) {
@@ -1472,9 +1474,11 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt,
14721474
if (!Z_ISUNDEF(param.parameter)) {
14731475
zval_ptr_dtor(&(param.parameter));
14741476
}
1475-
return 0;
1477+
1478+
RETURN_FALSE;
14761479
}
1477-
return 1;
1480+
1481+
RETURN_TRUE;
14781482
} /* }}} */
14791483

14801484
/* {{{ bind an input parameter to the value of a PHP variable. $paramno is the 1-based position of the placeholder in the SQL statement (but can be the parameter name for drivers that support named placeholders). It should be called prior to execute(). */
@@ -1485,22 +1489,22 @@ PHP_METHOD(PDOStatement, bindValue)
14851489
zval *parameter;
14861490

14871491
memset(&param, 0, sizeof(param));
1488-
param.paramno = -1;
14891492

1490-
if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
1491-
"lz|l", &param.paramno, &parameter, &param_type)) {
1492-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|l", &param.name,
1493-
&parameter, &param_type)) {
1494-
return;
1495-
}
1496-
}
1493+
ZEND_PARSE_PARAMETERS_START(2, 3)
1494+
Z_PARAM_STR_OR_LONG(param.name, param.paramno)
1495+
Z_PARAM_ZVAL(parameter)
1496+
Z_PARAM_OPTIONAL
1497+
Z_PARAM_LONG(param_type)
1498+
ZEND_PARSE_PARAMETERS_END();
14971499

14981500
PHP_STMT_GET_OBJ;
14991501
param.param_type = (int) param_type;
15001502

1501-
if (param.paramno > 0) {
1503+
if (param.name) {
1504+
param.paramno = -1;
1505+
} else if (param.paramno > 0) {
15021506
--param.paramno; /* make it zero-based internally */
1503-
} else if (!param.name) {
1507+
} else {
15041508
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "Columns/Parameters are 1-based");
15051509
RETURN_FALSE;
15061510
}
@@ -1520,16 +1524,14 @@ PHP_METHOD(PDOStatement, bindValue)
15201524
/* {{{ bind a parameter to a PHP variable. $paramno is the 1-based position of the placeholder in the SQL statement (but can be the parameter name for drivers that support named placeholders). This isn't supported by all drivers. It should be called prior to execute(). */
15211525
PHP_METHOD(PDOStatement, bindParam)
15221526
{
1523-
PHP_STMT_GET_OBJ;
1524-
RETURN_BOOL(register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, stmt, TRUE));
1527+
register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
15251528
}
15261529
/* }}} */
15271530

15281531
/* {{{ bind a column to a PHP variable. On each row fetch $param will contain the value of the corresponding column. $column is the 1-based offset of the column, or the column name. For portability, don't call this before execute(). */
15291532
PHP_METHOD(PDOStatement, bindColumn)
15301533
{
1531-
PHP_STMT_GET_OBJ;
1532-
RETURN_BOOL(register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, stmt, 0));
1534+
register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
15331535
}
15341536
/* }}} */
15351537

ext/pdo/pdo_stmt.stub.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
class PDOStatement implements IteratorAggregate
66
{
77
/** @return bool */
8-
public function bindColumn(int|string $column, &$param, int $type = 0, int $maxlen = 0, mixed $driverdata = null) {}
8+
public function bindColumn(string|int $column, mixed &$param, int $type = 0, int $maxlen = 0, mixed $driverdata = null) {}
99

1010
/** @return bool */
11-
public function bindParam(int|string $parameter, &$param, int $type = PDO::PARAM_STR, int $maxlen = 0, mixed $driverdata = null) {}
11+
public function bindParam(string|int $parameter, mixed &$param, int $type = PDO::PARAM_STR, int $maxlen = 0, mixed $driverdata = null) {}
1212

13-
/**
14-
* @param int|string $parameter
15-
* @param mixed $value
16-
* @return bool
17-
*/
18-
public function bindValue($parameter, $value, int $type = PDO::PARAM_STR) {}
13+
/** @return bool */
14+
public function bindValue(string|int $parameter, mixed $value, int $type = PDO::PARAM_STR) {}
1915

2016
/** @return bool */
2117
public function closeCursor() {}

0 commit comments

Comments
 (0)