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)); var_dump(array_map(function ($thing) { return is_object($thing) && method_exists($thing, '__invoke'); }, $things)); var_dump(array_map(function ($thing) { return is_callable($thing, '__invoke') && !is_string($thing); }, $things));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZfom
function name:  (null)
number of ops:  48
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%2FLZfom%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        SEND_VAR                                                 !0
         28        DO_ICALL                                         $16     
         29        SEND_VAR                                                 $16
         30        DO_ICALL                                                 
   14    31        INIT_FCALL                                               'var_dump'
         32        INIT_FCALL                                               'array_map'
         33        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLZfom%3A14%242'
         34        SEND_VAL                                                 ~18
         35        SEND_VAR                                                 !0
         36        DO_ICALL                                         $19     
         37        SEND_VAR                                                 $19
         38        DO_ICALL                                                 
   15    39        INIT_FCALL                                               'var_dump'
         40        INIT_FCALL                                               'array_map'
         41        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLZfom%3A15%243'
         42        SEND_VAL                                                 ~21
         43        SEND_VAR                                                 !0
         44        DO_ICALL                                         $22     
         45        SEND_VAR                                                 $22
         46        DO_ICALL                                                 
         47      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FLZfom%3A6%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZfom
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%2FLZfom%3A6%241

Function %00%7Bclosure%7D%2Fin%2FLZfom%3A14%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/LZfom
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        TYPE_CHECK                                  256  ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->8
          3    >   INIT_FCALL                                               'method_exists'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 '__invoke'
          6        DO_ICALL                                         $2      
          7        BOOL                                             ~1      $2
          8    > > RETURN                                                   ~1
          9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLZfom%3A14%242

Function %00%7Bclosure%7D%2Fin%2FLZfom%3A15%243:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/LZfom
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'is_callable'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '__invoke'
          4        DO_ICALL                                         $1      
          5      > JMPZ_EX                                          ~2      $1, ->9
          6    >   TYPE_CHECK                                   64  ~3      !0
          7        BOOL_NOT                                         ~4      ~3
          8        BOOL                                             ~2      ~4
          9    > > RETURN                                                   ~2
         10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLZfom%3A15%243

Class Stuff:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZfom
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/LZfom
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:
161.66 ms | 1404 KiB | 21 Q