PHP 8.0.0 Beta 4 available for testing

ReflectionParameter::hasType

(PHP 7)

ReflectionParameter::hasTypeChecks if parameter has a type

Descrierea

public ReflectionParameter::hasType ( void ) : bool

Checks if the parameter has a type associated with it.

Parametri

Această funcție nu are parametri.

Valorile întoarse

TRUE if a type is specified, FALSE otherwise.

Exemple

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

Exemplul de mai sus va afișa ceva similar cu:

bool(true)
bool(false)

A se vedea și

add a note add a note

User Contributed Notes

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