array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'reflectionmethod.getdeclaringclass.php', 1 => 'ReflectionMethod::getDeclaringClass', 2 => 'Gets declaring class for the reflected method', ), 'up' => array ( 0 => 'class.reflectionmethod.php', 1 => 'ReflectionMethod', ), 'prev' => array ( 0 => 'reflectionmethod.getclosure.php', 1 => 'ReflectionMethod::getClosure', ), 'next' => array ( 0 => 'reflectionmethod.getmodifiers.php', 1 => 'ReflectionMethod::getModifiers', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/reflection/reflectionmethod/getdeclaringclass.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5, PHP 7, PHP 8)
ReflectionMethod::getDeclaringClass — Gets declaring class for the reflected method
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" }