1--TEST-- 2Test get_declared_traits() function : testing autoloaded traits 3--FILE-- 4<?php 5/* Prototype : proto array get_declared_traits() 6 * Description: Returns an array of all declared traits. 7 * Source code: Zend/zend_builtin_functions.c 8 * Alias to functions: 9 */ 10 11 12echo "*** Testing get_declared_traits() : testing autoloaded traits ***\n"; 13 14spl_autoload_register(function ($trait_name) { 15 require_once $trait_name . '.inc'; 16}); 17 18echo "\n-- before instance is declared --\n"; 19var_dump(in_array('AutoTrait', get_declared_traits())); 20 21echo "\n-- after use is declared --\n"; 22 23class MyClass { 24 use AutoTrait; 25} 26 27var_dump(in_array('AutoTrait', get_declared_traits())); 28 29echo "\nDONE\n"; 30 31?> 32--EXPECT-- 33*** Testing get_declared_traits() : testing autoloaded traits *** 34 35-- before instance is declared -- 36bool(false) 37 38-- after use is declared -- 39bool(true) 40 41DONE 42