Skip to content

Commit fbbcf82

Browse files
committed
Unify static/non-static check for magic methods
And promote it to be fatal.
1 parent b466e8b commit fbbcf82

15 files changed

+58
-191
lines changed

Zend/tests/bug61025.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ Bug #61025 (__invoke() visibility not honored)
33
--FILE--
44
<?php
55

6-
Interface InvokeAble {
7-
static function __invoke();
8-
}
9-
106
class Bar {
117
private function __invoke() {
128
return __CLASS__;
@@ -20,8 +16,6 @@ echo $b->__invoke();
2016

2117
?>
2218
--EXPECTF--
23-
Warning: The magic method InvokeAble::__invoke() cannot be static in %sbug61025.php on line %d
24-
2519
Warning: The magic method Bar::__invoke() must have public visibility in %sbug61025.php on line %d
2620
Bar
2721
Fatal error: Uncaught Error: Call to private method Bar::__invoke() from global scope in %s:%d

Zend/tests/bug70215.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ $b();
1717

1818
?>
1919
--EXPECTF--
20-
Warning: The magic method A::__invoke() cannot be static in %s on line %d
21-
A
20+
Fatal error: Method A::__invoke() cannot be static in %s on line %d

Zend/tests/errmsg_032.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class test {
1212
echo "Done\n";
1313
?>
1414
--EXPECTF--
15-
Fatal error: Constructor test::__construct() cannot be static in %s on line %d
15+
Fatal error: Method test::__construct() cannot be static in %s on line %d

Zend/tests/errmsg_033.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class test {
1212
echo "Done\n";
1313
?>
1414
--EXPECTF--
15-
Fatal error: Destructor test::__destruct() cannot be static in %s on line %d
15+
Fatal error: Method test::__destruct() cannot be static in %s on line %d

Zend/tests/errmsg_034.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ class test {
1212
echo "Done\n";
1313
?>
1414
--EXPECTF--
15-
Fatal error: Clone method test::__clone() cannot be static in %s on line %d
15+
Fatal error: Method test::__clone() cannot be static in %s on line %d

Zend/tests/magic_methods_003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class foo {
1111

1212
?>
1313
--EXPECTF--
14-
Warning: The magic method foo::__unset() cannot be static in %s on line %d
14+
Fatal error: Method foo::__unset() cannot be static in %s on line %d

Zend/tests/magic_methods_005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ interface a {
99

1010
?>
1111
--EXPECTF--
12-
Warning: The magic method a::__call() cannot be static in %s on line %d
12+
Fatal error: Method a::__call() cannot be static in %s on line %d

Zend/tests/magic_methods_006.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ interface a {
99

1010
?>
1111
--EXPECTF--
12-
Warning: The magic method a::__callStatic() must be static in %s on line %d
12+
Fatal error: Method a::__callStatic() must be static in %s on line %d

Zend/tests/magic_methods_010.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ class a {
1212
--EXPECTF--
1313
Warning: The magic method a::__toString() must have public visibility in %s on line %d
1414

15-
Warning: The magic method a::__toString() cannot be static in %s on line %d
16-
1715
Fatal error: Method a::__toString() cannot take arguments in %s on line %d

Zend/tests/magic_methods_serialize.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ class Foo {
77
}
88
?>
99
--EXPECTF--
10-
Warning: The magic method Foo::__serialize() cannot be static in %s on line %d
11-
1210
Fatal error: Method Foo::__serialize() cannot take arguments in %s on line %d

0 commit comments

Comments
 (0)