Dutch PHP Conference 2025 - Call For Papers

ReflectionMethod::getDeclaringClass

(PHP 5, PHP 7, PHP 8)

ReflectionMethod::getDeclaringClassGets declaring class for the reflected method

Опис

public ReflectionMethod::getDeclaringClass(): ReflectionClass

Gets the declaring class for the reflected method.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

A ReflectionClass object of the class that the reflected method is part of.

Приклади

Приклад #1 ReflectionMethod::getDeclaringClass() example

<?php
class HelloWorld {

protected function
sayHelloTo($name) {
return
'Hello ' . $name;
}

}

$reflectionMethod = new ReflectionMethod(new HelloWorld(), 'sayHelloTo');
var_dump($reflectionMethod->getDeclaringClass());
?>

Поданий вище приклад виведе:

object(ReflectionClass)#2 (1) {
  ["name"]=>
  string(10) "HelloWorld"
}

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top