Annotation of embedaddon/php/ext/reflection/tests/bug40431.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Bug #40431 (dynamic properties may cause crash in ReflectionProperty methods)
                      3: --FILE--
                      4: <?php
                      5: 
                      6: echo "=== 1st test ===\n";
1.1.1.2 ! misho       7: $Obj = new stdClass;
1.1       misho       8: $Obj->value = 'value';
                      9: $RefObj = new ReflectionObject($Obj);
                     10: 
                     11: $props = $RefObj->getProperties();
                     12: 
                     13: var_dump($props);
                     14: var_dump($props[0]->isStatic());
                     15: var_dump($props[0]->isPrivate());
                     16: var_dump($props[0]->isPublic());
                     17: var_dump($props[0]->isProtected());
                     18: 
                     19: echo "=== 2nd test ===\n";
                     20: 
                     21: class test1 {
                     22: }
                     23: 
                     24: class test2 extends test1{
                     25: }
                     26: 
                     27: $Obj = new test2;
                     28: $Obj->value = 'value';
                     29: $RefObj = new ReflectionObject($Obj);
                     30: 
                     31: $props = $RefObj->getProperties();
                     32: 
                     33: var_dump($props);
                     34: var_dump($props[0]->isStatic());
                     35: var_dump($props[0]->isPrivate());
                     36: var_dump($props[0]->isPublic());
                     37: var_dump($props[0]->isProtected());
                     38: 
                     39: echo "=== 3rd test ===\n";
                     40: 
                     41: class test3 {
                     42: }
                     43: 
                     44: $Obj = new test3;
                     45: $Obj->value = 'value';
                     46: $RefObj = new ReflectionObject($Obj);
                     47: 
                     48: $props = $RefObj->getProperties();
                     49: 
                     50: var_dump($props);
                     51: var_dump($props[0]->isStatic());
                     52: var_dump($props[0]->isPrivate());
                     53: var_dump($props[0]->isPublic());
                     54: var_dump($props[0]->isProtected());
                     55: 
                     56: echo "=== 4th test ===\n";
                     57: 
                     58: class test5 {
                     59:        private $value = 1;
                     60: }
                     61: 
                     62: class test4 extends test5{
                     63: }
                     64: 
                     65: $Obj = new test4;
                     66: $Obj->value = 'value';
                     67: $RefObj = new ReflectionObject($Obj);
                     68: 
                     69: $props = $RefObj->getProperties();
                     70: 
                     71: var_dump($props);
                     72: var_dump($props[0]->isStatic());
                     73: var_dump($props[0]->isPrivate());
                     74: var_dump($props[0]->isPublic());
                     75: var_dump($props[0]->isProtected());
                     76: 
                     77: echo "Done\n";
                     78: ?>
                     79: --EXPECTF--    
                     80: === 1st test ===
                     81: array(1) {
                     82:   [0]=>
                     83:   &object(ReflectionProperty)#%d (2) {
                     84:     ["name"]=>
                     85:     string(5) "value"
                     86:     ["class"]=>
                     87:     string(8) "stdClass"
                     88:   }
                     89: }
                     90: bool(false)
                     91: bool(false)
                     92: bool(true)
                     93: bool(false)
                     94: === 2nd test ===
                     95: array(1) {
                     96:   [0]=>
                     97:   &object(ReflectionProperty)#%d (2) {
                     98:     ["name"]=>
                     99:     string(5) "value"
                    100:     ["class"]=>
                    101:     string(5) "test2"
                    102:   }
                    103: }
                    104: bool(false)
                    105: bool(false)
                    106: bool(true)
                    107: bool(false)
                    108: === 3rd test ===
                    109: array(1) {
                    110:   [0]=>
                    111:   &object(ReflectionProperty)#%d (2) {
                    112:     ["name"]=>
                    113:     string(5) "value"
                    114:     ["class"]=>
                    115:     string(5) "test3"
                    116:   }
                    117: }
                    118: bool(false)
                    119: bool(false)
                    120: bool(true)
                    121: bool(false)
                    122: === 4th test ===
                    123: array(1) {
                    124:   [0]=>
                    125:   &object(ReflectionProperty)#%d (2) {
                    126:     ["name"]=>
                    127:     string(5) "value"
                    128:     ["class"]=>
                    129:     string(5) "test4"
                    130:   }
                    131: }
                    132: bool(false)
                    133: bool(false)
                    134: bool(true)
                    135: bool(false)
                    136: Done

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