3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Entity { protected $_properties = []; public function &__get($property) { $value = null; if (isset($this->_properties[$property])) { $value =& $this->_properties[$property]; } return $value; } public function __set($property, $value) { $this->_properties[$property] = $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(); $entity->foo = 'hello'; $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/S3fTZ
function name:  (null)
number of ops:  21
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
   44     3        ASSIGN_OBJ                                               !0, 'foo'
          4        OP_DATA                                                  'hello'
   46     5        NEW                                              $6      'CustomIterator'
          6        NEW                                              $7      'ArrayIterator'
          7        INIT_ARRAY                                       ~8      !0
          8        SEND_VAL_EX                                              ~8
          9        DO_FCALL                                      0          
         10        SEND_VAR_NO_REF_EX                                       $7
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $6
   47    13        INIT_METHOD_CALL                                         !1, 'rewind'
         14        DO_FCALL                                      0          
   48    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !1, 'current'
         17        DO_FCALL                                      0  $13     
         18        SEND_VAR                                                 $13
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FS3fTZ%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S3fTZ
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%2FS3fTZ%3A30%240

Class Entity:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
Return found
Branch analysis from position: 8
filename:       /in/S3fTZ
function name:  __get
number of ops:  10
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        FETCH_OBJ_IS                                     ~3      '_properties'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~3, !0
          4      > JMPZ                                                     ~4, ->8
   13     5    >   FETCH_OBJ_W                                      $5      '_properties'
          6        FETCH_DIM_W                                      $6      $5, !0
          7        ASSIGN_REF                                               !1, $6
   16     8    > > RETURN_BY_REF                                            !1
   17     9*     > RETURN_BY_REF                                            null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S3fTZ
function name:  __set
number of ops:  6
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        FETCH_OBJ_W                                      $2      '_properties'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   22     5      > 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/S3fTZ
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%2FS3fTZ%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/S3fTZ
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:
178.38 ms | 1400 KiB | 15 Q