Annotation of embedaddon/php/Zend/tests/objects_022.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Testing 'self', 'parent' as type-hint
! 3: --FILE--
! 4: <?php
! 5:
! 6: interface iTest { }
! 7:
! 8: class baz implements iTest {}
! 9:
! 10: class bar { }
! 11:
! 12: class foo extends bar {
! 13: public function testFoo(self $obj) {
! 14: var_dump($obj);
! 15: }
! 16: public function testBar(parent $obj) {
! 17: var_dump($obj);
! 18: }
! 19: public function testBaz(iTest $obj) {
! 20: var_dump($obj);
! 21: }
! 22: }
! 23:
! 24: $foo = new foo;
! 25: $foo->testFoo(new foo);
! 26: $foo->testBar(new bar);
! 27: $foo->testBaz(new baz);
! 28: $foo->testFoo(new stdClass); // Catchable fatal error
! 29:
! 30: ?>
! 31: --EXPECTF--
! 32: object(foo)#%d (0) {
! 33: }
! 34: object(bar)#%d (0) {
! 35: }
! 36: object(baz)#%d (0) {
! 37: }
! 38:
! 39: Catchable fatal error: Argument 1 passed to foo::testFoo() must be an instance of foo, instance of stdClass given, called in %s on line %d and defined in %s on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>