/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/reflection/tests/ReflectionClass_getConstant_basic.phpt
53 строки
2 KB
Daniel Scherzer
[RFC] Deprecate ReflectionClass::getConstant() for missing constants (#19456)
12 авг 2025, 15:50
Не верифицирован
12 авг 2025, 15:50
ffdc104
Код
Авторство
О чём код?
--TEST-- ReflectionClass::getConstant() --FILE-- <?php class C { const a = 'hello from C'; } class D extends C { } class E extends D { } class F extends E { const a = 'hello from F'; } class X { } $classes = array("C", "D", "E", "F", "X"); foreach($classes as $class) { echo "Reflecting on class $class:\n"; $rc = new ReflectionClass($class); var_dump($rc->getConstant('a')); var_dump($rc->getConstant('doesnotexist')); } ?> --EXPECTF-- Reflecting on class C: string(12) "hello from C" Deprecated: ReflectionClass::getConstant() for a non-existent constant is deprecated, use ReflectionClass::hasConstant() to check if the constant exists in %s on line %d bool(false) Reflecting on class D: string(12) "hello from C" Deprecated: ReflectionClass::getConstant() for a non-existent constant is deprecated, use ReflectionClass::hasConstant() to check if the constant exists in %s on line %d bool(false) Reflecting on class E: string(12) "hello from C" Deprecated: ReflectionClass::getConstant() for a non-existent constant is deprecated, use ReflectionClass::hasConstant() to check if the constant exists in %s on line %d bool(false) Reflecting on class F: string(12) "hello from F" Deprecated: ReflectionClass::getConstant() for a non-existent constant is deprecated, use ReflectionClass::hasConstant() to check if the constant exists in %s on line %d bool(false) Reflecting on class X: Deprecated: ReflectionClass::getConstant() for a non-existent constant is deprecated, use ReflectionClass::hasConstant() to check if the constant exists in %s on line %d bool(false) Deprecated: ReflectionClass::getConstant() for a non-existent constant is deprecated, use ReflectionClass::hasConstant() to check if the constant exists in %s on line %d bool(false)