3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReadOnly { protected $realProperty; private $dynamicProperty = array(); function __construct() { $realProperty = 12; $this->members['test'] = 'read-only'; } public function __set($name, $value) { if($name=='test') { if(isset($this->dynamicProperty[$name])) throw new Exception("Can't overwrite $name"); $props[$name] = $value; } } } class Writeable extends ReadOnly { function __construct($value) { parent::__construct(); $this->realProperty = 25; // ok $this->test = $value; // causes Fatal Error } } $test = new Writeable('write to me');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oQ03I
function name:  (null)
number of ops:  5
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $1      'Writeable'
          1        SEND_VAL_EX                                              'write+to+me'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
          4      > RETURN                                                   1

Class ReadOnly:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oQ03I
function name:  __construct
number of ops:  5
compiled vars:  !0 = $realProperty
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, 12
    8     1        FETCH_OBJ_W                                      $2      'members'
          2        ASSIGN_DIM                                               $2, 'test'
          3        OP_DATA                                                  'read-only'
    9     4      > RETURN                                                   null

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/oQ03I
function name:  __set
number of ops:  16
compiled vars:  !0 = $name, !1 = $value, !2 = $props
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        IS_EQUAL                                                 !0, 'test'
          3      > JMPZ                                                     ~3, ->15
   12     4    >   FETCH_OBJ_IS                                     ~4      'dynamicProperty'
          5        ISSET_ISEMPTY_DIM_OBJ                         0          ~4, !0
          6      > JMPZ                                                     ~5, ->13
   13     7    >   NEW                                              $6      'Exception'
          8        NOP                                                      
          9        FAST_CONCAT                                      ~7      'Can%27t+overwrite+', !0
         10        SEND_VAL_EX                                              ~7
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $6
   15    13    >   ASSIGN_DIM                                               !2, !0
         14        OP_DATA                                                  !1
   17    15    > > RETURN                                                   null

End of function __set

End of class ReadOnly.

Class Writeable:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oQ03I
function name:  __construct
number of ops:  8
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_STATIC_METHOD_CALL                                  
          2        DO_FCALL                                      0          
   22     3        ASSIGN_OBJ                                               'realProperty'
          4        OP_DATA                                                  25
   23     5        ASSIGN_OBJ                                               'test'
          6        OP_DATA                                                  !0
   24     7      > RETURN                                                   null

End of function __construct

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/oQ03I
function name:  __set
number of ops:  16
compiled vars:  !0 = $name, !1 = $value, !2 = $props
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        IS_EQUAL                                                 !0, 'test'
          3      > JMPZ                                                     ~3, ->15
   12     4    >   FETCH_OBJ_IS                                     ~4      'dynamicProperty'
          5        ISSET_ISEMPTY_DIM_OBJ                         0          ~4, !0
          6      > JMPZ                                                     ~5, ->13
   13     7    >   NEW                                              $6      'Exception'
          8        NOP                                                      
          9        FAST_CONCAT                                      ~7      'Can%27t+overwrite+', !0
         10        SEND_VAL_EX                                              ~7
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $6
   15    13    >   ASSIGN_DIM                                               !2, !0
         14        OP_DATA                                                  !1
   17    15    > > RETURN                                                   null

End of function __set

End of class Writeable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.25 ms | 1399 KiB | 13 Q