diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | Zend/tests/bug79740.phpt | 22 | ||||
-rw-r--r-- | Zend/zend_compile.c | 6 |
3 files changed, 32 insertions, 0 deletions
@@ -6,6 +6,10 @@ PHP NEWS . Fixed bug #79030 (Upgrade apache2handler's php_apache_sapi_get_request_time to return usec). (Herbert256) +- Core: + . Fixed bug #79740 (serialize() and unserialize() methods can not be called + statically). (Nikita) + - FTP: . Fixed bug #55857 (ftp_size on large files). (cmb) diff --git a/Zend/tests/bug79740.phpt b/Zend/tests/bug79740.phpt new file mode 100644 index 0000000000..311bcbcf56 --- /dev/null +++ b/Zend/tests/bug79740.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #79740: serialize() and unserialize() methods can not be called statically +--FILE-- +<?php +class A { + public function serialize() { } + public function unserialize() { } +} + +var_dump(is_callable(['A', 'serialize'])); +var_dump(is_callable(['A', 'unserialize'])); +A::serialize(); +A::unserialize(); + +?> +--EXPECTF-- +bool(true) +bool(true) + +Deprecated: Non-static method A::serialize() should not be called statically in %s on line %d + +Deprecated: Non-static method A::unserialize() should not be called statically in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c498f95347..8b36a0940e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5813,8 +5813,14 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo } } else if (zend_string_equals_literal(lcname, "serialize")) { ce->serialize_func = (zend_function *) op_array; + if (!is_static) { + op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC; + } } else if (zend_string_equals_literal(lcname, "unserialize")) { ce->unserialize_func = (zend_function *) op_array; + if (!is_static) { + op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC; + } } else if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') { if (!is_static) { op_array->fn_flags |= ZEND_ACC_ALLOW_STATIC; |