php教程

ReflectionParameter::hasType

(PHP 7)

ReflectionParameter::hasTypeChecks if parameter has a type

说明

public ReflectionParameter::hasType ( void ) : bool

Checks if the parameter has a type associated with it.

参数

此函数没有参数。

返回值

TRUE if a type is specified, FALSE otherwise.

范例

Example #1 ReflectionParameter::hasType() example

<?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)

参见

User Contributed Notes

There are no user contributed notes for this page.

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788