|
| 1 | +--TEST-- |
| 2 | +Deprecation of self/parent/static in callables |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +class A { |
| 7 | + public function foo() {} |
| 8 | +} |
| 9 | +class B extends A { |
| 10 | + public function test() { |
| 11 | + // Different callables using self/parent/static |
| 12 | + echo "Test different callables\n"; |
| 13 | + call_user_func("self::foo"); |
| 14 | + call_user_func("parent::foo"); |
| 15 | + call_user_func("static::foo"); |
| 16 | + call_user_func(["self", "foo"]); |
| 17 | + call_user_func(["parent", "foo"]); |
| 18 | + call_user_func(["static", "foo"]); |
| 19 | + call_user_func(["B", "self::foo"]); |
| 20 | + call_user_func(["B", "parent::foo"]); |
| 21 | + call_user_func(["B", "static::foo"]); |
| 22 | + |
| 23 | + // Also applies to other things performing calls |
| 24 | + echo "Test array_map()\n"; |
| 25 | + array_map("self::foo", [1]); |
| 26 | + |
| 27 | + echo "Test is_callable() -- should be silent\n"; |
| 28 | + var_dump(is_callable("self::foo")); |
| 29 | + |
| 30 | + echo "Test callable type hint -- should be silent\n"; |
| 31 | + $this->callableTypeHint("self::foo"); |
| 32 | + } |
| 33 | + |
| 34 | + public function callableTypeHint(callable $c) {} |
| 35 | +} |
| 36 | + |
| 37 | +$b = new B; |
| 38 | +$b->test(); |
| 39 | + |
| 40 | +?> |
| 41 | +--EXPECTF-- |
| 42 | +Test different callables |
| 43 | + |
| 44 | +Deprecated: Use of "self" in callables is deprecated in %s on line %d |
| 45 | + |
| 46 | +Deprecated: Use of "parent" in callables is deprecated in %s on line %d |
| 47 | + |
| 48 | +Deprecated: Use of "static" in callables is deprecated in %s on line %d |
| 49 | + |
| 50 | +Deprecated: Use of "self" in callables is deprecated in %s on line %d |
| 51 | + |
| 52 | +Deprecated: Use of "parent" in callables is deprecated in %s on line %d |
| 53 | + |
| 54 | +Deprecated: Use of "static" in callables is deprecated in %s on line %d |
| 55 | + |
| 56 | +Deprecated: Use of "self" in callables is deprecated in %s on line %d |
| 57 | + |
| 58 | +Deprecated: Use of "parent" in callables is deprecated in %s on line %d |
| 59 | + |
| 60 | +Deprecated: Use of "static" in callables is deprecated in %s on line %d |
| 61 | +Test array_map() |
| 62 | + |
| 63 | +Deprecated: Use of "self" in callables is deprecated in %s on line %d |
| 64 | +Test is_callable() -- should be silent |
| 65 | +bool(true) |
| 66 | +Test callable type hint -- should be silent |
0 commit comments