Created
June 25, 2016 15:28
-
-
Save simodima/8653b83afc963a4a67d0e824e66fe10f to your computer and use it in GitHub Desktop.
PHP iterable interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface Iterator extends Traversable | |
{ | |
abstract public mixed current ( void ) | |
abstract public scalar key ( void ) | |
abstract public void next ( void ) | |
abstract public void rewind ( void ) | |
abstract public boolean valid ( void ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface IteratorAggregate extends Traversable | |
{ | |
abstract public Traversable getIterator( void ) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Interface to detect if a class is traversable using foreach. | |
* Abstract base interface that cannot be implemented alone. Instead it must be implemented by either IteratorAggregate or Iterator. | |
*/ | |
abstract interface Traversable | |
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment