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)

锟轿硷拷