(PHP 7, PHP 8)
ReflectionParameter::hasType — 檢查參數是否具有類型
此函式沒有參數。
範例 #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)