3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A{ private $__props = ["a"]; function __get($prop){ if(\array_key_exists($prop, $this->__props)){ return $this->__props[$prop]; } } function __set($prop, $value){ if($prop === "a"){ if($value > 100){ $this->__props[$prop] = $value; } else { trigger_error('Invariant "$this->a > 100" violated'); } } } } $a = new A(); $a->a = 110; $b = &$a->a; $b = "hello"; var_dump($a,$b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ctX1c
function name:  (null)
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $2      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   21     3        ASSIGN_OBJ                                               !0, 'a'
          4        OP_DATA                                                  110
   22     5        FETCH_OBJ_W                                      $6      !0, 'a'
          6        ASSIGN_REF                                               !1, $6
   23     7        ASSIGN                                                   !1, 'hello'
   24     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class A:
Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ctX1c
function name:  __get
number of ops:  8
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        FETCH_OBJ_R                                      ~1      '__props'
          2        ARRAY_KEY_EXISTS                                         !0, ~1
          3      > JMPZ                                                     ~2, ->7
    7     4    >   FETCH_OBJ_R                                      ~3      '__props'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6      > RETURN                                                   ~4
    9     7    > > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
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
filename:       /in/ctX1c
function name:  __set
number of ops:  14
compiled vars:  !0 = $prop, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        IS_IDENTICAL                                             !0, 'a'
          3      > JMPZ                                                     ~2, ->13
   12     4    >   IS_SMALLER                                               100, !1
          5      > JMPZ                                                     ~3, ->10
   13     6    >   FETCH_OBJ_W                                      $4      '__props'
          7        ASSIGN_DIM                                               $4, !0
          8        OP_DATA                                                  !1
          9      > JMP                                                      ->13
   15    10    >   INIT_FCALL                                               'trigger_error'
         11        SEND_VAL                                                 'Invariant+%22%24this-%3Ea+%3E+100%22+violated'
         12        DO_ICALL                                                 
   18    13    > > RETURN                                                   null

End of function __set

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.87 ms | 1400 KiB | 17 Q