Skip to content

Commit 73ee69f

Browse files
committed
Add missing argument type information in stubs
1 parent 7a69c5c commit 73ee69f

14 files changed

+43
-36
lines changed

Zend/tests/bug72162.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $var11 = new StdClass();
77
$var16 = error_reporting($var11);
88
?>
99
--EXPECTF--
10-
Fatal error: Uncaught Error: Object of class stdClass could not be converted to string in %s:%d
10+
Fatal error: Uncaught TypeError: error_reporting(): Argument #1 ($new_error_level) must be of type ?int, object given in %s:%d
1111
Stack trace:
1212
#0 %s(%d): error_reporting(Object(stdClass))
1313
#1 {main}

Zend/zend_builtin_functions.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -385,21 +385,17 @@ ZEND_FUNCTION(strncasecmp)
385385
Return the current error_reporting level, and if an argument was passed - change to the new level */
386386
ZEND_FUNCTION(error_reporting)
387387
{
388-
zval *err = NULL;
389388
int old_error_reporting;
389+
zend_long err;
390+
zend_bool err_is_null = 1;
390391

391392
ZEND_PARSE_PARAMETERS_START(0, 1)
392393
Z_PARAM_OPTIONAL
393-
Z_PARAM_ZVAL(err)
394+
Z_PARAM_LONG_OR_NULL(err, err_is_null)
394395
ZEND_PARSE_PARAMETERS_END();
395396

396397
old_error_reporting = EG(error_reporting);
397-
if (ZEND_NUM_ARGS() != 0) {
398-
zend_string *new_val = zval_try_get_string(err);
399-
if (UNEXPECTED(!new_val)) {
400-
RETURN_THROWS();
401-
}
402-
398+
if (!err_is_null) {
403399
do {
404400
zend_ini_entry *p = EG(error_reporting_ini_entry);
405401

@@ -425,12 +421,8 @@ ZEND_FUNCTION(error_reporting)
425421
zend_string_release_ex(p->value, 0);
426422
}
427423

428-
p->value = new_val;
429-
if (Z_TYPE_P(err) == IS_LONG) {
430-
EG(error_reporting) = Z_LVAL_P(err);
431-
} else {
432-
EG(error_reporting) = atoi(ZSTR_VAL(p->value));
433-
}
424+
p->value = zend_long_to_str(err);
425+
EG(error_reporting) = err;
434426
} while (0);
435427
}
436428

@@ -686,7 +678,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /*
686678
} else if (Z_TYPE_P(obj) == IS_OBJECT) {
687679
instance_ce = Z_OBJCE_P(obj);
688680
} else {
689-
RETURN_FALSE;
681+
zend_argument_type_error(1, "must be of type object|string, %s given", zend_zval_type_name(obj));
690682
}
691683

692684
if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) {

Zend/zend_builtin_functions.stub.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ function strcasecmp(string $str1, string $str2): int {}
2020

2121
function strncasecmp(string $str1, string $str2, int $len): int {}
2222

23-
function error_reporting($new_error_level = UNKNOWN): int {}
23+
function error_reporting(?int $new_error_level = null): int {}
2424

25+
/** @param bool|int|float|string|array|resource|object|null $value */
2526
function define(string $constant_name, $value, bool $case_insensitive = false): bool {}
2627

2728
function defined(string $constant_name): bool {}
@@ -32,8 +33,10 @@ function get_called_class(): string {}
3233

3334
function get_parent_class(string|object $object = UNKNOWN): string|false {}
3435

36+
/** @param object|string $object */
3537
function is_subclass_of($object, string $class_name, bool $allow_string = true): bool {}
3638

39+
/** @param object|string $object */
3740
function is_a($object, string $class_name, bool $allow_string = false): bool {}
3841

3942
function get_class_vars(string $class_name): array|false {}

Zend/zend_builtin_functions_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: f81f2b4cf552c4ee8406b91c437797feb1164be0 */
2+
* Stub hash: df21733ba0df6030d08d234f0ce3c84031f3af88 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_version, 0, 0, IS_STRING, 0)
55
ZEND_END_ARG_INFO()
@@ -34,7 +34,7 @@ ZEND_END_ARG_INFO()
3434
#define arginfo_strncasecmp arginfo_strncmp
3535

3636
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_error_reporting, 0, 0, IS_LONG, 0)
37-
ZEND_ARG_INFO(0, new_error_level)
37+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, new_error_level, IS_LONG, 1, "null")
3838
ZEND_END_ARG_INFO()
3939

4040
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_define, 0, 2, _IS_BOOL, 0)

Zend/zend_interfaces.stub.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,30 @@ public function rewind();
3030

3131
interface ArrayAccess
3232
{
33-
/** @return bool */
33+
/**
34+
* @param mixed $offset
35+
* @return bool
36+
*/
3437
public function offsetExists($offset);
3538

36-
/* actually this should be return by ref but atm cannot be */
37-
/** @return mixed */
39+
/**
40+
* Actually this should be return by ref but atm cannot be.
41+
* @param mixed $offset
42+
* @return mixed
43+
*/
3844
public function offsetGet($offset);
3945

40-
/** @return void */
46+
/**
47+
* @param mixed $offset
48+
* @param mixed $value
49+
* @return void
50+
*/
4151
public function offsetSet($offset, $value);
4252

43-
/** @return void */
53+
/**
54+
* @param mixed $offset
55+
* @return void
56+
*/
4457
public function offsetUnset($offset);
4558
}
4659

Zend/zend_interfaces_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: c3b97b8a9c7522fc5b58e63fbf9cd6a801f4bbc2 */
2+
* Stub hash: ae9726d113b996346cf906f7d3e8f43efc91a330 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, 0)
55
ZEND_END_ARG_INFO()

ext/hash/hash.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function hash_hmac_algos(): array {}
3131
function hash_pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0, bool $raw_output = false): string {}
3232

3333
/**
34-
* @param $known_string no type juggling is performed
35-
* @param $user_string no type juggling is performed
34+
* @param string $known_string no type juggling is performed
35+
* @param string $user_string no type juggling is performed
3636
*/
3737
function hash_equals(string $known_string, string $user_string): bool {}
3838

ext/hash/hash_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: d4caa0bf70c25a8436049197e822a6c85e4e4643 */
2+
* Stub hash: 074ac4c7d8bf3fd068456fe0e7577de57dbe0487 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_hash, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)

ext/intl/php_intl.stub.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ function intltz_create_time_zone_id_enumeration(int $zoneType, ?string $region =
366366

367367
function intltz_from_date_time_zone(DateTimeZone $zone): ?IntlTimeZone {}
368368

369+
/** @param bool $isSystemID */
369370
function intltz_get_canonical_id(string $zoneId, &$isSystemID = null): string|false {}
370371

371372
function intltz_get_display_name(IntlTimeZone $tz, bool $isDaylight = false, int $style = IntlTimeZone::DISPLAY_LONG, ?string $locale = null): string|false {}
@@ -414,7 +415,7 @@ function transliterator_list_ids(): array|false {}
414415

415416
function transliterator_create_inverse(Transliterator $orig_trans): ?Transliterator {}
416417

417-
/** @param Transliterator|string */
418+
/** @param Transliterator|string $transliterator */
418419
function transliterator_transliterate($transliterator, string $subject, int $start = 0, int $end = -1): string|false {}
419420

420421
function transliterator_get_error_code(Transliterator $trans): int|false {}

ext/intl/php_intl_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: f5411cdc67ac288183c4210932b222c406bfe254 */
2+
* Stub hash: 290db397461f797572c1cac7c2278df87099476c */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1)
55
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timeZone, "null")

ext/mysqli/mysqli.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ function mysqli_stmt_attr_set(mysqli_stmt $mysql_stmt, int $attr, int $mode_in):
681681

682682
function mysqli_stmt_bind_param(mysqli_stmt $mysql_stmt, string $types, mixed &...$vars): bool {}
683683

684-
/** @param mixed &...$vars */
684+
/** @param mixed $vars */
685685
function mysqli_stmt_bind_result(mysqli_stmt $mysql_stmt, &...$vars): bool {}
686686

687687
function mysqli_stmt_close(mysqli_stmt $mysql_stmt): bool {}

ext/mysqli/mysqli_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: 49567a0e831c0a484aaf2c2d213ad24109f2639b */
2+
* Stub hash: fd71a49c5e3723ec697661bac3e03882d5dbedbb */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING)
55
ZEND_ARG_OBJ_INFO(0, mysql_link, mysqli, 0)

ext/reflection/php_reflection.stub.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,7 @@ class ReflectionParameter implements Reflector
485485
/** @alias ReflectionClass::__clone */
486486
final private function __clone() {}
487487

488-
/**
489-
* @param $function string|array|object
490-
*/
488+
/** @param string|array|object $function */
491489
public function __construct($function, int|string $parameter) {}
492490

493491
public function __toString(): string {}

ext/reflection/php_reflection_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: 2facddef786be36211215451083b610a5d09dec7 */
2+
* Stub hash: 61daf9fa79b5c189de354a0be889ee021de0d6a5 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)

0 commit comments

Comments
 (0)