PHP 8.3.7 Released!

ReflectionParameter::hasType

(PHP 7, PHP 8)

ReflectionParameter::hasTypeVerifica se o parâmetro tem um tipo

Descrição

public ReflectionParameter::hasType(): bool

Verifica se o parâmetro possui um tipo associado a ele.

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

true se um tipo for especificado, false caso contrário.

Exemplos

Exemplo #1 Exemplo de 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());

O exemplo acima produzirá algo semelhante a:

bool(true)
bool(false)

Veja Também

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top