3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mutate($value, Generator $mutator) { while ($mutator->valid()) { try { $fn = $mutator->current(); $value = $fn($value); $mutator->send($value); } catch (Exception $e) { $mutator->throw($e); } } return $value; } $mutations = [ function ($n) { return $n + 1; }, function ($n) { return $n + 2; }, function ($n) { return $n + 3; }, function ($n) { return $n + 4; }, ]; function debuggingMutator(array $mutations) { foreach ($mutations as $mutation) { $result = (yield $mutation); echo "Result: {$result}\n"; } } $result = mutate(0, debuggingMutator($mutations)); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J2L92
function name:  (null)
number of ops:  21
compiled vars:  !0 = $mutations, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJ2L92%3A19%240'
          1        INIT_ARRAY                                       ~3      ~2
   20     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJ2L92%3A20%241'
          3        ADD_ARRAY_ELEMENT                                ~3      ~4
   21     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJ2L92%3A21%242'
          5        ADD_ARRAY_ELEMENT                                ~3      ~5
   22     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FJ2L92%3A22%243'
          7        ADD_ARRAY_ELEMENT                                ~3      ~6
   18     8        ASSIGN                                                   !0, ~3
   33     9        INIT_FCALL                                               'mutate'
         10        SEND_VAL                                                 0
         11        INIT_FCALL                                               'debuggingmutator'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $8      
         14        SEND_VAR                                                 $8
         15        DO_FCALL                                      0  $9      
         16        ASSIGN                                                   !1, $9
   34    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function mutate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 3
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Found catch point at position: 14
Branch analysis from position: 14
2 jumps found. (Code = 107) Position 1 = 15, Position 2 = -2
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 3
Branch analysis from position: 21
Branch analysis from position: 3
filename:       /in/J2L92
function name:  mutate
number of ops:  23
compiled vars:  !0 = $value, !1 = $mutator, !2 = $fn, !3 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2      > JMP                                                      ->18
    7     3    >   INIT_METHOD_CALL                                         !1, 'current'
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !2, $4
    8     6        INIT_DYNAMIC_CALL                                        !2
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !0, $6
    9    10        INIT_METHOD_CALL                                         !1, 'send'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
         13      > JMP                                                      ->18
   10    14  E > > CATCH                                       last         'Exception'
   11    15    >   INIT_METHOD_CALL                                         !1, 'throw'
         16        SEND_VAR_EX                                              !3
         17        DO_FCALL                                      0          
    5    18    >   INIT_METHOD_CALL                                         !1, 'valid'
         19        DO_FCALL                                      0  $10     
         20      > JMPNZ                                                    $10, ->3
   15    21    > > RETURN                                                   !0
   16    22*     > RETURN                                                   null

End of function mutate

Function %00%7Bclosure%7D%2Fin%2FJ2L92%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J2L92
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 1
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJ2L92%3A19%240

Function %00%7Bclosure%7D%2Fin%2FJ2L92%3A20%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J2L92
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 2
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJ2L92%3A20%241

Function %00%7Bclosure%7D%2Fin%2FJ2L92%3A21%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J2L92
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 3
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJ2L92%3A21%242

Function %00%7Bclosure%7D%2Fin%2FJ2L92%3A22%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J2L92
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        ADD                                              ~1      !0, 4
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FJ2L92%3A22%243

Function debuggingmutator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
filename:       /in/J2L92
function name:  debuggingMutator
number of ops:  13
compiled vars:  !0 = $mutations, !1 = $mutation, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   27     2      > FE_RESET_R                                       $3      !0, ->11
          3    > > FE_FETCH_R                                               $3, !1, ->11
   28     4    >   YIELD                                            $4      !1
          5        ASSIGN                                                   !2, $4
   29     6        ROPE_INIT                                     3  ~7      'Result%3A+'
          7        ROPE_ADD                                      1  ~7      ~7, !2
          8        ROPE_END                                      2  ~6      ~7, '%0A'
          9        ECHO                                                     ~6
   27    10      > JMP                                                      ->3
         11    >   FE_FREE                                                  $3
   31    12      > GENERATOR_RETURN                                         

End of function debuggingmutator

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.47 ms | 1407 KiB | 17 Q