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) { 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 ImportantService { public function getInformation($uniqueIdentifier) { echo 'banana'; } } $cachedService = new CachingProxy(new Memcache(), new ImportantService()); $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/SFek6
function name:  (null)
number of ops:  18
compiled vars:  !0 = $cachedService, !1 = $result, !2 = $more
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   NEW                                              $3      'CachingProxy'
          1        NEW                                              $4      'Memcache'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $4
          4        NEW                                              $6      'ImportantService'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $6
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $3
   41     9        INIT_METHOD_CALL                                         !0, 'getInformation'
         10        SEND_VAL_EX                                              123
         11        DO_FCALL                                      0  $10     
         12        ASSIGN                                                   !1, $10
   42    13        INIT_METHOD_CALL                                         !0, 'getInformation'
         14        SEND_VAL_EX                                              123
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !2, $12
         17      > RETURN                                                   1

Class CachingProxy:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SFek6
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
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 37
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/SFek6
function name:  __call
number of ops:  39
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                                               'substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 3
          6        DO_ICALL                                         $4      
          7        IS_NOT_IDENTICAL                                         $4, 'get'
          8      > JMPZ                                                     ~5, ->15
   17     9    >   INIT_USER_CALL                                0          'call_user_func_array', !0
         10        SEND_ARRAY                                               !1
         11        CHECK_UNDEF_ARGS                                         
         12        DO_FCALL                                      0  $6      
         13        ASSIGN                                                   !2, $6
         14      > JMP                                                      ->37
   19    15    >   INIT_FCALL                                               'serialize'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $8      
         18        CONCAT                                           ~9      !0, $8
         19        ASSIGN                                                   !3, ~9
   20    20        FETCH_OBJ_R                                      ~11     'cache'
         21        INIT_METHOD_CALL                                         ~11, 'get'
         22        SEND_VAR_EX                                              !3
         23        DO_FCALL                                      0  $12     
         24        ASSIGN                                                   !2, $12
   21    25        TYPE_CHECK                                    4          !2
         26      > JMPZ                                                     ~14, ->37
   22    27    >   INIT_USER_CALL                                0          'call_user_func_array', !0
         28        SEND_ARRAY                                               !1
         29        CHECK_UNDEF_ARGS                                         
         30        DO_FCALL                                      0  $15     
         31        ASSIGN                                                   !2, $15
   23    32        FETCH_OBJ_R                                      ~17     'cache'
         33        INIT_METHOD_CALL                                         ~17, 'set'
         34        SEND_VAR_EX                                              !3
         35        SEND_VAR_EX                                              !2
         36        DO_FCALL                                      0          
   27    37    > > RETURN                                                   !2
   28    38*     > RETURN                                                   null

End of function __call

End of class CachingProxy.

Class ImportantService:
Function getinformation:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SFek6
function name:  getInformation
number of ops:  3
compiled vars:  !0 = $uniqueIdentifier
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   35     1        ECHO                                                     'banana'
   36     2      > RETURN                                                   null

End of function getinformation

End of class ImportantService.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.72 ms | 1400 KiB | 17 Q