3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function flatten() { $data = func_get_args(); return array_reduce($data, function($c, $a){ return array_merge($c, is_array($a) ?$this->flatten(...$a) : [$a]); }, []) ; } } var_dump((new Foo())->flatten(1)); var_dump((new Foo())->flatten()); var_dump((new Foo())->flatten(1, [2], [3, [4,5]]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uRUpK
function name:  (null)
number of ops:  26
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'Foo'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'flatten'
          4        SEND_VAL_EX                                              1
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   20     8        INIT_FCALL                                               'var_dump'
          9        NEW                                              $4      'Foo'
         10        DO_FCALL                                      0          
         11        INIT_METHOD_CALL                                         $4, 'flatten'
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
   21    15        INIT_FCALL                                               'var_dump'
         16        NEW                                              $8      'Foo'
         17        DO_FCALL                                      0          
         18        INIT_METHOD_CALL                                         $8, 'flatten'
         19        SEND_VAL_EX                                              1
         20        SEND_VAL_EX                                              <array>
         21        SEND_VAL_EX                                              <array>
         22        DO_FCALL                                      0  $10     
         23        SEND_VAR                                                 $10
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FuRUpK%3A10%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uRUpK
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $c, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        INIT_FCALL                                               'array_merge'
          3        SEND_VAR                                                 !0
          4        TYPE_CHECK                                  128          !1
          5      > JMPZ                                                     ~2, ->13
          6    >   FETCH_THIS                                       $3      
          7        INIT_METHOD_CALL                                         $3, 'flatten'
          8        SEND_UNPACK                                              !1
          9        CHECK_UNDEF_ARGS                                         
         10        DO_FCALL                                      1  $4      
         11        QM_ASSIGN                                        ~5      $4
         12      > JMP                                                      ->15
         13    >   INIT_ARRAY                                       ~6      !1
         14        QM_ASSIGN                                        ~5      ~6
         15    >   SEND_VAL                                                 ~5
         16        DO_ICALL                                         $7      
         17      > RETURN                                                   $7
   12    18*     > RETURN                                                   null

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

Class Foo:
Function flatten:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uRUpK
function name:  flatten
number of ops:  10
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
   10     2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FuRUpK%3A10%240'
   12     5        SEND_VAL                                                 ~3
          6        SEND_VAL                                                 <array>
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
   15     9*     > RETURN                                                   null

End of function flatten

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
129.6 ms | 1405 KiB | 19 Q