3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public static $map = [ 'lolo' => 'Foo', ]; public static function get($vars, $params) { return new self::$map[$varrs]($params); } } class Foo { public $r; public function __construct($r) { $this->r = $r; } } $varrs = 'lolo'; $params = 213123; $temp = Test::get($varrs, $params); var_dump($temp, $temp->r);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/invbg
function name:  (null)
number of ops:  13
compiled vars:  !0 = $varrs, !1 = $params, !2 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, 'lolo'
   23     1        ASSIGN                                                   !1, 213123
   26     2        INIT_STATIC_METHOD_CALL                                  'Test', 'get'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   28     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        FETCH_OBJ_R                                      ~7      !2, 'r'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class Test:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/invbg
function name:  get
number of ops:  10
compiled vars:  !0 = $vars, !1 = $params, !2 = $varrs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        FETCH_STATIC_PROP_R          unknown             ~3      'map'
          3        FETCH_DIM_R                                      ~4      ~3, !2
          4        FETCH_CLASS                                   0  $5      ~4
          5        NEW                                              $6      $5
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8      > RETURN                                                   $6
   11     9*     > RETURN                                                   null

End of function get

End of class Test.

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

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.72 ms | 1396 KiB | 15 Q