3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Stuff { function __invoke() { return 'I am ' . get_class($this) . '.'; } } class Thing { function __invoke() { return 'I am Thing.'; } } class Thang { use Stuff; } $things[] = function () { return 'I am Thong.'; }; $things[] = new Thing; $things[] = new Thang; $things[] = 'strlen'; $things[] = [$things[0], '__invoke']; $things[] = [$things[1], '__invoke']; var_dump(array_map('is_callable'), $things);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mjCEp
function name:  (null)
number of ops:  32
compiled vars:  !0 = $things
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CLASS                                            'thang'
    6     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmjCEp%3A6%241'
          2        ASSIGN_DIM                                               !0
          3        OP_DATA                                                  ~2
    7     4        NEW                                              $4      'Thing'
          5        DO_FCALL                                      0          
          6        ASSIGN_DIM                                               !0
          7        OP_DATA                                                  $4
    8     8        NEW                                              $7      'Thang'
          9        DO_FCALL                                      0          
         10        ASSIGN_DIM                                               !0
         11        OP_DATA                                                  $7
    9    12        ASSIGN_DIM                                               !0
         13        OP_DATA                                                  'strlen'
   10    14        FETCH_DIM_R                                      ~11     !0, 0
         15        INIT_ARRAY                                       ~12     ~11
         16        ADD_ARRAY_ELEMENT                                ~12     '__invoke'
         17        ASSIGN_DIM                                               !0
         18        OP_DATA                                                  ~12
   11    19        FETCH_DIM_R                                      ~14     !0, 1
         20        INIT_ARRAY                                       ~15     ~14
         21        ADD_ARRAY_ELEMENT                                ~15     '__invoke'
         22        ASSIGN_DIM                                               !0
         23        OP_DATA                                                  ~15
   13    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'array_map'
         26        SEND_VAL                                                 'is_callable'
         27        DO_ICALL                                         $16     
         28        SEND_VAR                                                 $16
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FmjCEp%3A6%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mjCEp
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   'I+am+Thong.'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmjCEp%3A6%241

Class Stuff:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mjCEp
function name:  __invoke
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        CONCAT                                           ~2      'I+am+', ~1
          3        CONCAT                                           ~3      ~2, '.'
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of function __invoke

End of class Stuff.

Class Thing:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mjCEp
function name:  __invoke
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   'I+am+Thing.'
          1*     > RETURN                                                   null

End of function __invoke

End of class Thing.

Class Thang: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.35 ms | 1400 KiB | 17 Q