Skip to content

Add all the missing parameter types to stubs #5955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions ext/dom/php_dom.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ public function __construct(string $data = "") {}

interface DOMParentNode
{
/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function append(...$nodes): void;

/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function prepend(...$nodes): void;
}

interface DOMChildNode
{
public function remove(): void;

/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function before(... $nodes): void;

/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function after(...$nodes): void;

/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function replaceWith(...$nodes): void;
}

Expand Down Expand Up @@ -116,10 +116,10 @@ public function __construct() {}
/** @return bool */
public function appendXML(string $data) {}

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

/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function prepend(...$nodes): void {}
}

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

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

public function remove(): void {}

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

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

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

public function remove(): void {}

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

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

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

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

/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function prepend(...$nodes): void {}
}

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

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

/** @var ...DOMNode|string $nodes */
/** @param DOMNode|string $nodes */
public function prepend(...$nodes): void {}
}

Expand Down
2 changes: 1 addition & 1 deletion ext/dom/php_dom_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 3ecc7d640235675f1f573f043e68f11a4fca0bad */
* Stub hash: 6d25769eb3f8686042dccc55d8d8bd5e3852676f */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 1)
ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0)
Expand Down
12 changes: 4 additions & 8 deletions ext/ffi/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3747,7 +3747,7 @@ ZEND_METHOD(FFI, free) /* {{{ */
ZEND_METHOD(FFI, cast) /* {{{ */
{
zend_string *type_def = NULL;
zval *ztype = NULL;
zend_object *ztype = NULL;
zend_ffi_type *old_type, *type, *type_ptr;
zend_ffi_cdata *old_cdata, *cdata;
zend_bool is_const = 0;
Expand All @@ -3756,12 +3756,8 @@ ZEND_METHOD(FFI, cast) /* {{{ */

ZEND_FFI_VALIDATE_API_RESTRICTION();
ZEND_PARSE_PARAMETERS_START(2, 2)
if (Z_TYPE_P(EX_VAR_NUM(0)) == IS_STRING) {
Z_PARAM_STR(type_def)
} else {
Z_PARAM_OBJECT_OF_CLASS(ztype, zend_ffi_ctype_ce)
}
Z_PARAM_ZVAL(zv);
Z_PARAM_STR_OR_OBJ_OF_CLASS(type_def, ztype, zend_ffi_ctype_ce)
Z_PARAM_ZVAL(zv)
ZEND_PARSE_PARAMETERS_END();

arg = zv;
Expand Down Expand Up @@ -3818,7 +3814,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */

type_ptr = dcl.type;
} else {
zend_ffi_ctype *ctype = (zend_ffi_ctype*)Z_OBJ_P(ztype);
zend_ffi_ctype *ctype = (zend_ffi_ctype*) ztype;

type_ptr = type = ctype->type;
if (ZEND_FFI_TYPE_IS_OWNED(type)) {
Expand Down
6 changes: 3 additions & 3 deletions ext/ffi/ffi.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public static function new($type, bool $owned = true, bool $persistent = false):
public static function free(FFI\CData $ptr): void {}

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

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

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

/**
* @param FFI\CData|string $src
* @prefer-ref $dst
* @prefer-ref $src
* @param string|FFI\CData $dst
*/
public static function memcpy(FFI\CData $dst, $src, int $size): void {}

Expand Down
4 changes: 2 additions & 2 deletions ext/ffi/ffi_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e66d306e0dbe08ec3d66935c69ab9e36b9b8165a */
* Stub hash: a486305cd865e2798f7d9916760a3ec3c6f114b0 */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"")
Expand All @@ -25,7 +25,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_FFI_free, 0, 1, IS_VOID, 0
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cast, 0, 2, FFI\\CData, 1)
ZEND_ARG_INFO(0, type)
ZEND_ARG_OBJ_TYPE_MASK(0, type, FFI\\CType, MAY_BE_STRING, NULL)
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr)
ZEND_END_ARG_INFO()

Expand Down
3 changes: 2 additions & 1 deletion ext/gd/gd.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ function imagettfbbox(float $size, float $angle, string $font_file, string $text
function imagettftext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text): array|false {}
#endif

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

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

Expand Down
7 changes: 2 additions & 5 deletions ext/gd/gd_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: a792b0c5497013c85cca83c4baab928a5191f3b9 */
* Stub hash: 540beb37f18b81102e7977447399757e865285c2 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -502,10 +502,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilter, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, im, GdImage, 0)
ZEND_ARG_TYPE_INFO(0, filtertype, IS_LONG, 0)
ZEND_ARG_INFO(0, arg1)
ZEND_ARG_INFO(0, arg2)
ZEND_ARG_INFO(0, arg3)
ZEND_ARG_INFO(0, arg4)
ZEND_ARG_VARIADIC_INFO(0, filter_args)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imageconvolution, 0, 4, _IS_BOOL, 0)
Expand Down
10 changes: 9 additions & 1 deletion ext/pcre/php_pcre.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

/** @generate-function-entries */

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

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

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

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

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

/** @param string|array $subject */
/**
* @param array|string $subject
* @param int $count
*/
function preg_replace_callback_array(array $pattern, $subject, int $limit = -1, &$count = null, int $flags = 0): string|array|null {}

function preg_split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array|false {}
Expand Down
2 changes: 1 addition & 1 deletion ext/pcre/php_pcre_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 88e664fe3f4714ab7760a99bffef5c11eafcf0aa */
* Stub hash: 8e8fea5b33408e8a1a39c1b1ae71f16fe1bdd391 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_preg_match, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
Expand Down
64 changes: 33 additions & 31 deletions ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,32 +1435,34 @@ PHP_METHOD(PDOStatement, fetchAll)
}
/* }}} */

static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, int is_param) /* {{{ */
static void register_bound_param(INTERNAL_FUNCTION_PARAMETERS, int is_param) /* {{{ */
{
struct pdo_bound_param_data param;
zend_long param_type = PDO_PARAM_STR;
zval *parameter, *driver_params = NULL;

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

if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
"lz|llz!", &param.paramno, &parameter, &param_type, &param.max_value_len,
&driver_params)) {
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|llz!", &param.name,
&parameter, &param_type, &param.max_value_len,
&driver_params)) {
return 0;
}
}

ZEND_PARSE_PARAMETERS_START(2, 5)
Z_PARAM_STR_OR_LONG(param.name, param.paramno)
Z_PARAM_ZVAL(parameter)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(param_type)
Z_PARAM_LONG(param.max_value_len)
Z_PARAM_ZVAL_OR_NULL(driver_params)
ZEND_PARSE_PARAMETERS_END();

PHP_STMT_GET_OBJ;

param.param_type = (int) param_type;

if (param.paramno > 0) {
if (param.name) {
param.paramno = -1;
} else if (param.paramno > 0) {
--param.paramno; /* make it zero-based internally */
} else if (!param.name) {
} else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "Columns/Parameters are 1-based");
return 0;
RETURN_FALSE;
}

if (driver_params) {
Expand All @@ -1472,9 +1474,11 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt,
if (!Z_ISUNDEF(param.parameter)) {
zval_ptr_dtor(&(param.parameter));
}
return 0;

RETURN_FALSE;
}
return 1;

RETURN_TRUE;
} /* }}} */

/* {{{ 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(). */
Expand All @@ -1485,22 +1489,22 @@ PHP_METHOD(PDOStatement, bindValue)
zval *parameter;

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

if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
"lz|l", &param.paramno, &parameter, &param_type)) {
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|l", &param.name,
&parameter, &param_type)) {
return;
}
}
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR_OR_LONG(param.name, param.paramno)
Z_PARAM_ZVAL(parameter)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(param_type)
ZEND_PARSE_PARAMETERS_END();

PHP_STMT_GET_OBJ;
param.param_type = (int) param_type;

if (param.paramno > 0) {
if (param.name) {
param.paramno = -1;
} else if (param.paramno > 0) {
--param.paramno; /* make it zero-based internally */
} else if (!param.name) {
} else {
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "Columns/Parameters are 1-based");
RETURN_FALSE;
}
Expand All @@ -1520,16 +1524,14 @@ PHP_METHOD(PDOStatement, bindValue)
/* {{{ 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(). */
PHP_METHOD(PDOStatement, bindParam)
{
PHP_STMT_GET_OBJ;
RETURN_BOOL(register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, stmt, TRUE));
register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */

/* {{{ 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(). */
PHP_METHOD(PDOStatement, bindColumn)
{
PHP_STMT_GET_OBJ;
RETURN_BOOL(register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, stmt, 0));
register_bound_param(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */

Expand Down
12 changes: 4 additions & 8 deletions ext/pdo/pdo_stmt.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
class PDOStatement implements IteratorAggregate
{
/** @return bool */
public function bindColumn(int|string $column, &$param, int $type = 0, int $maxlen = 0, mixed $driverdata = null) {}
public function bindColumn(string|int $column, mixed &$param, int $type = 0, int $maxlen = 0, mixed $driverdata = null) {}

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

/**
* @param int|string $parameter
* @param mixed $value
* @return bool
*/
public function bindValue($parameter, $value, int $type = PDO::PARAM_STR) {}
/** @return bool */
public function bindValue(string|int $parameter, mixed $value, int $type = PDO::PARAM_STR) {}

/** @return bool */
public function closeCursor() {}
Expand Down
Loading