Annotation of embedaddon/php/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ReflectionClass::isIterateable()
! 3: --CREDITS--
! 4: Robin Fernandes <robinf@php.net>
! 5: Steve Seear <stevseea@php.net>
! 6: --FILE--
! 7: <?php
! 8: Interface ExtendsIterator extends Iterator {
! 9: }
! 10: Interface ExtendsIteratorAggregate extends IteratorAggregate {
! 11: }
! 12: Class IteratorImpl implements Iterator {
! 13: public function next() {}
! 14: public function key() {}
! 15: public function rewind() {}
! 16: public function current() {}
! 17: public function valid() {}
! 18: }
! 19: Class IterarorAggregateImpl implements IteratorAggregate {
! 20: public function getIterator() {}
! 21: }
! 22: Class ExtendsIteratorImpl extends IteratorImpl {
! 23: }
! 24: Class ExtendsIteratorAggregateImpl extends IterarorAggregateImpl {
! 25: }
! 26: Class A {
! 27: }
! 28:
! 29: $classes = array('Traversable', 'Iterator', 'IteratorAggregate', 'ExtendsIterator', 'ExtendsIteratorAggregate',
! 30: 'IteratorImpl', 'IterarorAggregateImpl', 'ExtendsIteratorImpl', 'ExtendsIteratorAggregateImpl', 'A');
! 31:
! 32: foreach($classes as $class) {
! 33: $rc = new ReflectionClass($class);
! 34: echo "Is $class iterable? ";
! 35: var_dump($rc->isIterateable());
! 36: }
! 37:
! 38: echo "\nTest invalid params:\n";
! 39: $rc = new ReflectionClass('IteratorImpl');
! 40: var_dump($rc->isIterateable(null));
! 41: var_dump($rc->isIterateable(null, null));
! 42: var_dump($rc->isIterateable(1));
! 43: var_dump($rc->isIterateable(1.5));
! 44: var_dump($rc->isIterateable(true));
! 45: var_dump($rc->isIterateable('X'));
! 46: var_dump($rc->isIterateable(null));
! 47:
! 48: echo "\nTest static invocation:\n";
! 49: ReflectionClass::isIterateable();
! 50:
! 51: ?>
! 52: --EXPECTF--
! 53: Is Traversable iterable? bool(false)
! 54: Is Iterator iterable? bool(false)
! 55: Is IteratorAggregate iterable? bool(false)
! 56: Is ExtendsIterator iterable? bool(false)
! 57: Is ExtendsIteratorAggregate iterable? bool(false)
! 58: Is IteratorImpl iterable? bool(true)
! 59: Is IterarorAggregateImpl iterable? bool(true)
! 60: Is ExtendsIteratorImpl iterable? bool(true)
! 61: Is ExtendsIteratorAggregateImpl iterable? bool(true)
! 62: Is A iterable? bool(false)
! 63:
! 64: Test invalid params:
! 65:
! 66: Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 34
! 67: NULL
! 68:
! 69: Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 2 given in %s on line 35
! 70: NULL
! 71:
! 72: Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 36
! 73: NULL
! 74:
! 75: Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 37
! 76: NULL
! 77:
! 78: Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 38
! 79: NULL
! 80:
! 81: Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 39
! 82: NULL
! 83:
! 84: Warning: ReflectionClass::isIterateable() expects exactly 0 parameters, 1 given in %s on line 40
! 85: NULL
! 86:
! 87: Test static invocation:
! 88:
! 89: Fatal error: Non-static method ReflectionClass::isIterateable() cannot be called statically in %s on line 43
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>