/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/reflection/tests/ReflectionProperty_constructor_variation1.phpt
58 строк
1 KB
Nikita Popov
Reindent phpt files
04 фев 2020, 00:52
04 фев 2020, 00:52
f8d7958
Код
Авторство
О чём код?
--TEST-- ReflectionProperty::__construct(): ensure inherited private props can't be accessed through ReflectionProperty. --FILE-- <?php class C { private $p = 1; static function testFromC() { try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } } } class D extends C{ static function testFromD() { try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } } } echo "--> Reflect inherited private from global scope:\n"; try { $rp = new ReflectionProperty("D", "p"); var_dump($rp); } catch (Exception $e) { echo $e->getMessage(); } echo "\n\n--> Reflect inherited private from declaring scope:\n"; C::testFromC(); echo "\n\n--> Reflect inherited private from declaring scope via subclass:\n"; D::testFromC(); echo "\n\n--> Reflect inherited private from subclass:\n"; D::testFromD(); ?> --EXPECT-- --> Reflect inherited private from global scope: Property D::$p does not exist --> Reflect inherited private from declaring scope: Property D::$p does not exist --> Reflect inherited private from declaring scope via subclass: Property D::$p does not exist --> Reflect inherited private from subclass: Property D::$p does not exist