Skip to content

Commit 2fafe5f

Browse files
committed
Add test for trait behavior
1 parent 88db98a commit 2fafe5f

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Behavior of static variables in trait methods
3+
--FILE--
4+
<?php
5+
6+
trait T {
7+
public static function counter() {
8+
static $i = 0;
9+
var_dump(++$i);
10+
}
11+
}
12+
13+
class C1 {
14+
use T {
15+
T::counter as counter1;
16+
T::counter as counter2;
17+
}
18+
}
19+
20+
class C2 {
21+
use T;
22+
}
23+
24+
C1::counter();
25+
C1::counter1();
26+
C1::counter2();
27+
C2::counter();
28+
29+
C1::counter();
30+
C1::counter1();
31+
C1::counter2();
32+
C2::counter();
33+
34+
?>
35+
--EXPECT--
36+
int(1)
37+
int(1)
38+
int(1)
39+
int(1)
40+
int(2)
41+
int(2)
42+
int(2)
43+
int(2)

0 commit comments

Comments
 (0)