Does ArrayAccess extend Traversable? The man pages for each make no mention of the other. The ArrayAccess page does not indicate that it extends Traversable, but it doesn't explicitly deny it either. I ask because I have code that could take either Traversable or ArrayAccess, and I want to make sure that I need to test for both.
1 Answer
Short answer No.
for what you need you can use arrayiterator http://php.net/manual/en/class.arrayiterator.php
- Interfaces do not implement each other "it extends."
- Interfaces are made to implemented or extended by developer through interface / abstract classes / classes.
interfaces are contracts that some code implements and adheres to and other code depends upon. It allows us to have assurance that any given dependency will implement the methods we expect. Even further, with the upcoming PHP 7, we can also use type hints (object and scalars) and return types to further ensure that concrete implementations adhere to the contracts.
ArrayAccessis pretty obvious, isn't it?