3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { function bar(callable $callable) { $callable($this); } function printStr() { echo "hi"; } } $foo = new foo(); $foo->bar(function ($that) { $that->printStr(); // Using $this when not in object context });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbnNH
function name:  (null)
number of ops:  8
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $1      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   14     3        INIT_METHOD_CALL                                         !0, 'bar'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVbnNH%3A14%240'
   16     5        SEND_VAL_EX                                              ~4
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FVbnNH%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbnNH
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $that
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_METHOD_CALL                                         !0, 'printStr'
          2        DO_FCALL                                      0          
   16     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVbnNH%3A14%240

Class foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbnNH
function name:  bar
number of ops:  6
compiled vars:  !0 = $callable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_DYNAMIC_CALL                                        !0
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        DO_FCALL                                      0          
    6     5      > RETURN                                                   null

End of function bar

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

End of function printstr

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.29 ms | 1399 KiB | 13 Q