Annotation of embedaddon/php/ext/reflection/tests/ReflectionMethod_invokeArgs_error3.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ReflectionMethod::invokeArgs() further errors
! 3: --FILE--
! 4: <?php
! 5:
! 6: class TestClass {
! 7: public $prop = 2;
! 8:
! 9: public function foo() {
! 10: echo "Called foo(), property = $this->prop\n";
! 11: var_dump($this);
! 12: return "Return Val";
! 13: }
! 14:
! 15: public static function staticMethod() {
! 16: echo "Called staticMethod()\n";
! 17: var_dump($this);
! 18: }
! 19:
! 20: private static function privateMethod() {
! 21: echo "Called privateMethod()\n";
! 22: }
! 23: }
! 24:
! 25: abstract class AbstractClass {
! 26: abstract function foo();
! 27: }
! 28:
! 29: $testClassInstance = new TestClass();
! 30: $testClassInstance->prop = "Hello";
! 31:
! 32: $foo = new ReflectionMethod($testClassInstance, 'foo');
! 33: $staticMethod = new ReflectionMethod('TestClass::staticMethod');
! 34: $privateMethod = new ReflectionMethod("TestClass::privateMethod");
! 35:
! 36: echo "Wrong number of parameters:\n";
! 37: var_dump($foo->invokeArgs());
! 38: var_dump($foo->invokeArgs(true));
! 39:
! 40: echo "\nNon-instance:\n";
! 41: try {
! 42: var_dump($foo->invokeArgs(new stdClass(), array()));
! 43: } catch (ReflectionException $e) {
! 44: var_dump($e->getMessage());
! 45: }
! 46:
! 47: echo "\nNon-object:\n";
! 48: var_dump($foo->invokeArgs(true, array()));
! 49:
! 50: echo "\nStatic method:\n";
! 51:
! 52: var_dump($staticMethod->invokeArgs());
! 53: var_dump($staticMethod->invokeArgs(true));
! 54: var_dump($staticMethod->invokeArgs(true, array()));
! 55: var_dump($staticMethod->invokeArgs(null, array()));
! 56:
! 57: echo "\nPrivate method:\n";
! 58: try {
! 59: var_dump($privateMethod->invokeArgs($testClassInstance, array()));
! 60: } catch (ReflectionException $e) {
! 61: var_dump($e->getMessage());
! 62: }
! 63:
! 64: echo "\nAbstract method:\n";
! 65: $abstractMethod = new ReflectionMethod("AbstractClass::foo");
! 66: try {
! 67: $abstractMethod->invokeArgs($testClassInstance, array());
! 68: } catch (ReflectionException $e) {
! 69: var_dump($e->getMessage());
! 70: }
! 71: try {
! 72: $abstractMethod->invokeArgs(true);
! 73: } catch (ReflectionException $e) {
! 74: var_dump($e->getMessage());
! 75: }
! 76:
! 77: ?>
! 78: --EXPECTF--
! 79: Wrong number of parameters:
! 80:
! 81: Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 0 given in %s on line %d
! 82: NULL
! 83:
! 84: Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
! 85: NULL
! 86:
! 87: Non-instance:
! 88: string(72) "Given object is not an instance of the class this method was declared in"
! 89:
! 90: Non-object:
! 91:
! 92: Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, boolean given in %s on line %d
! 93: NULL
! 94:
! 95: Static method:
! 96:
! 97: Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 0 given in %s on line %d
! 98: NULL
! 99:
! 100: Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
! 101: NULL
! 102:
! 103: Warning: ReflectionMethod::invokeArgs() expects parameter 1 to be object, boolean given in %s on line %d
! 104: NULL
! 105: Called staticMethod()
! 106:
! 107: Notice: Undefined variable: this in %s on line %d
! 108: NULL
! 109: NULL
! 110:
! 111: Private method:
! 112: string(86) "Trying to invoke private method TestClass::privateMethod() from scope ReflectionMethod"
! 113:
! 114: Abstract method:
! 115: string(53) "Trying to invoke abstract method AbstractClass::foo()"
! 116:
! 117: Warning: ReflectionMethod::invokeArgs() expects exactly 2 parameters, 1 given in %s on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>