ReflectionParameter::getType

(PHP 7)

ReflectionParameter::getType — Gets a parameter's type

Açıklama

public ReflectionParameter::getType ( void ) : ReflectionType

Gets the associated type of a parameter.

Değiştirgeler

Bu işlevin değiştirgesi yoktur.

Dönen Değerler

Returns a ReflectionType object if a parameter type is specified, NULL otherwise.

Örnekler

Örnek 1 ReflectionParameter::getType() example

<?php
function someFunction(int $param, $param2) {}

$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParams = $reflectionFunc->getParameters();
$reflectionType1 = $reflectionParams[0]->getType();
$reflectionType2 = $reflectionParams[1]->getType();

echo 
$reflectionType1;
var_dump($reflectionType2);

Yukarıdaki örnek şuna benzer bir çıktı üretir:

int
null

Ayrıca Bakınız