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($controller, $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); $person->badProp = 5;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lNaPf
function name:  (null)
number of ops:  21
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        ASSIGN_OBJ                                               !0, 'badProp'
         19        OP_DATA                                                  5
         20      > 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/lNaPf
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 = 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
filename:       /in/lNaPf
function name:  __get
number of ops:  16
compiled vars:  !0 = $name, !1 = $controller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'property_exists'
          2        SEND_VAR                                                 !1
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        BOOL_NOT                                         ~3      $2
          6      > JMPZ                                                     ~3, ->13
   13     7    >   NEW                                              $4      'Exception'
          8        NOP                                                      
          9        FAST_CONCAT                                      ~5      'No+such+property%3A+', !0
         10        SEND_VAL_EX                                              ~5
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $4
   15    13    >   FETCH_OBJ_R                                      ~7      !0
         14      > RETURN                                                   ~7
   16    15*     > RETURN                                                   null

End of function __get

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.27 ms | 1400 KiB | 17 Q