3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestClass { public function doIt() { echo 'done'; } } function is_instance_callable(array $definition) { return count($definition) === 2 && in_array($definition[1], get_class_methods($definition[0]) ?? [], true); } $callable = [TestClass::class, 'doIt', 'param' => 'myParam']; var_dump(is_instance_callable($callable)); var_dump(is_callable($callable));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ENbdC
function name:  (null)
number of ops:  14
compiled vars:  !0 = $callable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'is_instance_callable'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   19     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'is_callable'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function is_instance_callable:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/ENbdC
function name:  is_instance_callable
number of ops:  19
compiled vars:  !0 = $definition
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        COUNT                                            ~1      !0
          2        IS_IDENTICAL                                     ~2      ~1, 2
          3      > JMPZ_EX                                          ~2      ~2, ->17
          4    >   INIT_FCALL                                               'in_array'
          5        FETCH_DIM_R                                      ~3      !0, 1
          6        SEND_VAL                                                 ~3
          7        INIT_FCALL                                               'get_class_methods'
          8        FETCH_DIM_R                                      ~4      !0, 0
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11        COALESCE                                         ~6      $5
         12        QM_ASSIGN                                        ~6      <array>
         13        SEND_VAL                                                 ~6
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $7      
         16        BOOL                                             ~2      $7
         17    > > RETURN                                                   ~2
   14    18*     > RETURN                                                   null

End of function is_instance_callable

Class TestClass:
Function doit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ENbdC
function name:  doIt
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                     'done'
    8     1      > RETURN                                                   null

End of function doit

End of class TestClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.47 ms | 1008 KiB | 18 Q