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 gen() { $self = yield (0); echo "After yield 0\n"; yield new X('key', $self) => new X('value', $self); echo "After yield X\n"; yield 12; } $a = gen(); $a->next(); 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/kFjqt
function name:  (null)
number of ops:  21
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'gen'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   22     3        INIT_METHOD_CALL                                         !0, 'next'
          4        DO_FCALL                                      0          
   23     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'current'
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   24    10        INIT_METHOD_CALL                                         !0, 'send'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
   25    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !0, 'current'
         15        DO_FCALL                                      0  $7      
         16        SEND_VAR                                                 $7
         17        DO_ICALL                                                 
   26    18        INIT_METHOD_CALL                                         !0, 'next'
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/kFjqt
function name:  gen
number of ops:  16
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   GENERATOR_CREATE                                         
   14     1        YIELD                                            $1      0
          2        ASSIGN                                                   !0, $1
   15     3        ECHO                                                     'After+yield+0%0A'
   16     4        NEW                                              $3      'X'
          5        SEND_VAL_EX                                              'key'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        NEW                                              $5      'X'
          9        SEND_VAL_EX                                              'value'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12        YIELD                                                    $5, $3
   17    13        ECHO                                                     'After+yield+X%0A'
   18    14        YIELD                                                    12
   19    15      > 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/kFjqt
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_OBJ                                               'id'
          3        OP_DATA                                                  !0
          4        ASSIGN_OBJ                                               '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/kFjqt
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        ECHO                                                     ~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        ECHO                                                     '%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:
152.7 ms | 1403 KiB | 16 Q