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(method_exists($o,$a=current($m).$p))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/PbM53
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 = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 15
Branch analysis from position: 32
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 11
filename:       /in/PbM53
function name:  r
number of ops:  36
compiled vars:  !0 = $o, !1 = $p, !2 = $v, !3 = $m, !4 = $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                                         $5      
          5      > JMPZ_EX                                          ~6      $5, ->11
          6    >   BEGIN_SILENCE                                    ~7      
          7        FETCH_DIM_R                                      ~8      !2, !1
          8        ASSIGN                                           ~9      !2, ~8
          9        END_SILENCE                                              ~7
         10        BOOL                                             ~6      ~9
         11    >   ASSIGN                                           ~10     !2, ~6
         12      > JMPZ                                                     ~10, ->14
    8    13    > > RETURN                                                   !2
   10    14    >   ASSIGN                                                   !3, <array>
   13    15    >   INIT_FCALL                                               'method_exists'
         16        SEND_VAR                                                 !0
         17        INIT_FCALL                                               'current'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $12     
         20        CONCAT                                           ~13     $12, !1
         21        ASSIGN                                           ~14     !4, ~13
         22        SEND_VAL                                                 ~14
         23        DO_ICALL                                         $15     
         24      > JMPZ                                                     $15, ->28
         25    >   INIT_METHOD_CALL                                         !0, !4
         26        DO_FCALL                                      0  $16     
         27      > RETURN                                                   $16
   14    28    >   INIT_FCALL                                               'next'
         29        SEND_REF                                                 !3
         30        DO_ICALL                                         $17     
         31      > JMPNZ                                                    $17, ->15
   16    32    >   NEW                                              $18     'Exception'
         33        DO_FCALL                                      0          
         34      > THROW                                         0          $18
   17    35*     > 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/PbM53
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:
156.29 ms | 1400 KiB | 21 Q