3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Test { public function __construct(callable $foo) { // $this->cb is callable here var_dump(is_callable($foo)); } private function method() {} } $cb = [Test::class, 'method']; $obj = new Test($cb); // $obj->cb is NOT callable here var_dump(is_callable($cb));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Pl4ec
function name:  (null)
number of ops:  12
compiled vars:  !0 = $cb, !1 = $obj
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, <array>
   13     1        NEW                                                  $3      'Test'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !1, $3
   15     5        INIT_FCALL                                                   'var_dump'
          6        INIT_FCALL                                                   'is_callable'
          7        SEND_VAR                                                     !0
          8        DO_ICALL                                             $6      
          9        SEND_VAR                                                     $6
         10        DO_ICALL                                                     
         11      > RETURN                                                       1

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Pl4ec
function name:  __construct
number of ops:  8
compiled vars:  !0 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_FCALL                                                   'var_dump'
          2        INIT_FCALL                                                   'is_callable'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $1      
          5        SEND_VAR                                                     $1
          6        DO_ICALL                                                     
    6     7      > RETURN                                                       null

End of function __construct

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

End of function method

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.08 ms | 1584 KiB | 15 Q