3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Advanced PHP Interface Example: Traversable and Countable extended * * As Traversable is an internal class but PHP interfaces allow to extend * from multiple interfaces, it is possible to create your own internal * type (here based on Traversable) and base another non-internal sub-type * on it (here based on IteratorAggregate). * * @link http://wpkrauts.com/2013/how-to-build-flexible-php-interfaces/ */ interface CountableTraversable extends Traversable, Countable { } interface CountableTraversableAggregate extends CountableTraversable, IteratorAggregate { } class Widgets implements CountableTraversableAggregate { private $widgets = array(); function getIterator() { return new ArrayIterator($this->widgets); } function count() { return count($this->widgets); } }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Widgets::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6hpLr on line 32 Deprecated: Return type of Widgets::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/6hpLr on line 27

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
58.88 ms | 402 KiB | 8 Q