1--TEST-- 2Test trait_exists() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : proto bool trait_exists(string traitname [, bool autoload]) 6 * Description: Checks if the trait exists 7 * Source code: Zend/zend_builtin_functions.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing trait_exists() : basic functionality ***\n"; 12 13spl_autoload_register(function ($traitName) { 14 echo "In autoload($traitName)\n"; 15}); 16 17trait MyTrait {} 18 19echo "Calling trait_exists() on non-existent trait with autoload explicitly enabled:\n"; 20var_dump( trait_exists('C', true) ); 21echo "\nCalling trait_exists() on existing trait with autoload explicitly enabled:\n"; 22var_dump( trait_exists('MyTrait', true) ); 23 24echo "\nCalling trait_exists() on non-existent trait with autoload explicitly enabled:\n"; 25var_dump( trait_exists('D', false) ); 26echo "\nCalling trait_exists() on existing trait with autoload explicitly disabled:\n"; 27var_dump( trait_exists('MyTrait', false) ); 28 29echo "\nCalling trait_exists() on non-existent trait with autoload unspecified:\n"; 30var_dump( trait_exists('E') ); 31echo "\nCalling trait_exists() on existing trait with autoload unspecified:\n"; 32var_dump( trait_exists('MyTrait') ); 33 34echo "Done"; 35?> 36--EXPECTF-- 37*** Testing trait_exists() : basic functionality *** 38Calling trait_exists() on non-existent trait with autoload explicitly enabled: 39In autoload(C) 40bool(false) 41 42Calling trait_exists() on existing trait with autoload explicitly enabled: 43bool(true) 44 45Calling trait_exists() on non-existent trait with autoload explicitly enabled: 46bool(false) 47 48Calling trait_exists() on existing trait with autoload explicitly disabled: 49bool(true) 50 51Calling trait_exists() on non-existent trait with autoload unspecified: 52In autoload(E) 53bool(false) 54 55Calling trait_exists() on existing trait with autoload unspecified: 56bool(true) 57Done 58