3v4l.org

run code in 300+ PHP versions simultaneously
<?php class shapeClass { public function __set($name, $value) { throw new Exception("No such property: $name"); } public function __get($name) { throw new Exception("No such property: $name"); } } /* Declaring your struct/shape */ $person = new class() extends shapeClass { public $age = 15, $height = 72, $weight = 200; }; var_dump($person); var_dump($person->age); $person->age = 19; var_dump($person->age); try { var_dump($person->badProp); } catch (Exception $e) { var_dump($e); } try { $person->badProp = 5; } catch (Exception $e) { var_dump($e); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 22
Branch analysis from position: 22
2 jumps found. (Code = 107) Position 1 = 23, Position 2 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Found catch point at position: 29
Branch analysis from position: 29
2 jumps found. (Code = 107) Position 1 = 30, Position 2 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F8UfQ
function name:  (null)
number of ops:  34
compiled vars:  !0 = $person, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_ANON_CLASS                               <ptr>   'shapeclass'
          1        NEW                                              $3      $2
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   17     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   19     7        INIT_FCALL                                               'var_dump'
          8        FETCH_OBJ_R                                      ~7      !0, 'age'
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                                 
   20    11        ASSIGN_OBJ                                               !0, 'age'
         12        OP_DATA                                                  19
   21    13        INIT_FCALL                                               'var_dump'
         14        FETCH_OBJ_R                                      ~10     !0, 'age'
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                                 
   24    17        INIT_FCALL                                               'var_dump'
         18        FETCH_OBJ_R                                      ~12     !0, 'badProp'
         19        SEND_VAL                                                 ~12
         20        DO_ICALL                                                 
         21      > JMP                                                      ->26
   25    22  E > > CATCH                                       last         'Exception'
   26    23    >   INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
   30    26    >   ASSIGN_OBJ                                               !0, 'badProp'
         27        OP_DATA                                                  5
         28      > JMP                                                      ->33
   31    29  E > > CATCH                                       last         'Exception'
   32    30    >   INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
   33    33    > > RETURN                                                   1

Class shapeClass:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/F8UfQ
function name:  __set
number of ops:  9
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        NEW                                              $2      'Exception'
          3        NOP                                                      
          4        FAST_CONCAT                                      ~3      'No+such+property%3A+', !0
          5        SEND_VAL_EX                                              ~3
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $2
    6     8*     > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/F8UfQ
function name:  __get
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        NEW                                              $1      'Exception'
          2        NOP                                                      
          3        FAST_CONCAT                                      ~2      'No+such+property%3A+', !0
          4        SEND_VAL_EX                                              ~2
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $1
    9     7*     > RETURN                                                   null

End of function __get

End of class shapeClass.

Class shapeClass@anonymous: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.96 ms | 1400 KiB | 15 Q