PHP | ReflectionClass getTraitNames() Function Last Updated : 09 Apr, 2021 Comments Improve Suggest changes Like Article Like Report The ReflectionClass::getTraitNames() function is an inbuilt function in PHP which is used to return an array of name of traits used by the user-defined class. Syntax: array ReflectionClass::getTraitNames( void ) Parameters: This function does not accept any parameters. Return Value: This function returns an array of name of traits used by the user-defined class. Below programs illustrate the ReflectionClass::getTraitNames() function in PHP: Program 1: php <?php // Defining a trait class trait Company { public function GeeksforGeeks() { } } // Defining a user-defined class Department class Department{ use Company { } } // Using ReflectionClass over the // user-defined class Department $obj=new ReflectionClass('Department'); // Calling the getTraitNames() function $A = $obj->getTraitNames(); // Getting an array of names the traits var_dump($A); ?> Output: array(1) { [0]=> string(7) "Company" } Program 2: php <?php // Defining a user-defined class Department class Department{ } // Using ReflectionClass over the // user-defined class Department $obj=new ReflectionClass('Department'); // Calling the getTraitNames() function and // getting an array of name of the traits var_dump($obj->getTraitNames()); ?> Output: array(0) { } Reference: https://secure.php.net/manual/en/reflectionclass.gettraitnames.php Comment More infoAdvertise with us Next Article PHP | ReflectionClass getTraitNames() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- ReflectionClass PHP- Reflection +1 More Similar Reads PHP | ReflectionClass getTraitAliases() Function The ReflectionClass::getTraitAliases() function is an inbuilt function in PHP which is used to return an array of trait aliases used by the user-defined class.Syntax: array ReflectionClass::getTraitAliases( void ) Parameters: This function does not accept any parameters.Return Value: This function r 1 min read PHP | ReflectionClass getInterfaceNames() Function The ReflectionClass::getInterfaceNames() function is an inbuilt function in PHP which is used to return an array of interface names as values. Syntax: array ReflectionClass::getInterfaceNames( void ) Parameters: This function does not accept any parameters. Return Value: This function returns an arr 1 min read PHP | ReflectionClass getFileName() Function The ReflectionClass::getFileName() function is an inbuilt function in PHP which is used to return the filename of the file in which the class has been defined or returns false if the file is not found. Syntax: string ReflectionClass::getFileName( void ) Parameters: This function does not accept any 1 min read PHP | ReflectionClass getStartLine() Function The ReflectionClass::getStartLine() function is an inbuilt function in PHP which is used to return the line number from where the user defined class get started. Syntax: int ReflectionClass::getStartLine( void ) Parameters: This function does not accept any parameters. Return Value: This function re 1 min read PHP | ReflectionClass getInterfaces() Function The ReflectionClass::getInterfaces() function is an inbuilt function in PHP which is used to return an associative array of interfaces. These returned array is containing keys as interface names and the array values as ReflectionClass objects. Syntax: array ReflectionClass::getInterfaces( void ) Par 2 min read Like