From: Nikita Popov Date: Mon, 3 Aug 2020 08:23:06 +0000 (+0200) Subject: Enforce __set_state() parameter type X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d4659c25c1a40fcadd709560d60101ec524f730;p=php 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. --- diff --git a/Zend/tests/magic_methods_020.phpt b/Zend/tests/magic_methods_020.phpt new file mode 100644 index 0000000000..45e144cac7 --- /dev/null +++ b/Zend/tests/magic_methods_020.phpt @@ -0,0 +1,12 @@ +--TEST-- +__set_state first parameter must be an array +--FILE-- + +--EXPECTF-- +Fatal error: Foo::__set_state(): Parameter #1 ($properties) must be of type array when declared in %s on line %d diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 1b00e51416..c2f887a5bc 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2187,6 +2187,7 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, zend_check_magic_method_args(1, ce, fptr, error_type); zend_check_magic_method_static(ce, fptr, error_type); zend_check_magic_method_public(ce, fptr, error_type); + zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_ARRAY); zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_OBJECT); } else if (zend_string_equals_literal(lcname, "__invoke")) { zend_check_magic_method_non_static(ce, fptr, error_type);