diff --git a/Zend/tests/bug61025.phpt b/Zend/tests/bug61025.phpt index 54f6443f85c80..00139e6a9b4da 100644 --- a/Zend/tests/bug61025.phpt +++ b/Zend/tests/bug61025.phpt @@ -20,9 +20,9 @@ echo $b->__invoke(); ?> --EXPECTF-- -Warning: The magic method InvokeAble::__invoke() must have public visibility and cannot be static in %sbug61025.php on line %d +Warning: The magic method InvokeAble::__invoke() cannot be static in %sbug61025.php on line %d -Warning: The magic method Bar::__invoke() must have public visibility and cannot be static in %sbug61025.php on line %d +Warning: The magic method Bar::__invoke() must have public visibility in %sbug61025.php on line %d Bar Fatal error: Uncaught Error: Call to private method Bar::__invoke() from context '' in %sbug61025.php:%d Stack trace: diff --git a/Zend/tests/bug65322.phpt b/Zend/tests/bug65322.phpt index 9b5da8e4b7fa4..0a64783d68e60 100644 --- a/Zend/tests/bug65322.phpt +++ b/Zend/tests/bug65322.phpt @@ -19,6 +19,6 @@ eval('class A { private function __invoke() { } }'); ?> --EXPECTF-- -string(%d) "The magic method A::__invoke() must have public visibility and cannot be static" +string(%d) "The magic method A::__invoke() must have public visibility" string(%d) "%s(%d) : eval()'d code" string(1) "X" diff --git a/Zend/tests/bug67436/bug67436.phpt b/Zend/tests/bug67436/bug67436.phpt index ade29731ae4e4..1ceb83f491515 100644 --- a/Zend/tests/bug67436/bug67436.phpt +++ b/Zend/tests/bug67436/bug67436.phpt @@ -22,6 +22,6 @@ a::staticTest(); $b = new b(); $b->test(); --EXPECTF-- -string(%d) "The magic method b::__invoke() must have public visibility and cannot be static" +string(%d) "The magic method b::__invoke() must have public visibility" b::test() a::test(c::TESTCONSTANT) diff --git a/Zend/tests/bug67436/bug67436_nohandler.phpt b/Zend/tests/bug67436/bug67436_nohandler.phpt index abccfb62f4923..4a34870ebfabe 100644 --- a/Zend/tests/bug67436/bug67436_nohandler.phpt +++ b/Zend/tests/bug67436/bug67436_nohandler.phpt @@ -14,6 +14,6 @@ a::staticTest(); $b = new b(); $b->test(); --EXPECTF-- -Warning: The magic method b::__invoke() must have public visibility and cannot be static in %s on line %d +Warning: The magic method b::__invoke() must have public visibility in %s on line %d b::test() a::test(c::TESTCONSTANT) diff --git a/Zend/tests/bug70215.phpt b/Zend/tests/bug70215.phpt index 76a96722251a0..60fa802a7f972 100644 --- a/Zend/tests/bug70215.phpt +++ b/Zend/tests/bug70215.phpt @@ -17,5 +17,5 @@ $b(); ?> --EXPECTF-- -Warning: The magic method A::__invoke() must have public visibility and cannot be static in %s on line %d +Warning: The magic method A::__invoke() cannot be static in %s on line %d A diff --git a/Zend/tests/errmsg_045.phpt b/Zend/tests/errmsg_045.phpt index 35e6c7b00fef0..4a75cf5df4168 100644 --- a/Zend/tests/errmsg_045.phpt +++ b/Zend/tests/errmsg_045.phpt @@ -14,7 +14,7 @@ eval('class A { private function __invoke() { } }'); ?> --EXPECTF-- -string(%d) "The magic method A::__invoke() must have public visibility and cannot be static" +string(%d) "The magic method A::__invoke() must have public visibility" string(%d) "%s(%d) : eval()'d code" Warning: Undefined variable $undefined in %s on line %d diff --git a/Zend/tests/magic_methods_002.phpt b/Zend/tests/magic_methods_002.phpt index dbd4977ad6fe9..56868013bf3e2 100644 --- a/Zend/tests/magic_methods_002.phpt +++ b/Zend/tests/magic_methods_002.phpt @@ -11,4 +11,4 @@ class foo { ?> --EXPECTF-- -Warning: The magic method foo::__unset() must have public visibility and cannot be static in %s on line %d +Warning: The magic method foo::__unset() must have public visibility in %s on line %d diff --git a/Zend/tests/magic_methods_003.phpt b/Zend/tests/magic_methods_003.phpt index d2207e9db76cf..9f7ff5e9a51c4 100644 --- a/Zend/tests/magic_methods_003.phpt +++ b/Zend/tests/magic_methods_003.phpt @@ -11,4 +11,4 @@ class foo { ?> --EXPECTF-- -Warning: The magic method foo::__unset() must have public visibility and cannot be static in %s on line %d +Warning: The magic method foo::__unset() cannot be static in %s on line %d diff --git a/Zend/tests/magic_methods_004.phpt b/Zend/tests/magic_methods_004.phpt index 695747fdc72bb..b9ad81c6accae 100644 --- a/Zend/tests/magic_methods_004.phpt +++ b/Zend/tests/magic_methods_004.phpt @@ -11,4 +11,4 @@ class foo { ?> --EXPECTF-- -Warning: The magic method foo::__unset() must have public visibility and cannot be static in %s on line %d +Warning: The magic method foo::__unset() must have public visibility in %s on line %d diff --git a/Zend/tests/magic_methods_005.phpt b/Zend/tests/magic_methods_005.phpt index 14704c9229fc8..fe1cfa34e484c 100644 --- a/Zend/tests/magic_methods_005.phpt +++ b/Zend/tests/magic_methods_005.phpt @@ -9,4 +9,4 @@ interface a { ?> --EXPECTF-- -Warning: The magic method a::__call() must have public visibility and cannot be static in %s on line %d +Warning: The magic method a::__call() cannot be static in %s on line %d diff --git a/Zend/tests/magic_methods_006.phpt b/Zend/tests/magic_methods_006.phpt index 92c01636ce162..00fe599fc7182 100644 --- a/Zend/tests/magic_methods_006.phpt +++ b/Zend/tests/magic_methods_006.phpt @@ -9,4 +9,4 @@ interface a { ?> --EXPECTF-- -Warning: The magic method a::__callStatic() must have public visibility and be static in %s on line %d +Warning: The magic method a::__callStatic() must be static in %s on line %d diff --git a/Zend/tests/magic_methods_007.phpt b/Zend/tests/magic_methods_007.phpt index dd7714e5df1d0..86642b4ecb724 100644 --- a/Zend/tests/magic_methods_007.phpt +++ b/Zend/tests/magic_methods_007.phpt @@ -9,6 +9,6 @@ abstract class b { ?> --EXPECTF-- -Warning: The magic method b::__set() must have public visibility and cannot be static in %s on line %d +Warning: The magic method b::__set() must have public visibility in %s on line %d Fatal error: Method b::__set() must take exactly 2 arguments in %s on line %d diff --git a/Zend/tests/magic_methods_008.phpt b/Zend/tests/magic_methods_008.phpt index de99ecafd9e3d..3ddeb61d24e4d 100644 --- a/Zend/tests/magic_methods_008.phpt +++ b/Zend/tests/magic_methods_008.phpt @@ -14,6 +14,6 @@ class a extends b { ?> --EXPECTF-- -Warning: The magic method a::__set() must have public visibility and cannot be static in %s on line %d +Warning: The magic method a::__set() must have public visibility in %s on line %d Fatal error: Access level to a::__set() must be public (as in class b) in %s on line 8 diff --git a/Zend/tests/magic_methods_009.phpt b/Zend/tests/magic_methods_009.phpt index 17a99cef48616..97b54d2412de2 100644 --- a/Zend/tests/magic_methods_009.phpt +++ b/Zend/tests/magic_methods_009.phpt @@ -10,4 +10,4 @@ class a { ?> --EXPECTF-- -Warning: The magic method a::__callStatic() must have public visibility and be static in %s on line %d +Warning: The magic method a::__callStatic() must have public visibility in %s on line %d diff --git a/Zend/tests/magic_methods_010.phpt b/Zend/tests/magic_methods_010.phpt index 4c939d3faa192..b93d6e19f170e 100644 --- a/Zend/tests/magic_methods_010.phpt +++ b/Zend/tests/magic_methods_010.phpt @@ -10,6 +10,8 @@ class a { ?> --EXPECTF-- -Warning: The magic method a::__toString() must have public visibility and cannot be static in %s on line %d +Warning: The magic method a::__toString() must have public visibility in %s on line %d + +Warning: The magic method a::__toString() cannot be static in %s on line %d Fatal error: Method a::__toString() cannot take arguments in %s on line %d diff --git a/Zend/tests/magic_methods_serialize.phpt b/Zend/tests/magic_methods_serialize.phpt index 978aff8b4f76c..e3d20974c6f46 100644 --- a/Zend/tests/magic_methods_serialize.phpt +++ b/Zend/tests/magic_methods_serialize.phpt @@ -7,6 +7,6 @@ class Foo { } ?> --EXPECTF-- -Warning: The magic method Foo::__serialize() must have public visibility and cannot be static in %s on line %d +Warning: The magic method Foo::__serialize() cannot be static in %s on line %d Fatal error: Method Foo::__serialize() cannot take arguments in %s on line %d diff --git a/Zend/tests/magic_methods_unserialize.phpt b/Zend/tests/magic_methods_unserialize.phpt index dc6aa171a7b45..757cb6bf98aab 100644 --- a/Zend/tests/magic_methods_unserialize.phpt +++ b/Zend/tests/magic_methods_unserialize.phpt @@ -7,6 +7,6 @@ class Foo { } ?> --EXPECTF-- -Warning: The magic method Foo::__unserialize() must have public visibility and cannot be static in %s on line %d +Warning: The magic method Foo::__unserialize() cannot be static in %s on line %d Fatal error: Method Foo::__unserialize() must take exactly 1 argument in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 472a402fe6b72..fcbcb9ddb07be 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6052,15 +6052,21 @@ static void zend_compile_implicit_closure_uses(closure_info *info) static void zend_check_magic_method_attr(uint32_t attr, zend_class_entry *ce, const char* method, zend_bool is_static) /* {{{ */ { + if (!(attr & ZEND_ACC_PUBLIC)) { + zend_error(E_WARNING, + "The magic method %s::%s() must have public visibility", + ZSTR_VAL(ce->name), method); + } + if (is_static) { - if (!(attr & ZEND_ACC_PUBLIC) || !(attr & ZEND_ACC_STATIC)) { + if (!(attr & ZEND_ACC_STATIC)) { zend_error(E_WARNING, - "The magic method %s::%s() must have public visibility and be static", + "The magic method %s::%s() must be static", ZSTR_VAL(ce->name), method); } - } else if (!(attr & ZEND_ACC_PUBLIC) || (attr & ZEND_ACC_STATIC)) { + } else if (attr & ZEND_ACC_STATIC) { zend_error(E_WARNING, - "The magic method %s::%s() must have public visibility and cannot be static", + "The magic method %s::%s() cannot be static", ZSTR_VAL(ce->name), method); } } diff --git a/tests/classes/__call_005.phpt b/tests/classes/__call_005.phpt index 8db8cec43e3dd..20416edb5d05a 100644 --- a/tests/classes/__call_005.phpt +++ b/tests/classes/__call_005.phpt @@ -22,7 +22,7 @@ $b = new B(); $b->test(); ?> --EXPECTF-- -Warning: The magic method A::__call() must have public visibility and cannot be static in %s__call_005.php on line 3 +Warning: The magic method A::__call() must have public visibility in %s__call_005.php on line 3 In A::__call(test1, array(1,a)) object(B)#1 (0) { } diff --git a/tests/classes/__call_007.phpt b/tests/classes/__call_007.phpt index 6f90e84f7db62..e2edb8a5304f7 100644 --- a/tests/classes/__call_007.phpt +++ b/tests/classes/__call_007.phpt @@ -51,7 +51,7 @@ try { } ?> --EXPECTF-- -Warning: The magic method A::__call() must have public visibility and cannot be static in %s on line 3 +Warning: The magic method A::__call() cannot be static in %s on line 3 ---> Invoke __call via simple method call. object(A)#1 (0) { }