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 { //public $private = 'pr'; private $public = 'pu'; } 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); //var_dump($p->invoke(new stdClass())); $p = $r->getProperty('public'); $p->setAccessible(false); var_dump($p->getValue());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L9ljF
function name:  (null)
number of ops:  27
compiled vars:  !0 = $r, !1 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   NEW                                              $2      'ReflectionClass'
          1        SEND_VAL_EX                                              'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   46     4        INIT_METHOD_CALL                                         !0, 'getMethod'
          5        SEND_VAL_EX                                              'privateMethod'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   47     8        INIT_METHOD_CALL                                         !1, 'setAccessible'
          9        SEND_VAL_EX                                              <true>
         10        DO_FCALL                                      0          
   48    11        INIT_METHOD_CALL                                         !1, 'setAccessible'
         12        SEND_VAL_EX                                              <false>
         13        DO_FCALL                                      0          
   51    14        INIT_METHOD_CALL                                         !0, 'getProperty'
         15        SEND_VAL_EX                                              'public'
         16        DO_FCALL                                      0  $9      
         17        ASSIGN                                                   !1, $9
   52    18        INIT_METHOD_CALL                                         !1, 'setAccessible'
         19        SEND_VAL_EX                                              <false>
         20        DO_FCALL                                      0          
   53    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !1, 'getValue'
         23        DO_FCALL                                      0  $12     
         24        SEND_VAR                                                 $12
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Class Ex:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/L9ljF
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/L9ljF
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/L9ljF
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:
155 ms | 1400 KiB | 15 Q