123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- --TEST--
- ReflectionClass::getProperties()
- --CREDITS--
- Robin Fernandes <robinf@php.net>
- Steve Seear <stevseea@php.net>
- --FILE--
- <?php
- class C {
- public $pub1;
- public $pub2;
- private $priv1;
- private $priv2;
- static public $pubs;
- static public $pubs2;
- static private $privs1;
- static private $privs2;
- }
- $rc = new ReflectionClass("C");
- $StaticFlag = ReflectionProperty::IS_STATIC;
- $pubFlag = ReflectionProperty::IS_PUBLIC;
- $privFlag = ReflectionProperty::IS_PRIVATE;
- echo "No properties:";
- var_dump($rc->getProperties(0));
- echo "Public properties:";
- var_dump($rc->getProperties($pubFlag));
- echo "Private properties:";
- var_dump($rc->getProperties($privFlag));
- echo "Public or static properties:";
- var_dump($rc->getProperties($StaticFlag | $pubFlag));
- echo "Private or static properties:";
- var_dump($rc->getProperties($StaticFlag | $privFlag));
- ?>
- --EXPECTF--
- No properties:array(0) {
- }
- Public properties:array(4) {
- [0]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(4) "pub1"
- ["class"]=>
- string(1) "C"
- }
- [1]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(4) "pub2"
- ["class"]=>
- string(1) "C"
- }
- [2]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(4) "pubs"
- ["class"]=>
- string(1) "C"
- }
- [3]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(5) "pubs2"
- ["class"]=>
- string(1) "C"
- }
- }
- Private properties:array(4) {
- [0]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(5) "priv1"
- ["class"]=>
- string(1) "C"
- }
- [1]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(5) "priv2"
- ["class"]=>
- string(1) "C"
- }
- [2]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(6) "privs1"
- ["class"]=>
- string(1) "C"
- }
- [3]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(6) "privs2"
- ["class"]=>
- string(1) "C"
- }
- }
- Public or static properties:array(6) {
- [0]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(4) "pub1"
- ["class"]=>
- string(1) "C"
- }
- [1]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(4) "pub2"
- ["class"]=>
- string(1) "C"
- }
- [2]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(4) "pubs"
- ["class"]=>
- string(1) "C"
- }
- [3]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(5) "pubs2"
- ["class"]=>
- string(1) "C"
- }
- [4]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(6) "privs1"
- ["class"]=>
- string(1) "C"
- }
- [5]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(6) "privs2"
- ["class"]=>
- string(1) "C"
- }
- }
- Private or static properties:array(6) {
- [0]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(5) "priv1"
- ["class"]=>
- string(1) "C"
- }
- [1]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(5) "priv2"
- ["class"]=>
- string(1) "C"
- }
- [2]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(4) "pubs"
- ["class"]=>
- string(1) "C"
- }
- [3]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(5) "pubs2"
- ["class"]=>
- string(1) "C"
- }
- [4]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(6) "privs1"
- ["class"]=>
- string(1) "C"
- }
- [5]=>
- object(ReflectionProperty)#%d (2) {
- ["name"]=>
- string(6) "privs2"
- ["class"]=>
- string(1) "C"
- }
- }
|