3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace NS1 { class c1 { public function __construct(\NS2\c1 $c1) { } } } namespace NS2 { class c1 { public function __construct() { } } } namespace Foo { error_reporting(E_ALL); ini_seT('display_errors', 'on'); $r = new ReflectionClass('\NS1\c1'); echo $r->getName(); echo '<br />'; echo $r->getConstructor()->getParameters()[0]->getClass()->getName(); die; class Kitchen { private $yummy = 'cake'; } $sweetsThief = function (\Dice\Dice $kitchen) { return $kitchen->cache; }; $dice = new \Dice\Dice; $sweetsThief = Closure::bind($sweetsThief, null, $dice); var_dump($sweetsThief($dice)); class MyCache implements ArrayAccess { private $array = []; public function offsetGet($offset) { return $this->array[$offset]; } public function offsetSet($offset, $value) { $this->array[$offset] = $value; } public function offsetExists() { } } class Cached { private $dice; public function __construct(ArrayAccess $cache = null) { if (isset($cache['dice'])) { $this->dice = $this->cache['dice']; } else $this->dice = new Dice; } public function __destruct() { $clearInstances = function() { $this->instances = []; }; $clearInstances = $clearInstances->bindTo($this->dice, $this->dice); $clearInstances(); $this->cahe['dice'] = $this->dice; } } $a2 = $dice->create('A2', array($dice->create('ExtendedB'), 'Foo')); $cache = new Cached($dice); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/0keil
function name:  (null)
number of ops:  60
compiled vars:  !0 = $r, !1 = $sweetsThief, !2 = $dice, !3 = $a2, !4 = $cache
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_NS_FCALL_BY_NAME                                    'Foo%5Cerror_reporting'
          1        FETCH_CONSTANT                                   ~5      'Foo%5CE_ALL'
          2        SEND_VAL_EX                                              ~5
          3        DO_FCALL                                      0          
   22     4        INIT_NS_FCALL_BY_NAME                                    'Foo%5Cini_seT'
          5        SEND_VAL_EX                                              'display_errors'
          6        SEND_VAL_EX                                              'on'
          7        DO_FCALL                                      0          
   23     8        NEW                                              $8      'Foo%5CReflectionClass'
          9        SEND_VAL_EX                                              '%5CNS1%5Cc1'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !0, $8
   25    12        INIT_METHOD_CALL                                         !0, 'getName'
         13        DO_FCALL                                      0  $11     
         14        ECHO                                                     $11
   26    15        ECHO                                                     '%3Cbr+%2F%3E'
   27    16        INIT_METHOD_CALL                                         !0, 'getConstructor'
         17        DO_FCALL                                      0  $12     
         18        INIT_METHOD_CALL                                         $12, 'getParameters'
         19        DO_FCALL                                      0  $13     
         20        FETCH_DIM_R                                      ~14     $13, 0
         21        INIT_METHOD_CALL                                         ~14, 'getClass'
         22        DO_FCALL                                      0  $15     
         23        INIT_METHOD_CALL                                         $15, 'getName'
         24        DO_FCALL                                      0  $16     
         25        ECHO                                                     $16
   30    26      > EXIT                                                     
   37    27*       DECLARE_LAMBDA_FUNCTION                                  '%00foo%5C%7Bclosure%7D%2Fin%2F0keil%3A37%240'
         28*       ASSIGN                                                   !1, ~17
   41    29*       NEW                                              $19     'Dice%5CDice'
         30*       DO_FCALL                                      0          
         31*       ASSIGN                                                   !2, $19
   43    32*       INIT_STATIC_METHOD_CALL                                  'Foo%5CClosure', 'bind'
         33*       SEND_VAR_EX                                              !1
         34*       SEND_VAL_EX                                              null
         35*       SEND_VAR_EX                                              !2
         36*       DO_FCALL                                      0  $22     
         37*       ASSIGN                                                   !1, $22
   45    38*       INIT_NS_FCALL_BY_NAME                                    'Foo%5Cvar_dump'
         39*       INIT_DYNAMIC_CALL                                        !1
         40*       SEND_VAR_EX                                              !2
         41*       DO_FCALL                                      0  $24     
         42*       SEND_VAR_NO_REF_EX                                       $24
         43*       DO_FCALL                                      0          
   47    44*       DECLARE_CLASS                                            'foo%5Cmycache'
   87    45*       INIT_METHOD_CALL                                         !2, 'create'
         46*       SEND_VAL_EX                                              'A2'
         47*       INIT_METHOD_CALL                                         !2, 'create'
         48*       SEND_VAL_EX                                              'ExtendedB'
         49*       DO_FCALL                                      0  $26     
         50*       INIT_ARRAY                                       ~27     $26
         51*       ADD_ARRAY_ELEMENT                                ~27     'Foo'
         52*       SEND_VAL_EX                                              ~27
         53*       DO_FCALL                                      0  $28     
         54*       ASSIGN                                                   !3, $28
   90    55*       NEW                                              $30     'Foo%5CCached'
         56*       SEND_VAR_EX                                              !2
         57*       DO_FCALL                                      0          
         58*       ASSIGN                                                   !4, $30
   92    59*     > RETURN                                                   1

Function %00foo%5C%7Bclosure%7D%2Fin%2F0keil%3A37%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0keil
function name:  Foo\{closure}
number of ops:  4
compiled vars:  !0 = $kitchen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        FETCH_OBJ_R                                      ~1      !0, 'cache'
          2      > RETURN                                                   ~1
   39     3*     > RETURN                                                   null

End of function %00foo%5C%7Bclosure%7D%2Fin%2F0keil%3A37%240

Function %00foo%5C%7Bclosure%7D%2Fin%2F0keil%3A74%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0keil
function name:  Foo\{closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   FETCH_THIS                                       $0      
          1        ASSIGN_OBJ                                               $0, 'instances'
          2        OP_DATA                                                  <array>
   76     3      > RETURN                                                   null

End of function %00foo%5C%7Bclosure%7D%2Fin%2F0keil%3A74%242

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

End of function __construct

End of class NS1\c1.

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

End of function __construct

End of class NS2\c1.

Class Foo\Kitchen: [no user functions]
Class Foo\MyCache:
Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0keil
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
   51     1        FETCH_OBJ_R                                      ~1      'array'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   52     4*     > RETURN                                                   null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0keil
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   55     2        FETCH_OBJ_W                                      $2      'array'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   56     5      > RETURN                                                   null

End of function offsetset

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

End of function offsetexists

End of class Foo\MyCache.

Class Foo\Cached:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0keil
function name:  __construct
number of ops:  13
compiled vars:  !0 = $cache
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   RECV_INIT                                        !0      null
   67     1        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'dice'
          2      > JMPZ                                                     ~1, ->8
   68     3    >   FETCH_OBJ_R                                      ~3      'cache'
          4        FETCH_DIM_R                                      ~4      ~3, 'dice'
          5        ASSIGN_OBJ                                               'dice'
          6        OP_DATA                                                  ~4
          7      > JMP                                                      ->12
   70     8    >   NEW                                              $6      'Foo%5CDice'
          9        DO_FCALL                                      0          
         10        ASSIGN_OBJ                                               'dice'
         11        OP_DATA                                                  $6
   71    12    > > RETURN                                                   null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0keil
function name:  __destruct
number of ops:  18
compiled vars:  !0 = $clearInstances
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00foo%5C%7Bclosure%7D%2Fin%2F0keil%3A74%242'
          1        ASSIGN                                                   !0, ~1
   78     2        INIT_METHOD_CALL                                         !0, 'bindTo'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $3      'dice'
          5        SEND_FUNC_ARG                                            $3
          6        CHECK_FUNC_ARG                                           
          7        FETCH_OBJ_FUNC_ARG                               $4      'dice'
          8        SEND_FUNC_ARG                                            $4
          9        DO_FCALL                                      0  $5      
         10        ASSIGN                                                   !0, $5
   79    11        INIT_DYNAMIC_CALL                                        !0
         12        DO_FCALL                                      0          
   81    13        FETCH_OBJ_R                                      ~10     'dice'
         14        FETCH_OBJ_W                                      $8      'cahe'
         15        ASSIGN_DIM                                               $8, 'dice'
         16        OP_DATA                                                  ~10
   82    17      > RETURN                                                   null

End of function __destruct

End of class Foo\Cached.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.13 ms | 1411 KiB | 18 Q