3v4l.org

run code in 300+ PHP versions simultaneously
<?php // thanks to metaultralurker on reddit for inspiration function call(callable $fn) { return $fn(); } function map(callable $fn, \Traversable $data) { return call(function () use ($fn, $data) { foreach ($data as $v) { yield $fn($v); } }); } function filter(callable $fn, \Traversable $data) { return call(function () use ($fn, $data) { foreach ($data as $v) { if ($fn($v)) { yield $v; } } }); } $isNotZ = function ($x) { return $x !== 'Z'; }; $data = filter($isNotZ, map('strtoupper', call(function () { foreach (range('a', 'z') as $char) { yield $char; } }))); var_dump($data->current()); $data->next(); var_dump($data->current()); $data->next(); var_dump(iterator_to_array($data));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MSoU3
function name:  (null)
number of ops:  36
compiled vars:  !0 = $isNotZ, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMSoU3%3A27%242'
          1        ASSIGN                                                   !0, ~2
   31     2        INIT_FCALL                                               'filter'
          3        SEND_VAR                                                 !0
          4        INIT_FCALL                                               'map'
          5        SEND_VAL                                                 'strtoupper'
          6        INIT_FCALL                                               'call'
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMSoU3%3A31%243'
   35     8        SEND_VAL                                                 ~4
          9        DO_FCALL                                      0  $5      
         10        SEND_VAR                                                 $5
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_FCALL                                      0  $7      
   31    14        ASSIGN                                                   !1, $7
   38    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !1, 'current'
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
   39    20        INIT_METHOD_CALL                                         !1, 'next'
         21        DO_FCALL                                      0          
   40    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !1, 'current'
         24        DO_FCALL                                      0  $12     
         25        SEND_VAR                                                 $12
         26        DO_ICALL                                                 
   41    27        INIT_METHOD_CALL                                         !1, 'next'
         28        DO_FCALL                                      0          
   44    29        INIT_FCALL                                               'var_dump'
         30        INIT_FCALL                                               'iterator_to_array'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                         $15     
         33        SEND_VAR                                                 $15
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Function call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MSoU3
function name:  call
number of ops:  5
compiled vars:  !0 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
    7     4*     > RETURN                                                   null

End of function call

Function map:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MSoU3
function name:  map
number of ops:  10
compiled vars:  !0 = $fn, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'call'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMSoU3%3A10%240'
          4        BIND_LEXICAL                                             ~2, !0
          5        BIND_LEXICAL                                             ~2, !1
   14     6        SEND_VAL                                                 ~2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   15     9*     > RETURN                                                   null

End of function map

Function %00%7Bclosure%7D%2Fin%2FMSoU3%3A10%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 10
filename:       /in/MSoU3
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $fn, !1 = $data, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   GENERATOR_CREATE                                         
          1        BIND_STATIC                                              !0
          2        BIND_STATIC                                              !1
   11     3      > FE_RESET_R                                       $3      !1, ->10
          4    > > FE_FETCH_R                                               $3, !2, ->10
   12     5    >   INIT_DYNAMIC_CALL                                        !0
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $4      
          8        YIELD                                                    $4
   11     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $3
   14    11      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FMSoU3%3A10%240

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MSoU3
function name:  filter
number of ops:  10
compiled vars:  !0 = $fn, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        INIT_FCALL                                               'call'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMSoU3%3A18%241'
          4        BIND_LEXICAL                                             ~2, !0
          5        BIND_LEXICAL                                             ~2, !1
   24     6        SEND_VAL                                                 ~2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   25     9*     > RETURN                                                   null

End of function filter

Function %00%7Bclosure%7D%2Fin%2FMSoU3%3A18%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 11
filename:       /in/MSoU3
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $fn, !1 = $data, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   GENERATOR_CREATE                                         
          1        BIND_STATIC                                              !0
          2        BIND_STATIC                                              !1
   19     3      > FE_RESET_R                                       $3      !1, ->11
          4    > > FE_FETCH_R                                               $3, !2, ->11
   20     5    >   INIT_DYNAMIC_CALL                                        !0
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $4      
          8      > JMPZ                                                     $4, ->10
   21     9    >   YIELD                                                    !2
   19    10    > > JMP                                                      ->4
         11    >   FE_FREE                                                  $3
   24    12      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FMSoU3%3A18%241

Function %00%7Bclosure%7D%2Fin%2FMSoU3%3A27%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MSoU3
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        IS_NOT_IDENTICAL                                 ~1      !0, 'Z'
          2      > RETURN                                                   ~1
   29     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMSoU3%3A27%242

Function %00%7Bclosure%7D%2Fin%2FMSoU3%3A31%243:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 9
filename:       /in/MSoU3
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   GENERATOR_CREATE                                         
   32     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 'a'
          3        SEND_VAL                                                 'z'
          4        DO_ICALL                                         $1      
          5      > FE_RESET_R                                       $2      $1, ->9
          6    > > FE_FETCH_R                                               $2, !0, ->9
   33     7    >   YIELD                                                    !0
   32     8      > JMP                                                      ->6
          9    >   FE_FREE                                                  $2
   35    10      > GENERATOR_RETURN                                         

End of function %00%7Bclosure%7D%2Fin%2FMSoU3%3A31%243

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.2 ms | 1411 KiB | 24 Q