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

Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/tpvPO
function name:  gen
number of ops:  21
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        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   16     8        ECHO                                                     'After+yield+0%0A'
   17     9        NEW                                              $5      'X'
         10        SEND_VAL_EX                                              'key'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
         13        NEW                                              $7      'X'
         14        SEND_VAL_EX                                              'value'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0          
         17        YIELD                                                    $7, $5
   18    18        ECHO                                                     'After+yield+X%0A'
   19    19      > GENERATOR_RETURN                                         
   20    20*     > 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/tpvPO
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/tpvPO
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:
165.42 ms | 1402 KiB | 16 Q