<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionparameter.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'reflectionparameter.gettype.php',
    1 => 'ReflectionParameter::getType',
    2 => 'Gets a parameter\'s type',
  ),
  'up' => 
  array (
    0 => 'class.reflectionparameter.php',
    1 => 'ReflectionParameter',
  ),
  'prev' => 
  array (
    0 => 'reflectionparameter.getposition.php',
    1 => 'ReflectionParameter::getPosition',
  ),
  'next' => 
  array (
    0 => 'reflectionparameter.hastype.php',
    1 => 'ReflectionParameter::hasType',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/reflection/reflectionparameter/gettype.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionparameter.gettype" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionParameter::getType</h1>
  <p class="verinfo">(PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionParameter::getType</span> &mdash; <span class="dc-title">Gets a parameter&#039;s type</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionparameter.gettype-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionParameter::getType</strong></span>(): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.reflectiontype.php" class="type ReflectionType">ReflectionType</a></span></span></div>

  <p class="para rdfs-comment">
   Gets the associated type of a parameter.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionparameter.gettype-parameters">
  <h3 class="title">Bağımsız Değişkenler</h3>
  <p class="para">Bu işlevin bağımsız değişkeni yoktur.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionparameter.gettype-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
  <p class="para">
   Returns a <span class="classname"><a href="class.reflectiontype.php" class="classname">ReflectionType</a></span> object if a parameter type is
   specified, <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionparameter.gettype-examples">
  <h3 class="title">Örnekler</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Örnek 1 <span class="methodname"><strong>ReflectionParameter::getType()</strong></span> Usage as of PHP 7.1.0</strong></p>
    <div class="example-contents"><p>
     As of PHP 7.1.0, <span class="methodname"><a href="reflectiontype.tostring.php" class="methodname">ReflectionType::__toString()</a></span> is deprecated, and
     <span class="methodname"><strong>ReflectionParameter::getType()</strong></span> <em>may</em> return an
     instance of <span class="classname"><a href="class.reflectionnamedtype.php" class="classname">ReflectionNamedType</a></span>. To get the name of the parameter type,
     <span class="methodname"><strong>ReflectionNamedType()</strong></span> is available in this case.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">someFunction</span><span style="color: #007700">(</span><span style="color: #0000BB">int $param</span><span style="color: #007700">, </span><span style="color: #0000BB">$param2</span><span style="color: #007700">) {}<br /><br /></span><span style="color: #0000BB">$reflectionFunc </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">'someFunction'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$reflectionParams </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflectionFunc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getParameters</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$reflectionType1 </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflectionParams</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">getType</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$reflectionType2 </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflectionParams</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">getType</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">assert</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflectionType1 </span><span style="color: #007700">instanceof </span><span style="color: #0000BB">ReflectionNamedType</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$reflectionType1</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getName</span><span style="color: #007700">(), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflectionType2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>
Yukarıdaki örneğin çıktısı:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">int
NULL</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Örnek 2 <span class="methodname"><strong>ReflectionParameter::getType()</strong></span> Usage before PHP 7.1.0</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">someFunction</span><span style="color: #007700">(</span><span style="color: #0000BB">int $param</span><span style="color: #007700">, </span><span style="color: #0000BB">$param2</span><span style="color: #007700">) {}<br /><br /></span><span style="color: #0000BB">$reflectionFunc </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">'someFunction'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$reflectionParams </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflectionFunc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getParameters</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$reflectionType1 </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflectionParams</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">getType</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$reflectionType2 </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflectionParams</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">getType</span><span style="color: #007700">();<br /><br />echo </span><span style="color: #0000BB">$reflectionType1</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$reflectionType2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>
Yukarıdaki örneğin PHP 7.0 çıktısı:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">int
NULL</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-3">
   <p><strong>Örnek 3 <span class="methodname"><strong>ReflectionParameter::getType()</strong></span> Usage in PHP 8.0.0 and later</strong></p>
    <div class="example-contents"><p>
     As of PHP 8.0.0, this method may return a <span class="classname"><a href="class.reflectionnamedtype.php" class="classname">ReflectionNamedType</a></span> instance or
     a <span class="classname"><a href="class.reflectionuniontype.php" class="classname">ReflectionUnionType</a></span> instance.  The latter is a collection of the former.
     To analyze a type, it is often convenient to normalize it to an array of <span class="classname"><a href="class.reflectionnamedtype.php" class="classname">ReflectionNamedType</a></span>
     objects.  The following function will return an array of <code class="literal">0</code> or more <span class="classname"><a href="class.reflectionnamedtype.php" class="classname">ReflectionNamedType</a></span>
     instances.
    </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">getAllTypes</span><span style="color: #007700">(</span><span style="color: #0000BB">ReflectionParameter $reflectionParameter</span><span style="color: #007700">): array<br />{<br />    </span><span style="color: #0000BB">$reflectionType </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflectionParameter</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getType</span><span style="color: #007700">();<br /><br />    if (!</span><span style="color: #0000BB">$reflectionType</span><span style="color: #007700">) return [];<br /><br />    return </span><span style="color: #0000BB">$reflectionType </span><span style="color: #007700">instanceof </span><span style="color: #0000BB">ReflectionUnionType<br />        </span><span style="color: #007700">? </span><span style="color: #0000BB">$reflectionType</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTypes</span><span style="color: #007700">()<br />        : [</span><span style="color: #0000BB">$reflectionType</span><span style="color: #007700">];<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionparameter.gettype-seealso">
  <h3 class="title">Ayrıca Bakınız</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionparameter.hastype.php" class="methodname" rel="rdfs-seeAlso">ReflectionParameter::hasType()</a> - Checks if parameter has a type</span></li>
    <li><span class="methodname"><a href="reflectiontype.tostring.php" class="methodname" rel="rdfs-seeAlso">ReflectionType::__toString()</a> - To string</span></li>
   </ul>
  </p>
 </div>


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