/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/reflection/tests/ReflectionClass_getProperty_002.phpt
66 строк
2 KB
Nikita Popov
Deprecate passing null to non-nullable arg of internal function
11 фев 2021, 23:46
11 фев 2021, 23:46
b10416a
Код
Авторство
О чём код?
--TEST-- ReflectionClass::getProperty() - error cases --CREDITS-- Robin Fernandes <robinf@php.net> Steve Seear <stevseea@php.net> --FILE-- <?php class C { public $a; } $rc = new ReflectionClass("C"); echo "Check invalid params:\n"; try { var_dump($rc->getProperty()); } catch (TypeError $e) { echo $e->getMessage() . "\n"; } try { var_dump($rc->getProperty("a", "a")); } catch (TypeError $e) { echo $e->getMessage() . "\n"; } try { var_dump($rc->getProperty(null)); } catch (exception $e) { echo $e->getMessage() . "\n"; } try { var_dump($rc->getProperty(1)); } catch (exception $e) { echo $e->getMessage() . "\n"; } try { var_dump($rc->getProperty(1.5)); } catch (exception $e) { echo $e->getMessage() . "\n"; } try { var_dump($rc->getProperty(true)); } catch (exception $e) { echo $e->getMessage() . "\n"; } try { var_dump($rc->getProperty(array(1,2,3))); } catch (TypeError $e) { echo $e->getMessage() . "\n"; } try { var_dump($rc->getProperty(new C)); } catch (TypeError $e) { echo $e->getMessage() . "\n"; } ?> --EXPECTF-- Check invalid params: ReflectionClass::getProperty() expects exactly 1 argument, 0 given ReflectionClass::getProperty() expects exactly 1 argument, 2 given Deprecated: ReflectionClass::getProperty(): Passing null to parameter #1 ($name) of type string is deprecated in %s on line %d Property C::$ does not exist Property C::$1 does not exist Property C::$1.5 does not exist Property C::$1 does not exist ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, array given ReflectionClass::getProperty(): Argument #1 ($name) must be of type string, C given