3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SecureData { private $priv="my-private-value"; protected $prot="my-protected-value"; } function expose($obj, $attr_name) { $a = (array)$obj; $r = new ReflectionProperty($obj, $attr_name); if ($r->isPrivate()) return $a["\0".get_class($obj)."\0".$attr_name]; elseif ($r->isProtected()) return $a["\0*\0".$attr_name]; else return $obj->$attr_name; } $c = new SecureData; echo expose($c, 'priv'); # => my-private-value echo expose($c, 'prot'); # => my-protected-value
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uU01E
function name:  (null)
number of ops:  14
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $1      'SecureData'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   19     3        INIT_FCALL                                               'expose'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'priv'
          6        DO_FCALL                                      0  $4      
          7        ECHO                                                     $4
   20     8        INIT_FCALL                                               'expose'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 'prot'
         11        DO_FCALL                                      0  $5      
         12        ECHO                                                     $5
         13      > RETURN                                                   1

Function expose:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uU01E
function name:  expose
number of ops:  29
compiled vars:  !0 = $obj, !1 = $attr_name, !2 = $a, !3 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        CAST                                          7  ~4      !0
          3        ASSIGN                                                   !2, ~4
    9     4        NEW                                              $6      'ReflectionProperty'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !3, $6
   10     9        INIT_METHOD_CALL                                         !3, 'isPrivate'
         10        DO_FCALL                                      0  $9      
         11      > JMPZ                                                     $9, ->19
   11    12    >   GET_CLASS                                        ~10     !0
         13        CONCAT                                           ~11     '%00', ~10
         14        CONCAT                                           ~12     ~11, '%00'
         15        CONCAT                                           ~13     ~12, !1
         16        FETCH_DIM_R                                      ~14     !2, ~13
         17      > RETURN                                                   ~14
         18*       JMP                                                      ->28
   12    19    >   INIT_METHOD_CALL                                         !3, 'isProtected'
         20        DO_FCALL                                      0  $15     
         21      > JMPZ                                                     $15, ->26
   13    22    >   CONCAT                                           ~16     '%00%2A%00', !1
         23        FETCH_DIM_R                                      ~17     !2, ~16
         24      > RETURN                                                   ~17
         25*       JMP                                                      ->28
   15    26    >   FETCH_OBJ_R                                      ~18     !0, !1
         27      > RETURN                                                   ~18
   16    28*     > RETURN                                                   null

End of function expose

Class SecureData: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
189.95 ms | 1394 KiB | 15 Q