Skip to content

Commit 8624a93

Browse files
committed
Adapt patch to current master
1 parent 72b2524 commit 8624a93

9 files changed

+425
-194
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
#[Deprecated] attribute
3+
--FILE--
4+
<?php
5+
6+
error_reporting(E_ALL | E_DEPRECATED);
7+
ini_set('display_errors', true);
8+
9+
#[Deprecated]
10+
function test() {
11+
}
12+
13+
#[Deprecated("use test() instead")]
14+
function test2() {
15+
}
16+
17+
class Clazz {
18+
#[Deprecated]
19+
function test() {
20+
}
21+
22+
#[Deprecated("use test() instead")]
23+
function test2() {
24+
}
25+
}
26+
27+
test();
28+
test2();
29+
call_user_func("test");
30+
31+
$cls = new Clazz();
32+
$cls->test();
33+
$cls->test2();
34+
35+
call_user_func([$cls, "test"]);
36+
--EXPECTF--
37+
Deprecated: Function test() is deprecated in %s
38+
39+
Deprecated: Function test2() is deprecated, use test() instead in %s
40+
41+
Deprecated: Function test() is deprecated in %s
42+
43+
Deprecated: Method Clazz::test() is deprecated in %s
44+
45+
Deprecated: Method Clazz::test2() is deprecated, use test() instead in %s
46+
47+
Deprecated: Method Clazz::test() is deprecated in %s
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
#[Deprecated] attribute
3+
--FILE--
4+
<?php
5+
6+
#[Deprecated()]
7+
function test() {
8+
}
9+
10+
#[Deprecated("use test() instead")]
11+
function test2() {
12+
}
13+
14+
$reflection = new ReflectionFunction('test');
15+
var_dump($reflection->getAttributes()[0]->newInstance());
16+
17+
$reflection = new ReflectionFunction('test2');
18+
var_dump($reflection->getAttributes()[0]->newInstance());
19+
20+
--EXPECTF--
21+
object(Deprecated)#3 (1) {
22+
["message"]=>
23+
NULL
24+
}
25+
object(Deprecated)#2 (1) {
26+
["message"]=>
27+
string(18) "use test() instead"
28+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
#[Deprecated] attribute with wrong type
3+
--FILE--
4+
<?php
5+
6+
#[Deprecated(1234)]
7+
function test() {
8+
}
9+
10+
11+
--EXPECTF--
12+
Fatal error: Deprecated::__construct: Argument #1 ($message) must be of type string, int given in %s

0 commit comments

Comments
 (0)