3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class A implements IteratorAggregate { function __construct(public string $foo = 'bar') {} function getIterator() : Traversable { return new ArrayIterator($this); } } $obj = new A; foreach ($obj as $k => &$v) { $v = 'baz'; } var_dump($obj); // changed a readonly property
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 126) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/12vrb
function name:  (null)
number of ops:  14
compiled vars:  !0 = $obj, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'a'
   11     1        NEW                                              $3      'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   12     4      > FE_RESET_RW                                      $6      !0, ->9
          5    > > FE_FETCH_RW                                      ~7      $6, !1, ->9
          6    >   ASSIGN                                                   !2, ~7
          7        ASSIGN                                                   !1, 'baz'
          8      > JMP                                                      ->5
          9    >   FE_FREE                                                  $6
   13    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/12vrb
function name:  __construct
number of ops:  4
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_INIT                                        !0      'bar'
          1        ASSIGN_OBJ                                               'foo'
          2        OP_DATA                                                  !0
          3      > RETURN                                                   null

End of function __construct

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/12vrb
function name:  getIterator
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $0      'ArrayIterator'
          1        FETCH_THIS                                       $1      
          2        SEND_VAR_EX                                              $1
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $0
          5      > RETURN                                                   $0
    8     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function getiterator

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.83 ms | 1006 KiB | 14 Q