<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionmethod.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'reflectionmethod.getdeclaringclass.php',
    1 => 'ReflectionMethod::getDeclaringClass',
    2 => '获取被反射的方法所在类的反射实例',
  ),
  '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' => 'zh',
    'path' => 'reference/reflection/reflectionmethod/getdeclaringclass.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionmethod.getdeclaringclass" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionMethod::getDeclaringClass</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionMethod::getDeclaringClass</span> &mdash; <span class="dc-title">获取被反射的方法所在类的反射实例</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionmethod.getdeclaringclass-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionMethod::getDeclaringClass</strong></span>(): <span class="type"><a href="class.reflectionclass.php" class="type ReflectionClass">ReflectionClass</a></span></div>

  <p class="para rdfs-comment">
   获取被反射的方法所在的类的反射实例。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionmethod.getdeclaringclass-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionmethod.getdeclaringclass-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回类的 <span class="classname"><a href="class.reflectionclass.php" class="classname">ReflectionClass</a></span> 反射对象，被反射的方法是这个类的一部分。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionmethod.getdeclaringclass-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="methodname"><strong>ReflectionMethod::getDeclaringClass()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">HelloWorld </span><span style="color: #007700">{<br /><br />    protected function </span><span style="color: #0000BB">sayHelloTo</span><span style="color: #007700">(</span><span style="color: #0000BB">$name</span><span style="color: #007700">) {<br />        return </span><span style="color: #DD0000">'Hello ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$name</span><span style="color: #007700">;<br />    }<br /><br />}<br /><br /></span><span style="color: #0000BB">$reflectionMethod </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionMethod</span><span style="color: #007700">(new </span><span style="color: #0000BB">HelloWorld</span><span style="color: #007700">(), </span><span style="color: #DD0000">'sayHelloTo'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflectionMethod</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getDeclaringClass</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">object(ReflectionClass)#2 (1) {
  [&quot;name&quot;]=&gt;
  string(10) &quot;HelloWorld&quot;
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionmethod.getdeclaringclass-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionmethod.isabstract.php" class="methodname" rel="rdfs-seeAlso">ReflectionMethod::isAbstract()</a> - 判断方法是否是抽象方法</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>