--- /dev/null
+--TEST--
+ReflectionClass::export() - various parameters
+--FILE--
+<?php
+Class A {
+ public function privf(Exception $a) {}
+ public function pubf(A $a,
+ $b,
+ C $c = null,
+ $d = K,
+ $e = "15 chars long -",
+ $f = null,
+ $g = false,
+ array $h = null) {}
+}
+
+Class C extends A { }
+
+define('K', "16 chars long --");
+ReflectionClass::export("C");
+?>
+--EXPECTF--
+Class [ <user> class C extends A ] {
+ @@ %s 14-14
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [2] {
+ Method [ <user, inherits A> public method privf ] {
+ @@ %s 3 - 3
+
+ - Parameters [1] {
+ Parameter #0 [ <required> Exception $a ]
+ }
+ }
+
+ Method [ <user, inherits A> public method pubf ] {
+ @@ %s 4 - 11
+
+ - Parameters [8] {
+ Parameter #0 [ <required> A $a ]
+ Parameter #1 [ <required> $b ]
+ Parameter #2 [ <optional> C or NULL $c = NULL ]
+ Parameter #3 [ <optional> $d = '16 chars long -...' ]
+ Parameter #4 [ <optional> $e = '15 chars long -' ]
+ Parameter #5 [ <optional> $f = NULL ]
+ Parameter #6 [ <optional> $g = false ]
+ Parameter #7 [ <optional> array or NULL $h = NULL ]
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionClass::export() - ensure inherited private props are hidden.
+--FILE--
+<?php
+Class c {
+ private $a;
+ static private $b;
+}
+
+class d extends c {}
+
+ReflectionClass::export("c");
+ReflectionClass::export("d");
+?>
+--EXPECTF--
+Class [ <user> class c ] {
+ @@ %s 2-5
+
+ - Constants [0] {
+ }
+
+ - Static properties [1] {
+ Property [ private static $b ]
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [1] {
+ Property [ <default> private $a ]
+ }
+
+ - Methods [0] {
+ }
+}
+
+Class [ <user> class d extends c ] {
+ @@ %s 7-7
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionClass::getExtensionName() method - basic test for getExtensionName() method
+--SKIPIF--
+<?php extension_loaded('reflection') && extension_loaded('dom') or die('skip - reflection or dom extension not loaded'); ?>
+--CREDITS--
+Rein Velt <rein@velt.org>
+#testFest Roosendaal 2008-05-10
+--FILE--
+<?php
+ $rc=new reflectionClass('domDocument');
+ var_dump( $rc->getExtensionName()) ;
+?>
+--EXPECT--
+string(3) "dom"
--- /dev/null
+--TEST--
+ReflectionClass::getExtensionName() method - variation test for getExtensionName()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip - reflection extension not loaded'); ?>
+--CREDITS--
+Rein Velt <rein@velt.org>
+#testFest Roosendaal 2008-05-10
+--FILE--
+<?php
+
+ class myClass
+ {
+ public $varX;
+ public $varY;
+ }
+ $rc=new reflectionClass('myClass');
+ var_dump( $rc->getExtensionName()) ;
+?>
+--EXPECT--
+bool(false)
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionClass::getExtension() method - basic test for getExtension() method
+--SKIPIF--
+<?php extension_loaded('reflection') && extension_loaded('dom') or die('skip - reflection or dom extension not loaded'); ?>
+--CREDITS--
+Rein Velt <rein@velt.org>
+#testFest Roosendaal 2008-05-10
+--FILE--
+<?php
+ $rc=new reflectionClass('domDocument');
+ var_dump($rc->getExtension()) ;
+?>
+--EXPECTF--
+object(ReflectionExtension)#%d (1) {
+ ["name"]=>
+ string(3) "dom"
+}
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionClass::getExtension() method - variation test for getExtension()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip - reflection extension not loaded'); ?>
+--CREDITS--
+Rein Velt <rein@velt.org>
+#testFest Roosendaal 2008-05-10
+--FILE--
+<?php
+
+ class myClass
+ {
+ public $varX;
+ public $varY;
+ }
+ $rc=new reflectionClass('myClass');
+ var_dump( $rc->getExtension()) ;
+?>
+--EXPECT--
+NULL
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionClass::getInterfaceNames()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip - reflection extension not loaded'); ?>
+--CREDITS--
+Michelangelo van Dam <dragonbe@gmail.com>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+interface Foo { }
+
+interface Bar { }
+
+class Baz implements Foo, Bar { }
+
+$rc1 = new ReflectionClass("Baz");
+var_dump($rc1->getInterfaceNames());
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(3) "Foo"
+ [1]=>
+ string(3) "Bar"
+}
--- /dev/null
+--TEST--
+ReflectionClass::getModifiers()
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+--FILE--
+<?php
+
+class a {}
+abstract class b {}
+final class c {}
+interface d {}
+class e implements d {}
+interface f extends d {}
+class g extends b {}
+
+function dump_modifiers($class) {
+ $obj = new ReflectionClass($class);
+ var_dump($obj->getModifiers());
+}
+
+dump_modifiers('a');
+dump_modifiers('b');
+dump_modifiers('c');
+dump_modifiers('d');
+dump_modifiers('e');
+dump_modifiers('f');
+dump_modifiers('g');
+
+?>
+--EXPECT--
+int(0)
+int(32)
+int(64)
+int(128)
+int(0)
+int(128)
+int(0)
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionClass::getParentClass()
+--CREDITS--
+Michelangelo van Dam <dragonbe@gmail.com>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+
+class Foo {}
+
+class Bar extends Foo {}
+
+$rc1 = new ReflectionClass("Bar");
+var_dump($rc1->getParentClass());
+?>
+
+--EXPECTF--
+object(ReflectionClass)#%d (1) {
+ ["name"]=>
+ string(3) "Foo"
+}
--- /dev/null
+--TEST--
+ReflectionClass::hasConstant()
+--CREDIT--
+Marc Veldman <marc@ibuildings.nl>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+//New instance of class C - defined below
+$rc = new ReflectionClass("C");
+
+//Check if C has constant foo
+var_dump($rc->hasConstant('foo'));
+
+//C should not have constant bar
+var_dump($rc->hasConstant('bar'));
+
+Class C {
+ const foo=1;
+}
+?>
+--EXPECTF--
+bool(true)
+bool(false)
--- /dev/null
+--TEST--
+ReflectionClass::hasMethod()
+--CREDIT--
+Marc Veldman <marc@ibuildings.nl>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+//New instance of class C - defined below
+$rc = new ReflectionClass("C");
+
+//Check if C has public method publicFoo
+var_dump($rc->hasMethod('publicFoo'));
+
+//Check if C has protected method protectedFoo
+var_dump($rc->hasMethod('protectedFoo'));
+
+//Check if C has private method privateFoo
+var_dump($rc->hasMethod('privateFoo'));
+
+//Check if C has static method staticFoo
+var_dump($rc->hasMethod('staticFoo'));
+
+//C should not have method bar
+var_dump($rc->hasMethod('bar'));
+
+//Method names are case insensitive
+var_dump($rc->hasMethod('PUBLICfOO'));
+
+Class C {
+ public function publicFoo()
+ {
+ return true;
+ }
+
+ protected function protectedFoo()
+ {
+ return true;
+ }
+
+ private function privateFoo()
+ {
+ return true;
+ }
+
+ static function staticFoo()
+ {
+ return true;
+ }
+}
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(true)
--- /dev/null
+--TEST--
+ReflectionClass::hasProperty()
+--CREDIT--
+Marc Veldman <marc@ibuildings.nl>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+//New instance of class C - defined below
+$rc = new ReflectionClass("C");
+
+//Check if C has public property publicFoo
+var_dump($rc->hasProperty('publicFoo'));
+
+//Check if C has protected property protectedFoo
+var_dump($rc->hasProperty('protectedFoo'));
+
+//Check if C has private property privateFoo
+var_dump($rc->hasProperty('privateFoo'));
+
+//Check if C has static property staticFoo
+var_dump($rc->hasProperty('staticFoo'));
+
+//C should not have property bar
+var_dump($rc->hasProperty('bar'));
+
+Class C {
+ public $publicFoo;
+ protected $protectedFoo;
+ private $privateFoo;
+ public static $staticFoo;
+}
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
--- /dev/null
+--TEST--
+ReflectionClass::isAbstract() method
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip - reflection extension not loaded'); ?>
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+
+class TestClass {}
+abstract class TestAbstractClass {}
+
+$testClass = new ReflectionClass('TestClass');
+$abstractClass = new ReflectionClass('TestAbstractClass');
+
+var_dump($testClass->isAbstract());
+var_dump($abstractClass->isAbstract());
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
--- /dev/null
+--TEST--
+ReflectionClass::isFinal() method
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip - reflection extension not loaded'); ?>
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+
+class TestClass {}
+final class TestFinalClass {}
+
+$normalClass = new ReflectionClass('TestClass');
+$finalClass = new ReflectionClass('TestFinalClass');
+
+var_dump($normalClass->isFinal());
+var_dump($finalClass->isFinal());
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
--- /dev/null
+--TEST--
+ReflectionClass::isInterface() method
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+#testfest roosendaal on 2008-05-10
+--FILE--
+<?php
+
+interface TestInterface {}
+class TestClass {}
+interface DerivedInterface extends TestInterface {}
+
+$reflectionClass = new ReflectionClass('TestInterface');
+$reflectionClass2 = new ReflectionClass('TestClass');
+$reflectionClass3 = new ReflectionClass('DerivedInterface');
+
+var_dump($reflectionClass->isInterface());
+var_dump($reflectionClass2->isInterface());
+var_dump($reflectionClass3->isInterface());
+
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
--- /dev/null
+--TEST--
+ReflectionClass::isIterateable() basic
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>, Marc Veldman <marc@ibuildings.nl>
+--FILE--
+<?php
+
+class IteratorClass implements Iterator {
+ public function __construct() { }
+ public function key() {}
+ public function current() {}
+ function next() {}
+ function valid() {}
+ function rewind() {}
+}
+class DerivedClass extends IteratorClass {}
+class NonIterator {}
+
+function dump_iterateable($class) {
+ $reflection = new ReflectionClass($class);
+ var_dump($reflection->isIterateable());
+}
+
+$classes = array("ArrayObject", "IteratorClass", "DerivedClass", "NonIterator");
+foreach ($classes as $class) {
+ echo "Is $class iterateable? ";
+ dump_iterateable($class);
+}
+?>
+--EXPECT--
+Is ArrayObject iterateable? bool(true)
+Is IteratorClass iterateable? bool(true)
+Is DerivedClass iterateable? bool(true)
+Is NonIterator iterateable? bool(false)
--- /dev/null
+--TEST--
+ReflectionClass::isIterateable() variations
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+--FILE--
+<?php
+
+class BasicClass {}
+
+function dump_iterateable($obj)
+{
+ $reflection = new ReflectionClass($obj);
+ var_dump($reflection->isIterateable());
+}
+
+$basicClass = new BasicClass();
+$stdClass = new StdClass();
+
+dump_iterateable($basicClass);
+dump_iterateable($stdClass);
+
+?>
+--EXPECT--
+bool(false)
+bool(false)
--- /dev/null
+--TEST--
+ReflectionObject::__toString() : very basic test with no dynamic properties
+--FILE--
+<?php
+
+class Foo {
+ public $bar = 1;
+}
+$f = new foo;
+
+echo new ReflectionObject($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+ @@ %s 3-5
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [1] {
+ Property [ <default> public $bar ]
+ }
+
+ - Dynamic properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionObject::__toString() : very basic test with dynamic properties
+--FILE--
+<?php
+
+class Foo {
+ public $bar = 1;
+}
+$f = new foo;
+$f->dynProp = 'hello';
+$f->dynProp2 = 'hello again';
+echo new ReflectionObject($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+ @@ %s 3-5
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [1] {
+ Property [ <default> public $bar ]
+ }
+
+ - Dynamic properties [2] {
+ Property [ <dynamic> public $dynProp ]
+ Property [ <dynamic> public $dynProp2 ]
+ }
+
+ - Methods [0] {
+ }
+}
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionObject::export() : very basic test with no dynamic properties
+--FILE--
+<?php
+
+class Foo {
+ public $bar = 1;
+}
+$f = new foo;
+
+ReflectionObject::export($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+ @@ %s 3-5
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [1] {
+ Property [ <default> public $bar ]
+ }
+
+ - Dynamic properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionObject::export() : very basic test with dynamic properties
+--FILE--
+<?php
+
+class Foo {
+ public $bar = 1;
+}
+$f = new foo;
+$f->dynProp = 'hello';
+$f->dynProp2 = 'hello again';
+ReflectionObject::export($f);
+
+?>
+--EXPECTF--
+Object of class [ <user> class Foo ] {
+ @@ %s 3-5
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [1] {
+ Property [ <default> public $bar ]
+ }
+
+ - Dynamic properties [2] {
+ Property [ <dynamic> public $dynProp ]
+ Property [ <dynamic> public $dynProp2 ]
+ }
+
+ - Methods [0] {
+ }
+}
\ No newline at end of file
--- /dev/null
+--TEST--
+ReflectionObject::export() - ensure dynamic property with same name as inherited private property is shown.
+--FILE--
+<?php
+class C {
+ private $p = 1;
+}
+
+class D extends C{
+}
+
+$Obj = new D;
+$Obj->p = 'value';
+ReflectionObject::export($Obj)
+?>
+--EXPECTF--
+Object of class [ <user> class D extends C ] {
+ @@ %s 6-7
+
+ - Constants [0] {
+ }
+
+ - Static properties [0] {
+ }
+
+ - Static methods [0] {
+ }
+
+ - Properties [0] {
+ }
+
+ - Dynamic properties [0] {
+ }
+
+ - Methods [0] {
+ }
+}
+
--- /dev/null
+--TEST--
+ReflectionProperty::__construct(): ensure inherited private props can't be accessed through ReflectionProperty.
+--FILE--
+<?php
+
+class C {
+ private $p = 1;
+
+ static function testFromC() {
+ try {
+ $rp = new ReflectionProperty("D", "p");
+ var_dump($rp);
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ }
+ }
+}
+
+class D extends C{
+ static function testFromD() {
+ try {
+ $rp = new ReflectionProperty("D", "p");
+ var_dump($rp);
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ }
+ }
+}
+
+echo "--> Reflect inherited private from global scope:\n";
+try {
+ $rp = new ReflectionProperty("D", "p");
+ var_dump($rp);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+
+echo "\n\n--> Reflect inherited private from declaring scope:\n";
+C::testFromC();
+
+echo "\n\n--> Reflect inherited private from declaring scope via subclass:\n";
+D::testFromC();
+
+echo "\n\n--> Reflect inherited private from subclass:\n";
+D::testFromD();
+?>
+--EXPECTF--
+--> Reflect inherited private from global scope:
+Property D::$p does not exist
+
+--> Reflect inherited private from declaring scope:
+Property D::$p does not exist
+
+--> Reflect inherited private from declaring scope via subclass:
+Property D::$p does not exist
+
+--> Reflect inherited private from subclass:
+Property D::$p does not exist
\ No newline at end of file