3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BaseController { } class UserController extends BaseController { public static $get; public function get($id) { echo "Get: $id"; } public static function init() { $r = new ReflectionClass(static::class); $methods = $r->getMethods(ReflectionMethod::IS_PUBLIC); $props = $r->getStaticProperties(); var_dump($props); foreach ($methods as $method) { $prop = $method->name; if (in_array($prop, $props)) { static::$$prop = 'foo'; } } } } UserController::init(); echo UserController::$get;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ItQq4
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_STATIC_METHOD_CALL                                  'UserController', 'init'
          1        DO_FCALL                                      0          
   30     2        FETCH_STATIC_PROP_R          unknown             ~1      'get'
          3        ECHO                                                     ~1
          4      > RETURN                                                   1

Class BaseController: [no user functions]
Class UserController:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ItQq4
function name:  get
number of ops:  5
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'Get%3A+', !0
          3        ECHO                                                     ~1
   12     4      > RETURN                                                   null

End of function get

Function init:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 26
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/ItQq4
function name:  init
number of ops:  29
compiled vars:  !0 = $r, !1 = $methods, !2 = $props, !3 = $method, !4 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $5      'ReflectionClass'
          1        FETCH_CLASS_NAME                                 ~6      
          2        SEND_VAL_EX                                              ~6
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $5
   16     5        INIT_METHOD_CALL                                         !0, 'getMethods'
          6        SEND_VAL_EX                                              1
          7        DO_FCALL                                      0  $9      
          8        ASSIGN                                                   !1, $9
   17     9        INIT_METHOD_CALL                                         !0, 'getStaticProperties'
         10        DO_FCALL                                      0  $11     
         11        ASSIGN                                                   !2, $11
   18    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                                 
   19    15      > FE_RESET_R                                       $14     !1, ->27
         16    > > FE_FETCH_R                                               $14, !3, ->27
   20    17    >   FETCH_OBJ_R                                      ~15     !3, 'name'
         18        ASSIGN                                                   !4, ~15
   21    19        INIT_FCALL                                               'in_array'
         20        SEND_VAR                                                 !4
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $17     
         23      > JMPZ                                                     $17, ->26
   22    24    >   ASSIGN_STATIC_PROP                                       !4
         25        OP_DATA                                                  'foo'
   19    26    > > JMP                                                      ->16
         27    >   FE_FREE                                                  $14
   25    28      > RETURN                                                   null

End of function init

End of class UserController.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.35 ms | 1392 KiB | 17 Q