3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Entity { protected $_properties = []; public function &__get($property) { $value = null; return $value; } public function __set($property, $value) { $property = [$property => $value]; foreach ($property as $p => $value) { $this->_properties[$p] = $value; } } } class CustomIterator extends IteratorIterator { public $callback; public function __construct($items) { $this->callback = function ($a) { $a->foo .= ' world'; return $a; }; parent::__construct($items); } public function current() { $c = $this->callback; return $c(parent::current()); } } $entity = new Entity(); $it = new CustomIterator(new ArrayIterator([$entity])); $it->rewind(); var_dump($it->current());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pb3a2
function name:  (null)
number of ops:  19
compiled vars:  !0 = $entity, !1 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $2      'Entity'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   45     3        NEW                                              $5      'CustomIterator'
          4        NEW                                              $6      'ArrayIterator'
          5        INIT_ARRAY                                       ~7      !0
          6        SEND_VAL_EX                                              ~7
          7        DO_FCALL                                      0          
          8        SEND_VAR_NO_REF_EX                                       $6
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $5
   46    11        INIT_METHOD_CALL                                         !1, 'rewind'
         12        DO_FCALL                                      0          
   47    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !1, 'current'
         15        DO_FCALL                                      0  $12     
         16        SEND_VAR                                                 $12
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fpb3a2%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pb3a2
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        ASSIGN_OBJ_OP                                 8          !0, 'foo'
          2        OP_DATA                                                  '+world'
   32     3      > RETURN                                                   !0
   33     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fpb3a2%3A30%240

Class Entity:
Function __get:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/pb3a2
function name:  __get
number of ops:  4
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        ASSIGN                                                   !1, null
   12     2      > RETURN_BY_REF                                            !1
   13     3*     > RETURN_BY_REF                                            null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/pb3a2
function name:  __set
number of ops:  13
compiled vars:  !0 = $property, !1 = $value, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_ARRAY                                       ~3      !1, !0
          3        ASSIGN                                                   !0, ~3
   19     4      > FE_RESET_R                                       $5      !0, ->11
          5    > > FE_FETCH_R                                       ~6      $5, !1, ->11
          6    >   ASSIGN                                                   !2, ~6
   20     7        FETCH_OBJ_W                                      $8      '_properties'
          8        ASSIGN_DIM                                               $8, !2
          9        OP_DATA                                                  !1
   19    10      > JMP                                                      ->5
         11    >   FE_FREE                                                  $5
   22    12      > RETURN                                                   null

End of function __set

End of class Entity.

Class CustomIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pb3a2
function name:  __construct
number of ops:  8
compiled vars:  !0 = $items
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fpb3a2%3A30%240'
          2        ASSIGN_OBJ                                               'callback'
   33     3        OP_DATA                                                  ~2
   34     4        INIT_STATIC_METHOD_CALL                                  
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   35     7      > RETURN                                                   null

End of function __construct

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pb3a2
function name:  current
number of ops:  9
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   FETCH_OBJ_R                                      ~1      'callback'
          1        ASSIGN                                                   !0, ~1
   39     2        INIT_DYNAMIC_CALL                                        !0
          3        INIT_STATIC_METHOD_CALL                                  'current'
          4        DO_FCALL                                      0  $3      
          5        SEND_VAR_NO_REF_EX                                       $3
          6        DO_FCALL                                      0  $4      
          7      > RETURN                                                   $4
   40     8*     > RETURN                                                   null

End of function current

End of class CustomIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.05 ms | 1400 KiB | 15 Q