PHP | ReflectionMethod getDeclaringClass() Function Last Updated : 28 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The ReflectionMethod::getDeclaringClass() function is an inbuilt function in PHP which is utilized to return the name of the declared class. Syntax: ReflectionClass ReflectionMethod::getDeclaringClass ( void ) Parameters: This function does not accepts any parameter. Return Value: This function returns the name of the declared class for the reflected method. Below programs illustrates the ReflectionMethod::getDeclaringClass() function: Program 1: php <?php // Declaring a class class GeeksforGeeks { // Declaring a protected function protected function CSportal($name) { // Displays output return 'Geeks ' . $name; } } // Creating an object of ReflectionMethod $reflectionMethod = new ReflectionMethod(new GeeksforGeeks(), 'CSportal'); // Calling getDeclaringClass function var_dump($reflectionMethod->getDeclaringClass()); ?> Output: object(ReflectionClass)#2 (1) { ["name"]=> string(13) "GeeksforGeeks" } Program 2: php <?php // Declaring a class class NidhiSingh { // Declaring a protected function protected function Author($name) { // Displays output return 'Nidhi ' . $name; } } // Creating an object of ReflectionMethod $reflectionMethod = new ReflectionMethod(new NidhiSingh(), 'Author'); // Calling getDeclaringClass function var_dump($reflectionMethod->getDeclaringClass()); ?> Output: object(ReflectionClass)#2 (1) { ["name"]=> string(10) "NidhiSingh" } Reference: https://www.php.net/manual/en/reflectionmethod.getdeclaringclass.php. Comment More infoAdvertise with us Next Article PHP | ReflectionParameter getDeclaringClass() Function N nidhi1352singh Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | ReflectionParameter getDeclaringClass() Function The ReflectionParameter::getDeclaringClass() function is an inbuilt function in PHP which is used to return the declaring class. Syntax: ReflectionClass ReflectionParameter::getDeclaringClass ( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the de 2 min read PHP | ReflectionProperty getDeclaringClass() Function The ReflectionProperty::getDeclaringClass() function is an inbuilt function in PHP which is used to return the specified declaring classes. Syntax: ReflectionClass ReflectionProperty::getDeclaringClass ( void ) Parameters: This function does not accept any parameter. Return Value: This function retu 2 min read PHP | ReflectionMethod getModifiers() Function The ReflectionMethod::getModifiers() function is an inbuilt function in PHP which is used to return the numeric representation of the method modifiers. Syntax: int ReflectionMethod::getModifiers( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the 1 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 PHP | ReflectionParameter getClass() Function The ReflectionParameter::getClass() function is an inbuilt function in PHP which is used to return the class type hinted for the parameter. Syntax: ReflectionClass ReflectionParameter::getClass ( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the 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 Like