3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Vite { protected $buildDirectory; public function useBuildDirectory($path) { $this->buildDirectory = $path; } public function __invoke($entry, $buildDirectory = 'default') { return func_get_args()[1] ?? $this->buildDirectory ?? 'default'; } } $vite = new Vite(); var_dump([ 'expect' => 'default', 'recieved' => $vite([]) ]); var_dump([ 'expect' => 'foo', 'recieved' => $vite([], 'foo') ]); $vite->useBuildDirectory('custom'); var_dump([ 'expect' => 'custom', 'recieved' => $vite([]) ]); var_dump([ 'expect' => 'foo', 'recieved' => $vite([], 'foo') ]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J6XeM
function name:  (null)
number of ops:  41
compiled vars:  !0 = $vite
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $1      'Vite'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   19     3        INIT_FCALL                                               'var_dump'
   20     4        INIT_ARRAY                                       ~4      'default', 'expect'
   21     5        INIT_DYNAMIC_CALL                                        !0
          6        SEND_VAL_EX                                              <array>
          7        DO_FCALL                                      0  $5      
          8        ADD_ARRAY_ELEMENT                                ~4      $5, 'recieved'
          9        SEND_VAL                                                 ~4
   19    10        DO_ICALL                                                 
   23    11        INIT_FCALL                                               'var_dump'
   24    12        INIT_ARRAY                                       ~7      'foo', 'expect'
   25    13        INIT_DYNAMIC_CALL                                        !0
         14        SEND_VAL_EX                                              <array>
         15        SEND_VAL_EX                                              'foo'
         16        DO_FCALL                                      0  $8      
         17        ADD_ARRAY_ELEMENT                                ~7      $8, 'recieved'
         18        SEND_VAL                                                 ~7
   23    19        DO_ICALL                                                 
   28    20        INIT_METHOD_CALL                                         !0, 'useBuildDirectory'
         21        SEND_VAL_EX                                              'custom'
         22        DO_FCALL                                      0          
   29    23        INIT_FCALL                                               'var_dump'
   30    24        INIT_ARRAY                                       ~11     'custom', 'expect'
   31    25        INIT_DYNAMIC_CALL                                        !0
         26        SEND_VAL_EX                                              <array>
         27        DO_FCALL                                      0  $12     
         28        ADD_ARRAY_ELEMENT                                ~11     $12, 'recieved'
         29        SEND_VAL                                                 ~11
   29    30        DO_ICALL                                                 
   33    31        INIT_FCALL                                               'var_dump'
   34    32        INIT_ARRAY                                       ~14     'foo', 'expect'
   35    33        INIT_DYNAMIC_CALL                                        !0
         34        SEND_VAL_EX                                              <array>
         35        SEND_VAL_EX                                              'foo'
         36        DO_FCALL                                      0  $15     
         37        ADD_ARRAY_ELEMENT                                ~14     $15, 'recieved'
         38        SEND_VAL                                                 ~14
   33    39        DO_ICALL                                                 
   36    40      > RETURN                                                   1

Class Vite:
Function usebuilddirectory:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J6XeM
function name:  useBuildDirectory
number of ops:  4
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'buildDirectory'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function usebuilddirectory

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J6XeM
function name:  __invoke
number of ops:  11
compiled vars:  !0 = $entry, !1 = $buildDirectory
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'default'
   14     2        FUNC_GET_ARGS                                    ~2      
          3        FETCH_DIM_IS                                     ~3      ~2, 1
          4        COALESCE                                         ~4      ~3
          5        FETCH_OBJ_IS                                     ~5      'buildDirectory'
          6        COALESCE                                         ~6      ~5
          7        QM_ASSIGN                                        ~6      'default'
          8        QM_ASSIGN                                        ~4      ~6
          9      > RETURN                                                   ~4
   15    10*     > RETURN                                                   null

End of function __invoke

End of class Vite.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.3 ms | 1015 KiB | 14 Q