3v4l.org

run code in 300+ PHP versions simultaneously
<?php class P { function r($o,$p) { if($v=get_object_vars($o)&&@$v=$v[$p]) return$v; $m=['set','get','has','is','_']; do { if($s=get_class_methods($o)&&in_array($a=current($m).$p,$s))return$o->$a(); } while(next($m)); throw new Exception(); } } class A { private $a = 'hello'; protected function getA() { return $this->a; } } $a = new A(); $p = new P(); echo $p->r($a, 'a');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WhlCE
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a, !1 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $2      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   28     3        NEW                                              $5      'P'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   30     6        INIT_METHOD_CALL                                         !1, 'r'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAL_EX                                              'a'
          9        DO_FCALL                                      0  $8      
         10        ECHO                                                     $8
         11      > RETURN                                                   1

Class P:
Function r:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 15
Branch analysis from position: 38
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 29
Branch analysis from position: 11
filename:       /in/WhlCE
function name:  r
number of ops:  42
compiled vars:  !0 = $o, !1 = $p, !2 = $v, !3 = $m, !4 = $s, !5 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'get_object_vars'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5      > JMPZ_EX                                          ~7      $6, ->11
          6    >   BEGIN_SILENCE                                    ~8      
          7        FETCH_DIM_R                                      ~9      !2, !1
          8        ASSIGN                                           ~10     !2, ~9
          9        END_SILENCE                                              ~8
         10        BOOL                                             ~7      ~10
         11    >   ASSIGN                                           ~11     !2, ~7
         12      > JMPZ                                                     ~11, ->14
    8    13    > > RETURN                                                   !2
   10    14    >   ASSIGN                                                   !3, <array>
   13    15    >   INIT_FCALL                                               'get_class_methods'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $13     
         18      > JMPZ_EX                                          ~14     $13, ->29
         19    >   INIT_FCALL                                               'in_array'
         20        INIT_FCALL                                               'current'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $15     
         23        CONCAT                                           ~16     $15, !1
         24        ASSIGN                                           ~17     !5, ~16
         25        SEND_VAL                                                 ~17
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                         $18     
         28        BOOL                                             ~14     $18
         29    >   ASSIGN                                           ~19     !4, ~14
         30      > JMPZ                                                     ~19, ->34
         31    >   INIT_METHOD_CALL                                         !0, !5
         32        DO_FCALL                                      0  $20     
         33      > RETURN                                                   $20
   14    34    >   INIT_FCALL                                               'next'
         35        SEND_REF                                                 !3
         36        DO_ICALL                                         $21     
         37      > JMPNZ                                                    $21, ->15
   16    38    >   NEW                                              $22     'Exception'
         39        DO_FCALL                                      0          
         40      > THROW                                         0          $22
   17    41*     > RETURN                                                   null

End of function r

End of class P.

Class A:
Function geta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WhlCE
function name:  getA
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function geta

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.19 ms | 1400 KiB | 23 Q