ReflectionParameter::hasType

(PHP 7)

ReflectionParameter::hasType — Checks if parameter has a type

Descripción

public ReflectionParameter::hasType ( void ) : bool

Checks if the parameter has a type associated with it.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

TRUE if a type is specified, FALSE otherwise.

Ejemplos

Ejemplo #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());

El resultado del ejemplo sería algo similar a:

bool(true)
bool(false)

Ver también