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