3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LOL{ const FOO = 1; } $x = new LOL; $arr = array('x' => $x); echo $x::FOO; // works echo $arr['x']::FOO; // works too class WWW{ protected $lol; public function __construct($lol){ $this->lol= $lol; } public function doSMth(){ $lol = $this->lol; echo $lol::FOO; // fail. parse error.. wtf } } $w = new WWW($x); $w->doSMth();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YECbc
function name:  (null)
number of ops:  19
compiled vars:  !0 = $x, !1 = $arr, !2 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $3      'LOL'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    9     3        INIT_ARRAY                                       ~6      !0, 'x'
          4        ASSIGN                                                   !1, ~6
   11     5        FETCH_CLASS                                   0  $8      !0
          6        FETCH_CLASS_CONSTANT                             ~9      $8, 'FOO'
          7        ECHO                                                     ~9
   12     8        FETCH_DIM_R                                      ~10     !1, 'x'
          9        FETCH_CLASS                                   0  $11     ~10
         10        FETCH_CLASS_CONSTANT                             ~12     $11, 'FOO'
         11        ECHO                                                     ~12
   27    12        NEW                                              $13     'WWW'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !2, $13
   28    16        INIT_METHOD_CALL                                         !2, 'doSMth'
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Class LOL: [no user functions]
Class WWW:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YECbc
function name:  __construct
number of ops:  4
compiled vars:  !0 = $lol
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        ASSIGN_OBJ                                               'lol'
          2        OP_DATA                                                  !0
   19     3      > RETURN                                                   null

End of function __construct

Function dosmth:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YECbc
function name:  doSMth
number of ops:  6
compiled vars:  !0 = $lol
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~1      'lol'
          1        ASSIGN                                                   !0, ~1
   23     2        FETCH_CLASS                                   0  $3      !0
          3        FETCH_CLASS_CONSTANT                             ~4      $3, 'FOO'
          4        ECHO                                                     ~4
   24     5      > RETURN                                                   null

End of function dosmth

End of class WWW.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.9 ms | 1395 KiB | 13 Q