com php-src: Enforce __set_state() parameter type : Zend/tests/magic_methods_020.phpt Zend/zend _API.c

From: Date: Mon, 03 Aug 2020 08:23:06 +0000
Subject: com php-src: Enforce __set_state() parameter type : Zend/tests/magic_methods_020.phpt Zend/zend _API.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112502@lists.php.net to get a copy of this message
Commit: 5d4659c25c1a40fcadd709560d60101ec524f730 Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 3 Aug 2020 10:23:06 +0200 Parents: a4c015b4b272b992379517e3b0e8d5c6c6fb213d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5d4659c25c1a40fcadd709560d60101ec524f730 Log: 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. Bugs: https://bugs..php.net/79925 Changed paths: A Zend/tests/magic_methods_020.phpt M Zend/zend_API.c Diff: 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-- +<?php + +class Foo { + public static function __set_state(int $properties) {} +} + +?> +--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);

« previous php.cvs (#112502) next »