<?php
class EmptyIterator extends Iterator implements Countable
{
/** No operation.
* @return void
*/
function rewind()
{
// nothing to do
}
/** @return \c false
*/
function valid()
{
return false;
}
/** This function must not be called. It throws an exception upon access.
* @throw Exception
* @return void
*/
function current()
{
throw new Exception('Accessing the value of an EmptyIterator');
}
/** This function must not be called. It throws an exception upon access.
* @throw Exception
* @return void
*/
function key()
{
throw new Exception('Accessing the key of an EmptyIterator');
}
/** No operation.
* @return void
*/
function next()
{
// nothing to do
}
/**
* @return int
*/
function count()
{
return 0;
}
}
$ei = new EmptyIterator;
echo count($ei);
Fatal error: Class EmptyIterator cannot extend from interface Iterator in /in/VDOpJ on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.1
Fatal error: Class EmptyIterator must implement interface Traversable as part of either Iterator or IteratorAggregate in Unknown on line 0
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/VDOpJ on line 2
Process exited with code 255.