]> granicus.if.org Git - php/commitdiff
Slipt error messages while checking magic methods attributes
authorGabriel Caruso <carusogabriel34@gmail.com>
Sun, 26 Apr 2020 05:34:19 +0000 (07:34 +0200)
committerGabriel Caruso <carusogabriel34@gmail.com>
Mon, 27 Apr 2020 14:32:00 +0000 (16:32 +0200)
Closes GH-5465

20 files changed:
Zend/tests/bug61025.phpt
Zend/tests/bug65322.phpt
Zend/tests/bug67436/bug67436.phpt
Zend/tests/bug67436/bug67436_nohandler.phpt
Zend/tests/bug70215.phpt
Zend/tests/errmsg_045.phpt
Zend/tests/magic_methods_002.phpt
Zend/tests/magic_methods_003.phpt
Zend/tests/magic_methods_004.phpt
Zend/tests/magic_methods_005.phpt
Zend/tests/magic_methods_006.phpt
Zend/tests/magic_methods_007.phpt
Zend/tests/magic_methods_008.phpt
Zend/tests/magic_methods_009.phpt
Zend/tests/magic_methods_010.phpt
Zend/tests/magic_methods_serialize.phpt
Zend/tests/magic_methods_unserialize.phpt
Zend/zend_compile.c
tests/classes/__call_005.phpt
tests/classes/__call_007.phpt

index 54f6443f85c806a9b1cf898f36c3bee28ca5f3ee..00139e6a9b4da83b0ee367842c26166b4516f2cf 100644 (file)
@@ -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:
index 9b5da8e4b7fa499826b82323adf207390d056cdf..0a64783d68e604185e330723ebbd41acead2e1b2 100644 (file)
@@ -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"
index ade29731ae4e48fae792e3f5b13d9506c0574f47..1ceb83f491515469e18040673b6ef3027a70f748 100644 (file)
@@ -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)
index abccfb62f49230df6b419f10a0190515bd156cc0..4a34870ebfabe3600cec045bbf9c01d616f44de0 100644 (file)
@@ -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)
index 76a96722251a059f7a8322109030208810eff21e..60fa802a7f972b2260a97ec97e2c76938b7ea938 100644 (file)
@@ -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
index 35e6c7b00fef0355948b059aeeff065e80455356..4a75cf5df416842a0b49d6ee20b099b05394fe7d 100644 (file)
@@ -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
index dbd4977ad6fe95494d470004425e6881689e2acf..56868013bf3e2887c81767d9093f0dcfddc72825 100644 (file)
@@ -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
index d2207e9db76cf89d284b282559d23c613e170dee..9f7ff5e9a51c478c9b43bbfb844ea99603a3d863 100644 (file)
@@ -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
index 695747fdc72bb0ed563367e21be6679a4cd470a0..b9ad81c6accae179eef0ac19d4a77153fde12a98 100644 (file)
@@ -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
index 14704c9229fc8e67f05a921609cfe912c4e57657..fe1cfa34e484c7a4c2dbe50b2458c48ffedf46b0 100644 (file)
@@ -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
index 92c01636ce162ba1cff346750a4b769a95a1d2b9..00fe599fc7182df4e5213d3c1952375cb0c12c7f 100644 (file)
@@ -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
index dd7714e5df1d0e4c09b82291f990cc48954af458..86642b4ecb7247c84b61355f43568427f09ffc3a 100644 (file)
@@ -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
index de99ecafd9e3dd3a42905d13c7979b7787c1492c..3ddeb61d24e4d024b3f55fab811aded66df132c2 100644 (file)
@@ -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
index 17a99cef48616d60a5bae47029e2aa65fcaed244..97b54d2412de21c8edc044626aad1c6d15bc514a 100644 (file)
@@ -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
index 4c939d3faa1922818b4d0b3619154ab2de1f8858..b93d6e19f170e5459ab6fd1e457248cf629336b5 100644 (file)
@@ -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
index 978aff8b4f76cef6ed393b70806ff8e8274c695e..e3d20974c6f46bb2951c0d4acab0676ba28f89b8 100644 (file)
@@ -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
index dc6aa171a7b458a5849985a7501a6076a9a4f011..757cb6bf98aab1f01a74e5f38e42c87d06073fff 100644 (file)
@@ -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
index bb279d5570b8e99b317275ac51e561969fdfdefa..7c84456a6ff9c57c3fb768b23c8e03d7e380adcb 100644 (file)
@@ -6041,15 +6041,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);
        }
 }
index 8db8cec43e3dd6805788da3e9582d680b6f95e03..20416edb5d05a4bbb2f733253e822f96a401abea 100644 (file)
@@ -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) {
 }
index 6f90e84f7db62911825a3e7651635ed224562e2a..e2edb8a5304f7fce71b33c862869daf7a42b15db 100644 (file)
@@ -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) {
 }