3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stepMutator = stepMutator(); // This is the same as // // var_dump(iterator_to_array(stepMutator())); // var_dump(iterator_to_array($stepMutator)); function importSupport() { return array_values([ 'log' => function(?float $steps, ?string $tmpl = null) { return sprintf($tmpl ?? 'Mutator(steps=%s) Incremented', $steps); }, ]); } function importSpinners() { return array_values([ 'increment' => function(int $i) {return ++$i;}, 'decrement' => function(int $i) {return --$i;}, ]); } function stepMutator() { $id = random_int(1, 500000); $logLine = 0; list($log, $increment, $decrement) = array_merge( importSupport(), importSpinners() ); $logStep = function(int $step) {return sprintf('LogStep(%d)', $step);}; $stepper = function(int $step) {return sprintf('Step(%d)', $step);}; $steps = 0; yield $logStep(++$logLine) => $log($steps, 'Initialized(steps=%d)', $steps); yield $logStep(++$logLine) => $log(time(), 'Initialized(time=%s)'); yield $logStep(++$logLine) => $log($id, 'Initialized(id=%s)'); yield $logStep(++$logLine) => $log($steps = $increment($steps)); yield $logStep(++$logLine) => $log($steps = $increment($steps)); yield $logStep(++$logLine) => $log($steps = $increment($steps)); // Say, for instance, something needs pruning... yield $logStep(++$logLine) => $log($steps = $decrement($steps), 'Mutator(steps=%s) Decremented' ); yield $logStep(++$logLine) => $log($steps = $increment($steps)); yield $logStep(++$logLine) => $log(null, 'SIGEND'); // Signal end of processing. // Result of our effort. yield 'payload' => array_map($stepper, range(1, $steps)); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0mCqI
function name:  (null)
number of ops:  10
compiled vars:  !0 = $stepMutator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'stepMutator'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
    9     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'iterator_to_array'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
   55     9      > RETURN                                                   1

Function importsupport:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0mCqI
function name:  importSupport
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'array_values'
   13     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0mCqI%3A13%240'
   15     2        INIT_ARRAY                                       ~1      ~0, 'log'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5      > RETURN                                                   $2
   17     6*     > RETURN                                                   null

End of function importsupport

Function %00%7Bclosure%7D%2Fin%2F0mCqI%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0mCqI
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $steps, !1 = $tmpl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   14     2        INIT_FCALL                                               'sprintf'
          3        COALESCE                                         ~2      !1
          4        QM_ASSIGN                                        ~2      'Mutator%28steps%3D%25s%29+Incremented'
          5        SEND_VAL                                                 ~2
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   15     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F0mCqI%3A13%240

Function importspinners:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0mCqI
function name:  importSpinners
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'array_values'
   21     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0mCqI%3A21%241'
          2        INIT_ARRAY                                       ~1      ~0, 'increment'
   22     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0mCqI%3A22%242'
          4        ADD_ARRAY_ELEMENT                                ~1      ~2, 'decrement'
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
   24     8*     > RETURN                                                   null

End of function importspinners

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

End of function %00%7Bclosure%7D%2Fin%2F0mCqI%3A21%241

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

End of function %00%7Bclosure%7D%2Fin%2F0mCqI%3A22%242

Function stepmutator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/0mCqI
function name:  stepMutator
number of ops:  137
compiled vars:  !0 = $id, !1 = $logLine, !2 = $log, !3 = $increment, !4 = $decrement, !5 = $logStep, !6 = $stepper, !7 = $steps
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   GENERATOR_CREATE                                         
   27     1        INIT_FCALL                                               'random_int'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 500000
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !0, $8
   28     6        ASSIGN                                                   !1, 0
   29     7        INIT_FCALL                                               'array_merge'
   30     8        INIT_FCALL                                               'importsupport'
          9        DO_FCALL                                      0  $11     
         10        SEND_VAR                                                 $11
   31    11        INIT_FCALL                                               'importspinners'
         12        DO_FCALL                                      0  $12     
         13        SEND_VAR                                                 $12
         14        DO_ICALL                                         $13     
         15        FETCH_LIST_R                                     $14     $13, 0
   29    16        ASSIGN                                                   !2, $14
         17        FETCH_LIST_R                                     $16     $13, 1
         18        ASSIGN                                                   !3, $16
         19        FETCH_LIST_R                                     $18     $13, 2
         20        ASSIGN                                                   !4, $18
         21        FREE                                                     $13
   34    22        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0mCqI%3A34%243'
         23        ASSIGN                                                   !5, ~20
   35    24        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0mCqI%3A35%244'
         25        ASSIGN                                                   !6, ~22
   36    26        ASSIGN                                                   !7, 0
   38    27        INIT_DYNAMIC_CALL                                        !5
         28        PRE_INC                                          ~25     !1
         29        SEND_VAL_EX                                              ~25
         30        DO_FCALL                                      0  $26     
         31        INIT_DYNAMIC_CALL                                        !2
         32        SEND_VAR_EX                                              !7
         33        SEND_VAL_EX                                              'Initialized%28steps%3D%25d%29'
         34        SEND_VAR_EX                                              !7
         35        DO_FCALL                                      0  $27     
         36        YIELD                                                    $27, $26
   39    37        INIT_DYNAMIC_CALL                                        !5
         38        PRE_INC                                          ~29     !1
         39        SEND_VAL_EX                                              ~29
         40        DO_FCALL                                      0  $30     
         41        INIT_DYNAMIC_CALL                                        !2
         42        INIT_FCALL                                               'time'
         43        DO_ICALL                                         $31     
         44        SEND_VAR_NO_REF_EX                                       $31
         45        SEND_VAL_EX                                              'Initialized%28time%3D%25s%29'
         46        DO_FCALL                                      0  $32     
         47        YIELD                                                    $32, $30
   40    48        INIT_DYNAMIC_CALL                                        !5
         49        PRE_INC                                          ~34     !1
         50        SEND_VAL_EX                                              ~34
         51        DO_FCALL                                      0  $35     
         52        INIT_DYNAMIC_CALL                                        !2
         53        SEND_VAR_EX                                              !0
         54        SEND_VAL_EX                                              'Initialized%28id%3D%25s%29'
         55        DO_FCALL                                      0  $36     
         56        YIELD                                                    $36, $35
   41    57        INIT_DYNAMIC_CALL                                        !5
         58        PRE_INC                                          ~38     !1
         59        SEND_VAL_EX                                              ~38
         60        DO_FCALL                                      0  $39     
         61        INIT_DYNAMIC_CALL                                        !2
         62        INIT_DYNAMIC_CALL                                        !3
         63        SEND_VAR_EX                                              !7
         64        DO_FCALL                                      0  $40     
         65        ASSIGN                                           ~41     !7, $40
         66        SEND_VAL_EX                                              ~41
         67        DO_FCALL                                      0  $42     
         68        YIELD                                                    $42, $39
   42    69        INIT_DYNAMIC_CALL                                        !5
         70        PRE_INC                                          ~44     !1
         71        SEND_VAL_EX                                              ~44
         72        DO_FCALL                                      0  $45     
         73        INIT_DYNAMIC_CALL                                        !2
         74        INIT_DYNAMIC_CALL                                        !3
         75        SEND_VAR_EX                                              !7
         76        DO_FCALL                                      0  $46     
         77        ASSIGN                                           ~47     !7, $46
         78        SEND_VAL_EX                                              ~47
         79        DO_FCALL                                      0  $48     
         80        YIELD                                                    $48, $45
   43    81        INIT_DYNAMIC_CALL                                        !5
         82        PRE_INC                                          ~50     !1
         83        SEND_VAL_EX                                              ~50
         84        DO_FCALL                                      0  $51     
         85        INIT_DYNAMIC_CALL                                        !2
         86        INIT_DYNAMIC_CALL                                        !3
         87        SEND_VAR_EX                                              !7
         88        DO_FCALL                                      0  $52     
         89        ASSIGN                                           ~53     !7, $52
         90        SEND_VAL_EX                                              ~53
         91        DO_FCALL                                      0  $54     
         92        YIELD                                                    $54, $51
   46    93        INIT_DYNAMIC_CALL                                        !5
         94        PRE_INC                                          ~56     !1
         95        SEND_VAL_EX                                              ~56
         96        DO_FCALL                                      0  $57     
         97        INIT_DYNAMIC_CALL                                        !2
         98        INIT_DYNAMIC_CALL                                        !4
         99        SEND_VAR_EX                                              !7
        100        DO_FCALL                                      0  $58     
        101        ASSIGN                                           ~59     !7, $58
        102        SEND_VAL_EX                                              ~59
   47   103        SEND_VAL_EX                                              'Mutator%28steps%3D%25s%29+Decremented'
        104        DO_FCALL                                      0  $60     
        105        YIELD                                                    $60, $57
   50   106        INIT_DYNAMIC_CALL                                        !5
        107        PRE_INC                                          ~62     !1
        108        SEND_VAL_EX                                              ~62
        109        DO_FCALL                                      0  $63     
        110        INIT_DYNAMIC_CALL                                        !2
        111        INIT_DYNAMIC_CALL                                        !3
        112        SEND_VAR_EX                                              !7
        113        DO_FCALL                                      0  $64     
        114        ASSIGN                                           ~65     !7, $64
        115        SEND_VAL_EX                                              ~65
        116        DO_FCALL                                      0  $66     
        117        YIELD                                                    $66, $63
   51   118        INIT_DYNAMIC_CALL                                        !5
        119        PRE_INC                                          ~68     !1
        120        SEND_VAL_EX                                              ~68
        121        DO_FCALL                                      0  $69     
        122        INIT_DYNAMIC_CALL                                        !2
        123        SEND_VAL_EX                                              null
        124        SEND_VAL_EX                                              'SIGEND'
        125        DO_FCALL                                      0  $70     
        126        YIELD                                                    $70, $69
   54   127        INIT_FCALL                                               'array_map'
        128        SEND_VAR                                                 !6
        129        INIT_FCALL                                               'range'
        130        SEND_VAL                                                 1
        131        SEND_VAR                                                 !7
        132        DO_ICALL                                         $72     
        133        SEND_VAR                                                 $72
        134        DO_ICALL                                         $73     
        135        YIELD                                                    $73, 'payload'
   55   136      > GENERATOR_RETURN                                         

End of function stepmutator

Function %00%7Bclosure%7D%2Fin%2F0mCqI%3A34%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0mCqI
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $step
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'sprintf'
          2        SEND_VAL                                                 'LogStep%28%25d%29'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F0mCqI%3A34%243

Function %00%7Bclosure%7D%2Fin%2F0mCqI%3A35%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0mCqI
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $step
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'sprintf'
          2        SEND_VAL                                                 'Step%28%25d%29'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F0mCqI%3A35%244

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.19 ms | 1415 KiB | 33 Q