3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $x; public function __construct($v) { $this->x = $v; } public function get() { return $this->work(function() { return $this->increment(); }); } public function increment() { return $this->x++; } public function work($callback) { return $callback(); } public function getX() { return $this->x; } } $a = new A(1); $b = $a->get(); var_dump($a->getX());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bfLnM
function name:  (null)
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $2      'A'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   26     4        INIT_METHOD_CALL                                         !0, 'get'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   27     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !0, 'getX'
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FbfLnM%3A11%240

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bfLnM
function name:  __construct
number of ops:  4
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'x'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bfLnM
function name:  get
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_METHOD_CALL                                         'work'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FbfLnM%3A11%240'
          2        SEND_VAL_EX                                              ~0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   12     5*     > RETURN                                                   null

End of function get

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

End of function increment

Function work:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bfLnM
function name:  work
number of ops:  5
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   20     4*     > RETURN                                                   null

End of function work

Function getx:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bfLnM
function name:  getX
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~0      'x'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function getx

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.17 ms | 1400 KiB | 15 Q