3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CachingProxy { private $cache = null; private $instance = null; public function __construct(Memcache $cache, $instance) { $this->cache = $cache; $this->instance = $instance; } public function __call($method, $arguments) { var_dump($method, $arguments); die; if (substr($method, 0, 3) !== 'get') { $result = call_user_func_array($method, $arguments); } else { $uniqueId = $method . serialize($arguments); $result = $this->cache->get($uniqueId); if ($result === false) { $result = call_user_func_array($method, $arguments); $this->cache->set($uniqueId, $result); } } return $result; } } class Memcache { private $data = []; public function set($key, $value) { $this->data[$key] = $value; } public function get($key) { return isset($this->data[$key]) ? $this->data[$key] : false; } } class ImportantService { } $service = new ImportantService(); $cachedService = new CachingProxy($memcacheInstance, $service); $result = $cachedService->getInformation(123); // First call goes to a data source $more = $cachedService->getInformation(123); // From cache now
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dNV6g
function name:  (null)
number of ops:  17
compiled vars:  !0 = $service, !1 = $cachedService, !2 = $memcacheInstance, !3 = $result, !4 = $more
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   NEW                                              $5      'ImportantService'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   49     3        NEW                                              $8      'CachingProxy'
          4        SEND_VAR_EX                                              !2
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $8
   51     8        INIT_METHOD_CALL                                         !1, 'getInformation'
          9        SEND_VAL_EX                                              123
         10        DO_FCALL                                      0  $11     
         11        ASSIGN                                                   !3, $11
   52    12        INIT_METHOD_CALL                                         !1, 'getInformation'
         13        SEND_VAL_EX                                              123
         14        DO_FCALL                                      0  $13     
         15        ASSIGN                                                   !4, $13
         16      > RETURN                                                   1

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

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/dNV6g
function name:  __call
number of ops:  44
compiled vars:  !0 = $method, !1 = $arguments, !2 = $result, !3 = $uniqueId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        INIT_FCALL                                               'var_dump'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
          6      > EXIT                                                     
   17     7*       INIT_FCALL                                               'substr'
          8*       SEND_VAR                                                 !0
          9*       SEND_VAL                                                 0
         10*       SEND_VAL                                                 3
         11*       DO_ICALL                                         $5      
         12*       IS_NOT_IDENTICAL                                         $5, 'get'
         13*       JMPZ                                                     ~6, ->20
   18    14*       INIT_USER_CALL                                0          'call_user_func_array', !0
         15*       SEND_ARRAY                                               !1
         16*       CHECK_UNDEF_ARGS                                         
         17*       DO_FCALL                                      0  $7      
         18*       ASSIGN                                                   !2, $7
         19*       JMP                                                      ->42
   20    20*       INIT_FCALL                                               'serialize'
         21*       SEND_VAR                                                 !1
         22*       DO_ICALL                                         $9      
         23*       CONCAT                                           ~10     !0, $9
         24*       ASSIGN                                                   !3, ~10
   21    25*       FETCH_OBJ_R                                      ~12     'cache'
         26*       INIT_METHOD_CALL                                         ~12, 'get'
         27*       SEND_VAR_EX                                              !3
         28*       DO_FCALL                                      0  $13     
         29*       ASSIGN                                                   !2, $13
   22    30*       TYPE_CHECK                                    4          !2
         31*       JMPZ                                                     ~15, ->42
   23    32*       INIT_USER_CALL                                0          'call_user_func_array', !0
         33*       SEND_ARRAY                                               !1
         34*       CHECK_UNDEF_ARGS                                         
         35*       DO_FCALL                                      0  $16     
         36*       ASSIGN                                                   !2, $16
   24    37*       FETCH_OBJ_R                                      ~18     'cache'
         38*       INIT_METHOD_CALL                                         ~18, 'set'
         39*       SEND_VAR_EX                                              !3
         40*       SEND_VAR_EX                                              !2
         41*       DO_FCALL                                      0          
   28    42*       RETURN                                                   !2
   29    43*     > RETURN                                                   null

End of function __call

End of class CachingProxy.

Class Memcache:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dNV6g
function name:  set
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   36     2        FETCH_OBJ_W                                      $2      'data'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   37     5      > RETURN                                                   null

End of function set

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dNV6g
function name:  get
number of ops:  11
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   40     1        FETCH_OBJ_IS                                     ~1      'data'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      'data'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      <false>
          9    > > RETURN                                                   ~5
   41    10*     > RETURN                                                   null

End of function get

End of class Memcache.

Class ImportantService: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.65 ms | 1404 KiB | 19 Q