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