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'; private 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->getMethod('privateMethod'); //$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($c)); //$p = $r->getProperty('public'); //$p->setAccessible(false); //var_dump($p->getValue(true));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 79) Position 1 = -2
Found catch point at position: 14
Branch analysis from position: 14
2 jumps found. (Code = 107) Position 1 = 15, Position 2 = -2
Branch analysis from position: 15
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/l7FH3
function name:  (null)
number of ops:  35
compiled vars:  !0 = $r, !1 = $p, !2 = $e, !3 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   NEW                                              $4      'ReflectionClass'
          1        SEND_VAL_EX                                              'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
   46     4        INIT_METHOD_CALL                                         !0, 'getMethod'
          5        SEND_VAL_EX                                              'privateMethod'
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !1, $7
   51     8        INIT_METHOD_CALL                                         !1, 'invoke'
          9        NEW                                              $9      'A'
         10        DO_FCALL                                      0          
         11        SEND_VAR_NO_REF_EX                                       $9
         12        DO_FCALL                                      0          
         13      > JMP                                                      ->20
   52    14  E > > CATCH                                       last         'ReflectionException'
   53    15    >   INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !2, 'getCode'
         17        DO_FCALL                                      0  $12     
         18        SEND_VAR                                                 $12
         19        DO_ICALL                                                 
   56    20    > > EXIT                                                     
   58    21*       NEW                                              $14     'B'
         22*       DO_FCALL                                      0          
         23*       ASSIGN                                                   !3, $14
   59    24*       INIT_METHOD_CALL                                         !1, 'setValue'
         25*       SEND_VAR_EX                                              !3
         26*       SEND_VAL_EX                                              'b'
         27*       DO_FCALL                                      0          
   60    28*       INIT_FCALL                                               'var_dump'
         29*       INIT_METHOD_CALL                                         !1, 'getValue'
         30*       SEND_VAR_EX                                              !3
         31*       DO_FCALL                                      0  $18     
         32*       SEND_VAR                                                 $18
         33*       DO_ICALL                                                 
   64    34*     > RETURN                                                   1

Class Ex:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l7FH3
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/l7FH3
function name:  privateMethod
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     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/l7FH3
function name:  __construct
number of ops:  16
compiled vars:  !0 = $name, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   36     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > JMP                                                      ->15
   37     5  E > > CATCH                                       last         'Exception'
   38     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
   40    15    > > RETURN                                                   null

End of function __construct

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.58 ms | 1400 KiB | 15 Q