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); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6hpLr
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_CLASS                                            'countabletraversable'
   18     1        DECLARE_CLASS                                            'countabletraversableaggregate'
   23     2        DECLARE_CLASS                                            'widgets'
   36     3      > RETURN                                                   1

Class CountableTraversable: [no user functions]
Class CountableTraversableAggregate: [no user functions]
Class Widgets:
Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6hpLr
function name:  getIterator
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $0      'ArrayIterator'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'widgets'
          3        SEND_FUNC_ARG                                            $1
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $0
   30     6*     > RETURN                                                   null

End of function getiterator

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6hpLr
function name:  count
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~0      'widgets'
          1        COUNT                                            ~1      ~0
          2      > RETURN                                                   ~1
   35     3*     > RETURN                                                   null

End of function count

End of class Widgets.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.94 ms | 1394 KiB | 13 Q