Skip to content

Commit ee510ee

Browse files
committed
Deprecate partially supported callables
This deprecates all callables that are accepted by call_user_func($callable) but not by $callable(). In particular: "self::method" "parent::method" "static::method" ["self", "method"] ["parent", "method"] ["static", "method"] ["Foo", "Bar::method"] [new Foo, "Bar::method"] RFC: https://wiki.php.net/rfc/deprecate_partially_supported_callables Closes GH-7446.
1 parent 1afe89f commit ee510ee

27 files changed

+247
-30
lines changed

‎UPGRADING‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ PHP 8.2 UPGRADE NOTES
3535
4. Deprecated Functionality
3636
========================================
3737

38+
- Core:
39+
. Callables that are not accepted by the $callable() syntax (but are accepted
40+
by call_user_func) are deprecated. In particular:
41+
42+
"self::method"
43+
"parent::method"
44+
"static::method"
45+
["self", "method"]
46+
["parent", "method"]
47+
["static", "method"]
48+
["Foo", "Bar::method"]
49+
[new Foo, "Bar::method"]
50+
51+
This does not affect normal method callables like "A::method" or
52+
["A", "method"]. A deprecation notice is only emitted on call. Both
53+
is_callable() and the callable type will silently accept these callables
54+
until support for them is removed entirely.
55+
56+
RFC: https://wiki.php.net/rfc/deprecate_partially_supported_callables
57+
3858
========================================
3959
5. Changed Functions
4060
========================================

‎Zend/tests/bug37138.phpt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ st::e ();
1414
st::e2 ();
1515
stch::g ();
1616
?>
17-
--EXPECT--
17+
--EXPECTF--
1818
EHLO
19+
20+
Deprecated: Use of "self" in callables is deprecated in %s on line %d
1921
EHLO
22+
23+
Deprecated: Use of "parent" in callables is deprecated in %s on line %d
2024
EHLO

‎Zend/tests/bug41026.phpt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ try_class::main ();
2020

2121
echo "Done\n";
2222
?>
23-
--EXPECT--
23+
--EXPECTF--
24+
Deprecated: Use of "self" in callables is deprecated in %s on line %d
2425
Done
2526
CHECKPOINT

‎Zend/tests/bug45186.phpt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ try {
3838
}
3939

4040
?>
41-
--EXPECT--
41+
--EXPECTF--
4242
__call:
4343
string(3) "ABC"
4444
__call:
@@ -47,8 +47,12 @@ __call:
4747
string(3) "xyz"
4848
__call:
4949
string(3) "www"
50+
51+
Deprecated: Use of "self" in callables is deprecated in %s on line %d
5052
__call:
5153
string(1) "y"
54+
55+
Deprecated: Use of "self" in callables is deprecated in %s on line %d
5256
__call:
5357
string(1) "y"
5458
ok

‎Zend/tests/bug45186_2.phpt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ try {
3838
}
3939

4040
?>
41-
--EXPECT--
41+
--EXPECTF--
4242
__call:
4343
string(3) "ABC"
4444
__call:
@@ -47,8 +47,12 @@ __call:
4747
string(3) "xyz"
4848
__call:
4949
string(3) "www"
50+
51+
Deprecated: Use of "self" in callables is deprecated in %s on line %d
5052
__call:
5153
string(1) "y"
54+
55+
Deprecated: Use of "self" in callables is deprecated in %s on line %d
5256
__call:
5357
string(1) "y"
5458
ok

‎Zend/tests/bug48770.phpt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ $c = new C;
3030
$c->callFuncInParent('Which function will be called??');
3131

3232
?>
33-
--EXPECT--
33+
--EXPECTF--
34+
Deprecated: Callables of the form ["C", "parent::func"] are deprecated in %s on line %d
3435
B::func called

‎Zend/tests/bug48770_2.phpt‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@ $c = new C;
5353
$c->func('This should work!');
5454

5555
?>
56-
--EXPECT--
56+
--EXPECTF--
57+
Deprecated: Callables of the form ["C", "parent::func2"] are deprecated in %s on line %d
5758
string(27) "B::func2: This should work!"
59+
60+
Deprecated: Callables of the form ["C", "parent::func3"] are deprecated in %s on line %d
5861
string(27) "B::func3: This should work!"
62+
63+
Deprecated: Callables of the form ["C", "parent::func22"] are deprecated in %s on line %d
5964
call_user_func_array(): Argument #1 ($callback) must be a valid callback, cannot access private method B::func22()
65+
66+
Deprecated: Callables of the form ["C", "parent::inexistent"] are deprecated in %s on line %d
6067
call_user_func_array(): Argument #1 ($callback) must be a valid callback, class B does not have a method "inexistent"

‎Zend/tests/bug48770_3.phpt‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ $c = new C;
4444
$c->func('This should work!');
4545

4646
?>
47-
--EXPECT--
47+
--EXPECTF--
48+
Deprecated: Callables of the form ["C", "self::func2"] are deprecated in %s on line %d
4849
string(27) "B::func2: This should work!"
50+
51+
Deprecated: Callables of the form ["C", "self::func3"] are deprecated in %s on line %d
4952
string(27) "B::func3: This should work!"
53+
54+
Deprecated: Callables of the form ["C", "self::inexistent"] are deprecated in %s on line %d
5055
call_user_func_array(): Argument #1 ($callback) must be a valid callback, class C does not have a method "inexistent"

‎Zend/tests/bug66719.phpt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ call_user_func(array(B::class, 'parent::who'));
3434
C::test();
3535

3636
?>
37-
--EXPECT--
37+
--EXPECTF--
3838
string(1) "B"
3939
string(1) "A"
40+
41+
Deprecated: Callables of the form ["B", "parent::who"] are deprecated in %s on line %d
4042
string(1) "A"
4143
string(1) "B"
4244
string(1) "A"
45+
46+
Deprecated: Callables of the form ["B", "parent::who"] are deprecated in %s on line %d
4347
string(1) "A"

‎Zend/tests/bug78770.phpt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ class Test {
1919

2020
?>
2121
===DONE===
22-
--EXPECT--
22+
--EXPECTF--
23+
Deprecated: Use of "self" in callables is deprecated in %s on line %d
2324
===DONE===

0 commit comments

Comments
 (0)