3v4l.org

run code in 300+ PHP versions simultaneously
<?php // define the common interface interface StorageInterface { function store($key, $value); function retrieve($key); } // implement functionality common to descendants abstract class Storage implements StorageInterface { protected function normalizeKey($key) { return $normalizedKey; } protected function someOtherUtilityFunction() {} } // concrete implementations class S3 extends Storage { protected $backend; public function __construct(S3object $backend) { $this->backend = $backend; } public function store($key, $value) {} public function retrieve($key) {} } class DBX extends Storage { protected $backend; public function __construct(DBXobject $backend) { $this->backend = $backend; } public function store($key, $value) {} public function retrieve($key) {} } // maybe GCS is a completely different beast and can't/shouldn't descend from Storage class GoogleCloudStorage implements StorageInterface { protected $backend; public function __construct(GCSobject $backend) { $this->backend = $backend; } public function store($key, $value) {} public function retrieve($key) {} } // so long as the object implements the interface we don't care about its parentage class MyThingThatNeedsStorage { public function __construct(StorageInterface $storage) {} public function doSomething() { $this->storage->retrieve('foo'); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rcam4
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                            'storage'
   18     1        DECLARE_CLASS                                            's3', 'storage'
   26     2        DECLARE_CLASS                                            'dbx', 'storage'
   36     3        DECLARE_CLASS                                            'googlecloudstorage'
   51     4      > RETURN                                                   1

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

End of function store

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

End of function retrieve

End of class StorageInterface.

Class Storage:
Function normalizekey:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rcam4
function name:  normalizeKey
number of ops:  3
compiled vars:  !0 = $key, !1 = $normalizedKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1      > RETURN                                                   !1
   12     2*     > RETURN                                                   null

End of function normalizekey

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

End of function someotherutilityfunction

End of class Storage.

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

End of function __construct

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

End of function store

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

End of function retrieve

End of class S3.

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

End of function __construct

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

End of function store

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

End of function retrieve

End of class DBX.

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

End of function __construct

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

End of function store

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

End of function retrieve

End of class GoogleCloudStorage.

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

End of function __construct

Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rcam4
function name:  doSomething
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   FETCH_OBJ_R                                      ~0      'storage'
          1        INIT_METHOD_CALL                                         ~0, 'retrieve'
          2        SEND_VAL_EX                                              'foo'
          3        DO_FCALL                                      0          
   50     4      > RETURN                                                   null

End of function dosomething

End of class MyThingThatNeedsStorage.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.09 ms | 1403 KiB | 13 Q