3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! class A { private $a; private $b; public function __construct() { $this->a = 1; $this->b = 2; } public function __get($name) { switch ($name) { // protected: case 'a': return $this->a; break; // public case 'b': return $this->b; break; } } } class B extends A { public function getA() { return $this->a; } } $B = new B(); echo $B->b; // valid echo $B->a; // shouldn't be possible echo $B->getA(); // valid
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VsLD3
function name:  (null)
number of ops:  11
compiled vars:  !0 = $B
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   NEW                                              $1      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   42     3        FETCH_OBJ_R                                      ~4      !0, 'b'
          4        ECHO                                                     ~4
   43     5        FETCH_OBJ_R                                      ~5      !0, 'a'
          6        ECHO                                                     ~5
   44     7        INIT_METHOD_CALL                                         !0, 'getA'
          8        DO_FCALL                                      0  $6      
          9        ECHO                                                     $6
         10      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VsLD3
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN_OBJ                                               'a'
          1        OP_DATA                                                  1
   12     2        ASSIGN_OBJ                                               'b'
          3        OP_DATA                                                  2
   13     4      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 7, Position 2 = 10, Position 3 = 13, Position 4 = 2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 10
Branch analysis from position: 7
filename:       /in/VsLD3
function name:  __get
number of ops:  14
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1      > SWITCH_STRING                                            !0, [ 'a':->7, 'b':->10, ], ->13
   20     2    >   IS_EQUAL                                                 !0, 'a'
          3      > JMPNZ                                                    ~1, ->7
   25     4    >   IS_EQUAL                                                 !0, 'b'
          5      > JMPNZ                                                    ~1, ->10
          6    > > JMP                                                      ->13
   21     7    >   FETCH_OBJ_R                                      ~2      'a'
          8      > RETURN                                                   ~2
   22     9*       JMP                                                      ->13
   26    10    >   FETCH_OBJ_R                                      ~3      'b'
         11      > RETURN                                                   ~3
   27    12*       JMP                                                      ->13
   29    13    > > RETURN                                                   null

End of function __get

End of class A.

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

End of function geta

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VsLD3
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN_OBJ                                               'a'
          1        OP_DATA                                                  1
   12     2        ASSIGN_OBJ                                               'b'
          3        OP_DATA                                                  2
   13     4      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 7, Position 2 = 10, Position 3 = 13, Position 4 = 2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 10
Branch analysis from position: 7
filename:       /in/VsLD3
function name:  __get
number of ops:  14
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1      > SWITCH_STRING                                            !0, [ 'a':->7, 'b':->10, ], ->13
   20     2    >   IS_EQUAL                                                 !0, 'a'
          3      > JMPNZ                                                    ~1, ->7
   25     4    >   IS_EQUAL                                                 !0, 'b'
          5      > JMPNZ                                                    ~1, ->10
          6    > > JMP                                                      ->13
   21     7    >   FETCH_OBJ_R                                      ~2      'a'
          8      > RETURN                                                   ~2
   22     9*       JMP                                                      ->13
   26    10    >   FETCH_OBJ_R                                      ~3      'b'
         11      > RETURN                                                   ~3
   27    12*       JMP                                                      ->13
   29    13    > > RETURN                                                   null

End of function __get

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.53 ms | 1399 KiB | 13 Q