phpday 2027 - Call for Papers

ReflectionParameter::hasType

(PHP 7, PHP 8)

ReflectionParameter::hasType — Verifica 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

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top