Annotation of embedaddon/php/ext/reflection/tests/static_properties_002.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Reflection and inheriting static properties
! 3: --FILE--
! 4: <?php
! 5:
! 6: class base {
! 7: static protected $prop = 2;
! 8:
! 9: static function show() {
! 10: echo __METHOD__ . '(' . self::$prop . ")\n";
! 11: }
! 12:
! 13: static function inc() {
! 14: base::$prop++;
! 15: echo __METHOD__ . "()\n";
! 16: }
! 17: }
! 18:
! 19: class derived extends base {
! 20: static public $prop = 2;
! 21:
! 22: static function show() {
! 23: echo __METHOD__ . '(' . self::$prop . ")\n";
! 24: }
! 25:
! 26: static function inc() {
! 27: derived::$prop++;
! 28: echo __METHOD__ . "()\n";
! 29: }
! 30: }
! 31:
! 32: base::show();
! 33: derived::show();
! 34:
! 35: base::inc();
! 36:
! 37: base::show();
! 38: derived::show();
! 39:
! 40: derived::inc();
! 41:
! 42: base::show();
! 43: derived::show();
! 44:
! 45: $r = new ReflectionClass('derived');
! 46: echo 'Number of properties: '. count($r->getStaticProperties()) . "\n";
! 47:
! 48: echo "Done\n";
! 49: ?>
! 50: --EXPECTF--
! 51: base::show(2)
! 52: derived::show(2)
! 53: base::inc()
! 54: base::show(3)
! 55: derived::show(2)
! 56: derived::inc()
! 57: base::show(3)
! 58: derived::show(3)
! 59: Number of properties: 1
! 60: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>