3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function publicMethod() { return TestOther::store(function() { return $this->privateMethod(); }); } private function privateMethod() { return 'works'; } } class TestOther { public static function store(callable $function) { return $function; } } $test = new Test; $testFunction = $test->publicMethod(); echo $testFunction();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cmfrn
function name:  (null)
number of ops:  10
compiled vars:  !0 = $test, !1 = $testFunction
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $2      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   27     3        INIT_METHOD_CALL                                         !0, 'publicMethod'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   28     6        INIT_DYNAMIC_CALL                                        !1
          7        DO_FCALL                                      0  $7      
          8        ECHO                                                     $7
          9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FCmfrn%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cmfrn
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_THIS                                       $0      
          1        INIT_METHOD_CALL                                         $0, 'privateMethod'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
    9     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCmfrn%3A7%240

Class Test:
Function publicmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cmfrn
function name:  publicMethod
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_STATIC_METHOD_CALL                                  'TestOther', 'store'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCmfrn%3A7%240'
    9     2        SEND_VAL_EX                                              ~0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   10     5*     > RETURN                                                   null

End of function publicmethod

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

End of function privatemethod

End of class Test.

Class TestOther:
Function store:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cmfrn
function name:  store
number of ops:  3
compiled vars:  !0 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1      > RETURN                                                   !0
   22     2*     > RETURN                                                   null

End of function store

End of class TestOther.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.24 ms | 944 KiB | 14 Q