3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { function __construct($id, $gen) { $this->id = $id; $this->gen = $gen; } function __destruct() { echo "__destruct $this->id\n"; var_dump($this->gen->current()); var_dump($this->gen->key()); echo "\n\n"; } } function make($id, $self) { return new X($id, $self); } function gen() { $self = yield (0); echo "After yield 0\n"; $k = make('key', $self); $v = make('value', $self); yield $k => $v; unset($k, $v); echo "After yield X\n"; yield 12; } $a = gen(); var_dump($a->current()); $a->send($a); var_dump($a->current()); $a->next();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LUq3k
function name:  (null)
number of ops:  19
compiled vars:  !0 = $a
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  26     0  E >   INIT_FCALL                                               'gen'
         1        DO_FCALL                                      0  $1      
         2        QM_ASSIGN                                                !0
  27     3        INIT_FCALL                                               'var_dump'
         4        INIT_METHOD_CALL                                         !0, 'current'
         5        DO_FCALL                                      0  $3      
         6        SEND_VAR                                                 $3
         7        DO_ICALL                                                 
  28     8        INIT_METHOD_CALL                                         !0, 'send'
         9        SEND_VAR_EX                                              !0
        10        DO_FCALL                                      0          
  29    11        INIT_FCALL                                               'var_dump'
        12        INIT_METHOD_CALL                                         !0, 'current'
        13        DO_FCALL                                      0  $6      
        14        SEND_VAR                                                 $6
        15        DO_ICALL                                                 
  30    16        INIT_METHOD_CALL                                         !0, 'next'
        17        DO_FCALL                                      0          
        18      > RETURN                                                   1

Function make:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LUq3k
function name:  make
number of ops:  8
compiled vars:  !0 = $id, !1 = $self
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  13     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        NEW                                              $2      :7
         3        SEND_VAR_EX                                              !0
         4        SEND_VAR_EX                                              !1
         5        DO_FCALL                                      0          
         6      > RETURN                                                   $2
         7*     > RETURN                                                   null

End of function make

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/LUq3k
function name:  gen
number of ops:  20
compiled vars:  !0 = $self, !1 = $k, !2 = $v
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   DECLARE_CLASS                                            
  16     1        YIELD                                            $3      0
         2        QM_ASSIGN                                                !0
  17     3        ASSIGN_OBJ                                               'After+yield+0%0A'
  18     4        INIT_FCALL                                               'make'
         5        SEND_VAL                                                 'key'
         6        SEND_VAR                                                 !0
         7        DO_FCALL                                      0  $5      
         8        QM_ASSIGN                                                !1
  19     9        INIT_FCALL                                               'make'
        10        SEND_VAL                                                 'value'
        11        SEND_VAR                                                 !0
        12        DO_FCALL                                      0  $7      
        13        QM_ASSIGN                                                !2
  20    14        YIELD                                                    !2, !1
  21    15        DECLARE_LAMBDA_FUNCTION                                  !1
        16        DECLARE_LAMBDA_FUNCTION                                  !2
  22    17        ASSIGN_OBJ                                               'After+yield+X%0A'
  23    18        YIELD                                                    12
  24    19      > GENERATOR_RETURN                                         

End of function gen

Class X:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LUq3k
function name:  __construct
number of ops:  7
compiled vars:  !0 = $id, !1 = $gen
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        ASSIGN_SUB                                    0          'id'
         3        OP_DATA                                                  !0
         4        ASSIGN_SUB                                   24          'gen'
         5        OP_DATA                                                  !1
         6      > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LUq3k
function name:  __destruct
number of ops:  19
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   6     0  E >   ROPE_INIT                                     3  ~2      '__destruct+'
         1        FETCH_OBJ_R                                      ~0      'id'
         2        ROPE_ADD                                      1  ~2      ~2, ~0
         3        ROPE_END                                      2  ~1      ~2, '%0A'
         4        ASSIGN_OBJ                                               ~1
   7     5        INIT_FCALL                                               'var_dump'
         6        FETCH_OBJ_R                                      ~4      'gen'
         7        INIT_METHOD_CALL                                         ~4, 'current'
         8        DO_FCALL                                      0  $5      
         9        SEND_VAR                                                 $5
        10        DO_ICALL                                                 
   8    11        INIT_FCALL                                               'var_dump'
        12        FETCH_OBJ_R                                      ~7      'gen'
        13        INIT_METHOD_CALL                                         ~7, 'key'
        14        DO_FCALL                                      0  $8      
        15        SEND_VAR                                                 $8
        16        DO_ICALL                                                 
   9    17        ASSIGN_OBJ                                               '%0A%0A'
  10    18      > RETURN                                                   null

End of function __destruct

End of class X.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
16.01 ms | 416 KiB | 7 Q