summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Caruso <carusogabriel34@gmail.com>2020-04-26 07:34:19 +0200
committerGabriel Caruso <carusogabriel34@gmail.com>2020-04-27 16:32:00 +0200
commit7ce8c5ad892b8ce65426d7a8a6cf7376d56c98ee (patch)
treed7d9b9aade79f97180c598fbc13b7d4d0ad4aff1
parentf38d6cea420f1ab6975647cfc87292072538629f (diff)
downloadphp-git-7ce8c5ad892b8ce65426d7a8a6cf7376d56c98ee.tar.gz
Slipt error messages while checking magic methods attributes
Closes GH-5465
-rw-r--r--Zend/tests/bug61025.phpt4
-rw-r--r--Zend/tests/bug65322.phpt2
-rw-r--r--Zend/tests/bug67436/bug67436.phpt2
-rw-r--r--Zend/tests/bug67436/bug67436_nohandler.phpt2
-rw-r--r--Zend/tests/bug70215.phpt2
-rw-r--r--Zend/tests/errmsg_045.phpt2
-rw-r--r--Zend/tests/magic_methods_002.phpt2
-rw-r--r--Zend/tests/magic_methods_003.phpt2
-rw-r--r--Zend/tests/magic_methods_004.phpt2
-rw-r--r--Zend/tests/magic_methods_005.phpt2
-rw-r--r--Zend/tests/magic_methods_006.phpt2
-rw-r--r--Zend/tests/magic_methods_007.phpt2
-rw-r--r--Zend/tests/magic_methods_008.phpt2
-rw-r--r--Zend/tests/magic_methods_009.phpt2
-rw-r--r--Zend/tests/magic_methods_010.phpt4
-rw-r--r--Zend/tests/magic_methods_serialize.phpt2
-rw-r--r--Zend/tests/magic_methods_unserialize.phpt2
-rw-r--r--Zend/zend_compile.c14
-rw-r--r--tests/classes/__call_005.phpt2
-rw-r--r--tests/classes/__call_007.phpt2
20 files changed, 32 insertions, 24 deletions
diff --git a/Zend/tests/bug61025.phpt b/Zend/tests/bug61025.phpt
index 54f6443f85..00139e6a9b 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 9b5da8e4b7..0a64783d68 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 ade29731ae..1ceb83f491 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 abccfb62f4..4a34870ebf 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 76a9672225..60fa802a7f 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 35e6c7b00f..4a75cf5df4 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 dbd4977ad6..56868013bf 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 d2207e9db7..9f7ff5e9a5 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 695747fdc7..b9ad81c6ac 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 14704c9229..fe1cfa34e4 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 92c01636ce..00fe599fc7 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 dd7714e5df..86642b4ecb 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 de99ecafd9..3ddeb61d24 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 17a99cef48..97b54d2412 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 4c939d3faa..b93d6e19f1 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 978aff8b4f..e3d20974c6 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 dc6aa171a7..757cb6bf98 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 bb279d5570..7c84456a6f 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -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);
}
}
diff --git a/tests/classes/__call_005.phpt b/tests/classes/__call_005.phpt
index 8db8cec43e..20416edb5d 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 6f90e84f7d..e2edb8a530 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) {
}