PHP | ReflectionGenerator getFunction() Function Last Updated : 17 Dec, 2019 Comments Improve Suggest changes Like Article Like Report The ReflectionGenerator::getFunction() function is an inbuilt function in PHP which is used to return the function name of the specified generator. Syntax: ReflectionFunctionAbstract ReflectionGenerator::getFunction ( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the function name of the specified generator. Below programs illustrate the ReflectionGenerator::getFunction() function in PHP: Program_1: php <?php // Initializing a user-defined class Company class Company { public function GFG() { yield 0; } } // Creating a generator 'A' on the above // class Company $A = (new Company)->GFG(); // Using ReflectionGenerator over the // above generator 'A' $B = new ReflectionGenerator($A); // Calling the getFunction() function $C = $B->getFunction(); // Getting the function name of the // specified generator 'A' var_dump($C); ?> Output: object(ReflectionMethod)#4 (2) { ["name"]=> string(3) "GFG" ["class"]=> string(7) "Company" } Program_2: php <?php // Initializing a user-defined class Departments class Departments { public function Coding_Department() { yield 0; } public function HR_Department() { yield 1; } public function Marketing_Department() { yield 2; } } // Creating some generators on the above // class Departments $A = (new Departments)->Coding_Department(); $B = (new Departments)->HR_Department(); $C = (new Departments)->Marketing_Department(); // Using ReflectionGenerator over the // above generators $D = new ReflectionGenerator($A); $E = new ReflectionGenerator($B); $F = new ReflectionGenerator($C); // Calling the getFunction() function // and getting the function name of the // specified generators var_dump($D->getFunction()); echo "\n"; var_dump($E->getFunction()); echo "\n"; var_dump($F->getFunction()); ?> Output: object(ReflectionMethod)#10 (2) { ["name"]=> string(17) "Coding_Department" ["class"]=> string(11) "Departments" } object(ReflectionMethod)#10 (2) { ["name"]=> string(13) "HR_Department" ["class"]=> string(11) "Departments" } object(ReflectionMethod)#10 (2) { ["name"]=> string(20) "Marketing_Department" ["class"]=> string(11) "Departments" } Reference: https://www.php.net/manual/en/reflectiongenerator.getfunction.php Comment More infoAdvertise with us Next Article PHP | ReflectionGenerator getFunction() Function K Kanchan_Ray Follow Improve Article Tags : Web Technologies PHP PHP-function PHP- Reflection Similar Reads PHP | ReflectionGenerator getThis() Function The ReflectionGenerator::getThis() function is an inbuilt function in PHP which is used to return the $this value of the specified generator. Syntax: object ReflectionGenerator::getThis ( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the $this va 2 min read PHP | ReflectionGenerator getExecutingFile() Function The ReflectionGenerator::getExecutingFile() function is an inbuilt function in PHP which is used to return the full path and file name of the specified currently executing generator. Syntax: string ReflectionGenerator::getExecutingFile( void ) Parameters: This function does not accept any parameters 2 min read PHP | ReflectionGenerator getExecutingLine() Function The ReflectionGenerator::getExecutingLine() function is an inbuilt function in PHP which is used to return the line number of the specified currently executing statement in the generator. Syntax: int ReflectionGenerator::getExecutingLine( void ) Parameters: This function does not accept any paramete 2 min read PHP | ReflectionExtension getFunctions() Function The ReflectionExtension::getFunctions() function is an inbuilt function in PHP which is used to return extension functions from the specified extension. Syntax: array ReflectionExtension::getFunctions( void ) Parameters: This function does not accept any parameter. Return Value: This function return 2 min read PHP | ReflectionGenerator getExecutingGenerator() Function The ReflectionGenerator::getExecutingGenerator() function is an inbuilt function in PHP which is used to return the currently executing Generator object. Syntax: Generator ReflectionGenerator::getExecutingGenerator( void ) Parameters: This function does not accept any parameters. Return Value: This 2 min read PHP | ReflectionParameter getDeclaringFunction() Function The ReflectionParameter::getDeclaringFunction() function is an inbuilt function in PHP which is used to return the declaring function. Syntax: ReflectionFunctionAbstract ReflectionParameter::getDeclaringFunction ( void ) Parameters: This function does not accept any parameter. Return Value: This fun 2 min read PHP | ReflectionParameter getPosition() Function The ReflectionParameter::getPosition() function is an inbuilt function in PHP which is used to return the position of the specified parameter. Syntax: int ReflectionParameter::getPosition( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the positi 1 min read PHP | ReflectionMethod isDestructor() Function The ReflectionMethod::isDestructor() function is an inbuilt function in PHP which is used to return TRUE if the specified method is destructor, otherwise FALSE. Syntax: bool ReflectionMethod::isDestructor( void ) Parameters: This function does not accept any parameters. Return Value: This function r 1 min read PHP | ReflectionParameter getName() Function The ReflectionParameter::getName() function is an inbuilt function in PHP which is used to return the name of the specified parameter. Syntax: string ReflectionParameter::getName ( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the name of the sp 2 min read PHP | ReflectionMethod getClosure() Function The ReflectionMethod::getClosure() function is an inbuilt function in PHP which is used to return a dynamically created closure for the method otherwise, return NULL in case of an error. Syntax: Closure ReflectionMethod::getClosure ( $object ) Parameters: This function accepts a parameter object whi 2 min read Like