3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ex extends \ReflectionException { public $reflector; public function __construct($reflector, $message = '', \Exception $previous = null) { parent::__construct($message, 0, $previous); $this->reflector = $reflector; } } class A { private $private = 'private'; public $public = 'public'; public static $static = 'static'; public function privateMethod() { } } class B { private $private = 'private'; public $public = 'public'; } class C extends \ReflectionClass { public function __construct($name) { try { parent::__construct($name); } catch (\Exception $e) { throw new Ex($this, $e->getMessage(), $e); } } } $r = new \ReflectionClass('A'); $p = $r->getProperty('static'); $p->getSetValue('bla', 'bla'); die(); //$p->setAccessible(true); //$p->setAccessible(false); try { $p->invoke(new A()); } catch (\ReflectionException $e) { var_dump($e->getCode()); } die(); $c = new B(); $p->setValue($c, 'b'); var_dump($p->getValue(new stdClass())); //$p = $r->getProperty('public'); //$p->setAccessible(false); //var_dump($p->getValue(true));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
Found catch point at position: 19
Branch analysis from position: 19
2 jumps found. (Code = 107) Position 1 = 20, Position 2 = -2
Branch analysis from position: 20
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/dYcZF
function name:  (null)
number of ops:  42
compiled vars:  !0 = $r, !1 = $p, !2 = $e, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   NEW                                              $4      'ReflectionClass'
          1        SEND_VAL_EX                                              'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
   48     4        INIT_METHOD_CALL                                         !0, 'getProperty'
          5        SEND_VAL_EX                                              'static'
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !1, $7
   49     8        INIT_METHOD_CALL                                         !1, 'getSetValue'
          9        SEND_VAL_EX                                              'bla'
         10        SEND_VAL_EX                                              'bla'
         11        DO_FCALL                                      0          
   50    12      > EXIT                                                     
   55    13*       INIT_METHOD_CALL                                         !1, 'invoke'
         14*       NEW                                              $10     'A'
         15*       DO_FCALL                                      0          
         16*       SEND_VAR_NO_REF_EX                                       $10
         17*       DO_FCALL                                      0          
         18*       JMP                                                      ->25
   56    19  E > > CATCH                                       last         'ReflectionException'
   57    20    >   INIT_FCALL                                               'var_dump'
         21        INIT_METHOD_CALL                                         !2, 'getCode'
         22        DO_FCALL                                      0  $13     
         23        SEND_VAR                                                 $13
         24        DO_ICALL                                                 
   60    25      > EXIT                                                     
   62    26*       NEW                                              $15     'B'
         27*       DO_FCALL                                      0          
         28*       ASSIGN                                                   !3, $15
   63    29*       INIT_METHOD_CALL                                         !1, 'setValue'
         30*       SEND_VAR_EX                                              !3
         31*       SEND_VAL_EX                                              'b'
         32*       DO_FCALL                                      0          
   64    33*       INIT_FCALL                                               'var_dump'
         34*       INIT_METHOD_CALL                                         !1, 'getValue'
         35*       NEW                                              $19     'stdClass'
         36*       DO_FCALL                                      0          
         37*       SEND_VAR_NO_REF_EX                                       $19
         38*       DO_FCALL                                      0  $21     
         39*       SEND_VAR                                                 $21
         40*       DO_ICALL                                                 
   68    41*     > RETURN                                                   1

Class Ex:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dYcZF
function name:  __construct
number of ops:  11
compiled vars:  !0 = $reflector, !1 = $message, !2 = $previous
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
          2        RECV_INIT                                        !2      null
    9     3        INIT_STATIC_METHOD_CALL                                  
          4        SEND_VAR_EX                                              !1
          5        SEND_VAL_EX                                              0
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0          
   11     8        ASSIGN_OBJ                                               'reflector'
          9        OP_DATA                                                  !0
   12    10      > RETURN                                                   null

End of function __construct

End of class Ex.

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

End of function privatemethod

End of class A.

Class B: [no user functions]
Class C:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 5
Branch analysis from position: 5
2 jumps found. (Code = 107) Position 1 = 6, Position 2 = -2
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/dYcZF
function name:  __construct
number of ops:  16
compiled vars:  !0 = $name, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   38     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > JMP                                                      ->15
   39     5  E > > CATCH                                       last         'Exception'
   40     6    >   NEW                                              $3      'Ex'
          7        FETCH_THIS                                       $4      
          8        SEND_VAR_EX                                              $4
          9        INIT_METHOD_CALL                                         !1, 'getMessage'
         10        DO_FCALL                                      0  $5      
         11        SEND_VAR_NO_REF_EX                                       $5
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $3
   42    15    > > RETURN                                                   null

End of function __construct

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.04 ms | 1400 KiB | 15 Q