3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Controller { protected $wrapped = []; public function abc($request) { // did we wrap this yet? if (! isset($this->wrapped['abc'])) { // if not, do it now. this will only happen once (unless you clear it out). $this->wrapped['abc'] = $this->wrap( function ($request) { return "abc\n"; } ); } // invoke and return. return $this->wrapped['abc']($request); } protected function wrap(callable $inner_controller) { return function($request) use ($inner_controller) { // stuff $response = $inner_controller($request); // stuff return $response; }; } } $ctrl = new Controller(); echo $ctrl->abc('the request');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4uej
function name:  (null)
number of ops:  8
compiled vars:  !0 = $ctrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $1      'Controller'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   33     3        INIT_METHOD_CALL                                         !0, 'abc'
          4        SEND_VAL_EX                                              'the+request'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
          7      > RETURN                                                   1

Class Controller:
Function abc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/h4uej
function name:  abc
number of ops:  19
compiled vars:  !0 = $request
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        FETCH_OBJ_IS                                     ~1      'wrapped'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, 'abc'
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->12
   11     5    >   INIT_METHOD_CALL                                         'wrap'
   12     6        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
   14     7        SEND_VAL_EX                                              ~6
   11     8        DO_FCALL                                      0  $7      
          9        FETCH_OBJ_W                                      $4      'wrapped'
         10        ASSIGN_DIM                                               $4, 'abc'
   14    11        OP_DATA                                                  $7
   18    12    >   FETCH_OBJ_R                                      ~8      'wrapped'
         13        FETCH_DIM_R                                      ~9      ~8, 'abc'
         14        INIT_DYNAMIC_CALL                                        ~9
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $10     
         17      > RETURN                                                   $10
   19    18*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4uej
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $request
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1      > RETURN                                                   'abc%0A'
   14     2*     > RETURN                                                   null

End of Dynamic Function 0

End of function abc

Function wrap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4uej
function name:  wrap
number of ops:  5
compiled vars:  !0 = $inner_controller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          2        BIND_LEXICAL                                             ~1, !0
   27     3      > RETURN                                                   ~1
   28     4*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4uej
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $request, !1 = $inner_controller, !2 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   24     2        INIT_DYNAMIC_CALL                                        !1
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !2, $3
   26     6      > RETURN                                                   !2
   27     7*     > RETURN                                                   null

End of Dynamic Function 0

End of function wrap

End of class Controller.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.59 ms | 1453 KiB | 13 Q