/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/reflection/tests/ReflectionAttribute_constructor_001.phpt
25 строк
492 B
Máté Kocsis
Throw when calling ReflectionAttribute::__construct()
03 май 2022, 22:23
Не верифицирован
03 май 2022, 22:23
fc04a6e
Код
Авторство
О чём код?
--TEST-- ReflectionAttribute cannot be instantiated directly --FILE-- <?php #[Attribute] class A {} class Foo { #[A] public function bar() {} } $rm = new ReflectionMethod(Foo::class, "bar"); $attribute = $rm->getAttributes()[0]; $rm = new ReflectionMethod($attribute, "__construct"); try { var_dump($rm->invoke($attribute, 0, 1, 2)); } catch (ReflectionException $exception) { echo $exception->getMessage(); } ?> --EXPECT-- Cannot directly instantiate ReflectionAttribute