1--TEST-- 2Test get_declared_traits() function : basic functionality 3--FILE-- 4<?php 5echo "*** Testing get_declared_traits() : basic functionality ***\n"; 6 7trait MyTrait {} 8 9// Zero arguments 10echo "\n-- Testing get_declared_traits() function with Zero arguments --\n"; 11var_dump(get_declared_traits()); 12 13foreach (get_declared_traits() as $trait) { 14 if (!trait_exists($trait)) { 15 echo "Error: $trait is not a valid trait.\n"; 16 } 17} 18 19echo "\n-- Ensure trait is listed --\n"; 20var_dump(in_array('MyTrait', get_declared_traits())); 21 22echo "\n-- Ensure userspace interfaces are not listed --\n"; 23interface I {} 24var_dump(in_array( 'I', get_declared_traits())); 25 26echo "\n-- Ensure userspace classes are not listed --\n"; 27class MyClass {} 28var_dump(in_array( 'MyClass', get_declared_traits())); 29 30 31echo "Done"; 32?> 33--EXPECTF-- 34*** Testing get_declared_traits() : basic functionality *** 35 36-- Testing get_declared_traits() function with Zero arguments -- 37array(%d) { 38%a 39} 40 41-- Ensure trait is listed -- 42bool(true) 43 44-- Ensure userspace interfaces are not listed -- 45bool(false) 46 47-- Ensure userspace classes are not listed -- 48bool(false) 49Done 50