3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { function __construct($gen) { $this->gen = $gen; } function __destruct() { echo "__destruct: "; var_dump($this->gen->current()); echo "=====\n"; } } function gen() { $self = yield (0); echo "After yield 0\n"; yield (new X($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/f66TN
function name:  (null)
number of ops:  24
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'gen'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   17     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'current'
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   18     8        INIT_METHOD_CALL                                         !0, 'send'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
   19    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'current'
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
   20    16        INIT_METHOD_CALL                                         !0, 'next'
         17        DO_FCALL                                      0          
   21    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/f66TN
function name:  gen
number of ops:  11
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   GENERATOR_CREATE                                         
    9     1        YIELD                                            $1      0
          2        ASSIGN                                                   !0, $1
   10     3        ECHO                                                     'After+yield+0%0A'
   11     4        NEW                                              $3      'X'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        YIELD                                                    $3
   12     8        ECHO                                                     'After+yield+X%0A'
   13     9      > GENERATOR_RETURN                                         
   14    10*     > 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/f66TN
function name:  __construct
number of ops:  4
compiled vars:  !0 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'gen'
          2        OP_DATA                                                  !0
          3      > 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/f66TN
function name:  __destruct
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     '__destruct%3A+'
          1        INIT_FCALL                                               'var_dump'
          2        FETCH_OBJ_R                                      ~0      'gen'
          3        INIT_METHOD_CALL                                         ~0, 'current'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                                 
          7        ECHO                                                     '%3D%3D%3D%3D%3D%0A'
          8      > RETURN                                                   null

End of function __destruct

End of class X.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.47 ms | 1403 KiB | 16 Q