Skip to content

Commit

Permalink
Fixed bug #79740
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jun 26, 2020
1 parent 5435a4a commit c5caa05
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
22 changes: 22 additions & 0 deletions Zend/tests/bug79740.phpt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c5caa05

Please sign in to comment.