3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * yield expression: what is evaluated first: key or value? */ function genkey($key) { echo "(key) $key\n"; return $key; } function value($value) { echo "(value) $value\n"; return $value; } $gen = function() { foreach(range(0, 2) as $i) { yield genkey(chr(65+$i)) => value($i); } }; iterator_to_array($gen());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQa18
function name:  (null)
number of ops:  8
compiled vars:  !0 = $gen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcQa18%3A16%240'
          1        ASSIGN                                                   !0, ~1
   22     2        INIT_FCALL                                               'iterator_to_array'
          3        INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0  $3      
          5        SEND_VAR                                                 $3
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function genkey:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQa18
function name:  genkey
number of ops:  7
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ROPE_INIT                                     3  ~2      '%28key%29+'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        ECHO                                                     ~1
    8     5      > RETURN                                                   !0
    9     6*     > RETURN                                                   null

End of function genkey

Function value:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQa18
function name:  value
number of ops:  7
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ROPE_INIT                                     3  ~2      '%28value%29+'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        ECHO                                                     ~1
   13     5      > RETURN                                                   !0
   14     6*     > RETURN                                                   null

End of function value

Function %00%7Bclosure%7D%2Fin%2FcQa18%3A16%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 19
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 19
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 19
filename:       /in/cQa18
function name:  {closure}
number of ops:  21
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   GENERATOR_CREATE                                         
   17     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 2
          4        DO_ICALL                                         $1      
          5      > FE_RESET_R                                       $2      $1, ->19
          6    > > FE_FETCH_R                                               $2, !0, ->19
   18     7    >   INIT_FCALL                                               'genkey'
          8        INIT_FCALL                                               'chr'
          9        ADD                                              ~3      65, !0
         10        SEND_VAL                                                 ~3
         11        DO_ICALL                                         $4      
         12        SEND_VAR                                                 $4
         13        DO_FCALL                                      0  $5      
         14        INIT_FCALL                                               'value'
         15        SEND_VAR                                                 !0
         16        DO_FCALL                                      0  $6      
         17        YIELD                                                    $6, $5
   17    18      > JMP                                                      ->6
         19    >   FE_FREE                                                  $2
   20    20      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FcQa18%3A16%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.79 ms | 1394 KiB | 21 Q