PHP Conference Fukuoka 2025

ReflectionParameter::isDefaultValueConstant

(PHP 5 >= 5.4.6, PHP 7, PHP 8)

ReflectionParameter::isDefaultValueConstant โ€” Verifica si el valor por defecto del argumento es una constante

Descripciรณn

public ReflectionParameter::isDefaultValueConstant(): bool

Verifica si el valor por defecto del argumento es una constante

Parรกmetros

Esta funciรณn no contiene ningรบn parรกmetro.

Valores devueltos

Devuelve true si el valor por defecto es una constante, false en caso contrario.

Ver tambiรฉn

๏ผ‹add a note

User Contributed Notes 1 note

up
4
kristianoye at gmail dot com ยถ
10 years ago
This method returns true only if the parameter's default value is set to a named constant. e.g.

class Foo {
const OPTION_MULTIGET = 1;

//Method 1
public function setGetOptions($opts=0);

//Method 2
public function setMultiGetOptions($opts=Foo::OPTION_MULTIGET);
}

Method 1's first ReflectionParameter will return isDefaultValueConstant() = false (0 is a "constant"/static value but not a named constant) and Method 2's will return isDefaultValueConsntant() = true.
To Top