Reflection ReflectionParameter::hasType

(PHP 7, PHP 8)

ReflectionParameter::hasType — 매개변수에 유형이 있는지 확인


설명

public ReflectionParameter::hasType(): bool

매개변수에 연관된 유형이 있는지 확인합니다.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

유형이 지정되면 true, 그렇지 않으면 false입니다.


Examples

예제 #1 ReflectionParameter::hasType() 예제

                  
<?php
function someFunction(string $param, $param2 = null) {}

$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParams = $reflectionFunc->getParameters();

var_dump($reflectionParams[0]->hasType());
var_dump($reflectionParams[1]->hasType());
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

bool(true)
bool(false)
                

기타