blob: 8205435a5f6c5ccdcb772d1ff813becd877c989c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
--TEST--
Test semi-reserved method and constant names and trait conflict resolution
--FILE--
<?php
trait TraitA
{
public function catch(){ echo __METHOD__, PHP_EOL; }
private function list(){ echo __METHOD__, PHP_EOL; }
}
trait TraitB
{
static $list = ['a' => ['b' => ['c']]];
public static function catch(){ echo __METHOD__, PHP_EOL; }
private static function throw(){ echo __METHOD__, PHP_EOL; }
private static function self(){ echo __METHOD__, PHP_EOL; }
}
trait TraitC
{
public static function exit(){ echo __METHOD__, PHP_EOL; }
protected static function try(){ echo __METHOD__, PHP_EOL; }
}
class Foo
{
use TraitA, TraitB {
TraitA
::
catch insteadof namespace\TraitB;
TraitA::list as public foreach;
TraitB::throw as public;
TraitB::self as public;
}
use TraitC {
try as public attempt;
exit as die;
\TraitC::exit as bye;
namespace\TraitC::exit as byebye;
TraitC
::
exit as farewell;
}
}
(new Foo)->catch();
(new Foo)->foreach();
Foo::throw();
Foo::self();
var_dump(Foo::$list['a']);
Foo::attempt();
Foo::die();
Foo::bye();
Foo::byebye();
Foo::farewell();
echo "\nDone\n";
--EXPECT--
TraitA::catch
TraitA::list
TraitB::throw
TraitB::self
array(1) {
["b"]=>
array(1) {
[0]=>
string(1) "c"
}
}
TraitC::try
TraitC::exit
TraitC::exit
TraitC::exit
TraitC::exit
Done
|