Skip to content

Commit 5d4659c

Browse files
committed
Enforce __set_state() parameter type
This fixes one of the issues reported in bug #79925. The parameter type check for this particular method was missed.
1 parent a4c015b commit 5d4659c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Zend/tests/magic_methods_020.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
__set_state first parameter must be an array
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public static function __set_state(int $properties) {}
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Foo::__set_state(): Parameter #1 ($properties) must be of type array when declared in %s on line %d

Zend/zend_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,6 +2187,7 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce,
21872187
zend_check_magic_method_args(1, ce, fptr, error_type);
21882188
zend_check_magic_method_static(ce, fptr, error_type);
21892189
zend_check_magic_method_public(ce, fptr, error_type);
2190+
zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_ARRAY);
21902191
zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_OBJECT);
21912192
} else if (zend_string_equals_literal(lcname, "__invoke")) {
21922193
zend_check_magic_method_non_static(ce, fptr, error_type);

0 commit comments

Comments
 (0)