PHP 8.6.0 Beta 1 is available for testing

ReflectionParameter::hasType

(PHP 7, PHP 8)

ReflectionParameter::hasTypeVerifica si un parámetro tiene un tipo

Descripción

public function ReflectionParameter::hasType(): bool

Verifica si el parámetro tiene un tipo asociado con este.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

true si se especifica un tipo, false en caso contrario.

Ejemplos

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

Resultado del ejemplo anterior es similar a:

bool(true)
bool(false)

Véase también

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes

There are no user contributed notes for this page.

AltStyle によって変換されたページ (->オリジナル) /