Annotation of embedaddon/php/ext/reflection/tests/ReflectionProperty_basic2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test usage of ReflectionProperty methods isDefault(), getModifiers(), getDeclaringClass() and getDocComment().
                      3: --FILE--
                      4: <?php
                      5: 
                      6: function reflectProperty($class, $property) {
                      7:     $propInfo = new ReflectionProperty($class, $property);
                      8:     echo "**********************************\n";
                      9:     echo "Reflecting on property $class::$property\n\n";
                     10:     echo "isDefault():\n";
                     11:     var_dump($propInfo->isDefault());
                     12:     echo "getModifiers():\n";
                     13:     var_dump($propInfo->getModifiers());
                     14:     echo "getDeclaringClass():\n";
                     15:     var_dump($propInfo->getDeclaringClass());
                     16:     echo "getDocComment():\n";
                     17:     var_dump($propInfo->getDocComment());
                     18:     echo "\n**********************************\n";
                     19: }
                     20: 
                     21: class TestClass {
                     22:     public $pub;
                     23:     static public $stat = "static property";
                     24:     /**
                     25:      * This property has a comment.
                     26:      */
                     27:     protected $prot = 4;
                     28:     private $priv = "keepOut";
                     29: }
                     30: 
                     31: reflectProperty("TestClass", "pub");
                     32: reflectProperty("TestClass", "stat");
                     33: reflectProperty("TestClass", "prot");
                     34: reflectProperty("TestClass", "priv");
                     35: 
                     36: ?> 
                     37: --EXPECTF--
                     38: **********************************
                     39: Reflecting on property TestClass::pub
                     40: 
                     41: isDefault():
                     42: bool(true)
                     43: getModifiers():
                     44: int(256)
                     45: getDeclaringClass():
                     46: object(ReflectionClass)#%d (1) {
                     47:   ["name"]=>
                     48:   string(9) "TestClass"
                     49: }
                     50: getDocComment():
                     51: bool(false)
                     52: 
                     53: **********************************
                     54: **********************************
                     55: Reflecting on property TestClass::stat
                     56: 
                     57: isDefault():
                     58: bool(true)
                     59: getModifiers():
                     60: int(257)
                     61: getDeclaringClass():
                     62: object(ReflectionClass)#%d (1) {
                     63:   ["name"]=>
                     64:   string(9) "TestClass"
                     65: }
                     66: getDocComment():
                     67: bool(false)
                     68: 
                     69: **********************************
                     70: **********************************
                     71: Reflecting on property TestClass::prot
                     72: 
                     73: isDefault():
                     74: bool(true)
                     75: getModifiers():
                     76: int(512)
                     77: getDeclaringClass():
                     78: object(ReflectionClass)#%d (1) {
                     79:   ["name"]=>
                     80:   string(9) "TestClass"
                     81: }
                     82: getDocComment():
                     83: string(%d) "/**
                     84:      * This property has a comment.
                     85:      */"
                     86: 
                     87: **********************************
                     88: **********************************
                     89: Reflecting on property TestClass::priv
                     90: 
                     91: isDefault():
                     92: bool(true)
                     93: getModifiers():
                     94: int(1024)
                     95: getDeclaringClass():
                     96: object(ReflectionClass)#%d (1) {
                     97:   ["name"]=>
                     98:   string(9) "TestClass"
                     99: }
                    100: getDocComment():
                    101: bool(false)
                    102: 
                    103: **********************************

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>