3v4l.org

run code in 300+ PHP versions simultaneously
<?php $person = new class($controller) { public $age = 15, $height = 72, $weight = 200; public function __set($name, $value) { if (!property_exists($this, $name)) { throw new Exception("No such property: $name"); } $this->{$name} = $value; } public function __get($name) { if (!property_exists($this, $name)) { throw new Exception("No such property: $name"); } return $this->{$name}; } }; var_dump($person); var_dump($person->age); $person->age = 19; var_dump($person->age); var_dump($person->badProp); $person->badProp = 5;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iWWVp
function name:  (null)
number of ops:  25
compiled vars:  !0 = $person, !1 = $controller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_ANON_CLASS                               <true>  
          1        NEW                                              $3      $2
          2        SEND_VAR_EX                                              !1
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   20     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   22     8        INIT_FCALL                                               'var_dump'
          9        FETCH_OBJ_R                                      ~7      !0, 'age'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
   23    12        ASSIGN_OBJ                                               !0, 'age'
         13        OP_DATA                                                  19
   24    14        INIT_FCALL                                               'var_dump'
         15        FETCH_OBJ_R                                      ~10     !0, 'age'
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                                 
   26    18        INIT_FCALL                                               'var_dump'
         19        FETCH_OBJ_R                                      ~12     !0, 'badProp'
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                                 
   27    22        ASSIGN_OBJ                                               !0, 'badProp'
         23        OP_DATA                                                  5
         24      > RETURN                                                   1

Class class@anonymous:
Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iWWVp
function name:  __set
number of ops:  18
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'property_exists'
          3        FETCH_THIS                                       ~2      
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > JMPZ                                                     ~4, ->15
    7     9    >   NEW                                              $5      'Exception'
         10        NOP                                                      
         11        FAST_CONCAT                                      ~6      'No+such+property%3A+', !0
         12        SEND_VAL_EX                                              ~6
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $5
    9    15    >   ASSIGN_OBJ                                               !0
         16        OP_DATA                                                  !1
   10    17      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iWWVp
function name:  __get
number of ops:  17
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'property_exists'
          2        FETCH_THIS                                       ~1      
          3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        BOOL_NOT                                         ~3      $2
          7      > JMPZ                                                     ~3, ->14
   13     8    >   NEW                                              $4      'Exception'
          9        NOP                                                      
         10        FAST_CONCAT                                      ~5      'No+such+property%3A+', !0
         11        SEND_VAL_EX                                              ~5
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $4
   15    14    >   FETCH_OBJ_R                                      ~7      !0
         15      > RETURN                                                   ~7
   16    16*     > RETURN                                                   null

End of function __get

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.05 ms | 1400 KiB | 17 Q