array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'reflectionparameter.getdeclaringclass.php', 1 => 'ReflectionParameter::getDeclaringClass', ), 'up' => array ( 0 => 'class.reflectionparameter.php', 1 => 'ReflectionParameter', ), 'prev' => array ( 0 => 'reflectionparameter.getclass.php', 1 => 'ReflectionParameter::getClass', ), 'next' => array ( 0 => 'reflectionparameter.getdeclaringfunction.php', 1 => 'ReflectionParameter::getDeclaringFunction', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/reflection/reflectionparameter/getdeclaringclass.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.1.3, PHP 7, PHP 8)
ReflectionParameter::getDeclaringClass — Gets declaring class
Gets the declaring class.
Esta função não possui parâmetros.
A ReflectionClass object or null
if called on function.
Exemplo #1 Getting the class that declared the method
<?php
class Foo
{
public function bar(\DateTime $datetime)
{
}
}
class Baz extends Foo
{
}
$param = new \ReflectionParameter(['Baz', 'bar'], 0);
var_dump($param->getDeclaringClass());
O exemplo acima produzirá:
object(ReflectionClass)#2 (1) { ["name"]=> string(3) "Foo" }