diff options
Diffstat (limited to 'ext/reflection/tests/static_properties_002.phpt')
-rw-r--r-- | ext/reflection/tests/static_properties_002.phpt | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt new file mode 100644 index 0000000..218c629 --- /dev/null +++ b/ext/reflection/tests/static_properties_002.phpt @@ -0,0 +1,60 @@ +--TEST-- +Reflection and inheriting static properties +--FILE-- +<?php + +class base { + static protected $prop = 2; + + static function show() { + echo __METHOD__ . '(' . self::$prop . ")\n"; + } + + static function inc() { + base::$prop++; + echo __METHOD__ . "()\n"; + } +} + +class derived extends base { + static public $prop = 2; + + static function show() { + echo __METHOD__ . '(' . self::$prop . ")\n"; + } + + static function inc() { + derived::$prop++; + echo __METHOD__ . "()\n"; + } +} + +base::show(); +derived::show(); + +base::inc(); + +base::show(); +derived::show(); + +derived::inc(); + +base::show(); +derived::show(); + +$r = new ReflectionClass('derived'); +echo 'Number of properties: '. count($r->getStaticProperties()) . "\n"; + +echo "Done\n"; +?> +--EXPECTF-- +base::show(2) +derived::show(2) +base::inc() +base::show(3) +derived::show(2) +derived::inc() +base::show(3) +derived::show(3) +Number of properties: 1 +Done |