Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Zend/tests/magic_methods_set_state.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Testing __set_state() declaration with wrong modifier
--FILE--
<?php

class Foo {
function __set_state()
{
}
}

?>
--EXPECTF--
Warning: The magic method Foo::__set_state() must be static in %s on line %d
2 changes: 2 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -6170,6 +6170,8 @@ zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string *name,
zend_check_magic_method_attr(fn_flags, ce, "__serialize", 0);
} else if (zend_string_equals_literal(lcname, "__unserialize")) {
zend_check_magic_method_attr(fn_flags, ce, "__unserialize", 0);
} else if (zend_string_equals_literal(lcname, "__set_state")) {
zend_check_magic_method_attr(fn_flags, ce, "__set_state", 1);
}

return lcname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TestClass

public function __wakeup() {}

public function __set_state() {}
public static function __set_state() {}

public function __autoload() {}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ Modifiers for method TestClass::__wakeup():


Modifiers for method TestClass::__set_state():
0x00000001
0x00000011


Modifiers for method TestClass::__autoload():
Expand Down Expand Up @@ -207,7 +207,7 @@ Modifiers for method TestClass::__wakeup():


Modifiers for method TestClass::__set_state():
0x00000001
0x00000011


Modifiers for method TestClass::__autoload():
Expand Down