3v4l.org

run code in 300+ PHP versions simultaneously
<?php class obj { protected function protected_function(){ return true; } public function internal_is_callable(){ var_dump(is_callable([$this, "protected_function"])); } } $obj = new obj(); # If called from "outside" a class, is_callable() will return FALSE var_dump(is_callable([$obj, "protected_function"])); //returns bool(false) # Confusingly, if called from "inside" a class, is_callable() will return TRUE $obj->internal_is_callable(); //returns bool(true)
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fLaYN
function name:  (null)
number of ops:  14
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $1      'obj'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   16     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'is_callable'
          5        INIT_ARRAY                                       ~4      !0
          6        ADD_ARRAY_ELEMENT                                ~4      'protected_function'
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
   20    11        INIT_METHOD_CALL                                         !0, 'internal_is_callable'
         12        DO_FCALL                                      0          
   21    13      > RETURN                                                   1

Class obj:
Function protected_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fLaYN
function name:  protected_function
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   <true>
    6     1*     > RETURN                                                   null

End of function protected_function

Function internal_is_callable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fLaYN
function name:  internal_is_callable
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'is_callable'
          2        FETCH_THIS                                       ~0      
          3        INIT_ARRAY                                       ~1      ~0
          4        ADD_ARRAY_ELEMENT                                ~1      'protected_function'
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   10     9      > RETURN                                                   null

End of function internal_is_callable

End of class obj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.5 ms | 1002 KiB | 15 Q