3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { private $firstname; private $lastname; private $age; public function __contruct() { $this->firstname = null; $this->lastname = null; $this->age = null; } public function __set($property, $value) { $property = trim(strtolower($property)); if (!property_exists($this, $property)) { throw new Exception("$property does not exists"); } if( !isset($value) && empty($value)) { throw new Exception("$property Can not be NULL or EMPTY"); } switch($property) { case "firstname": case "lastname": if(!is_string($value)) { throw new Exception("$property must be a String"); } $this->$property = $value; break; case "age": if(!is_int($value)) { throw new Exception("TypeError : $property must be an Integer Value"); } $this->$property = $value; break; default: throw new Exception("Invalid Exception."); break; } } public function __get($property) { if(!property_exists($property)) { throw new Exception("Invalid Arguments: $property Does not Exists"); } return $this->$property; } } $user = new User(); $user->firstname = "Zia"; echo $user->firstname;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H7dds
function name:  (null)
number of ops:  8
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   NEW                                              $1      'User'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   57     3        ASSIGN_OBJ                                               !0, 'firstname'
          4        OP_DATA                                                  'Zia'
   58     5        FETCH_OBJ_R                                      ~5      !0, 'firstname'
          6        ECHO                                                     ~5
          7      > RETURN                                                   1

Class User:
Function __contruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H7dds
function name:  __contruct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN_OBJ                                               'firstname'
          1        OP_DATA                                                  null
   10     2        ASSIGN_OBJ                                               'lastname'
          3        OP_DATA                                                  null
   11     4        ASSIGN_OBJ                                               'age'
          5        OP_DATA                                                  null
   12     6      > RETURN                                                   null

End of function __contruct

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 34
5 jumps found. (Code = 188) Position 1 = 42, Position 2 = 42, Position 3 = 54, Position 4 = 67, Position 5 = 35
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 51
Branch analysis from position: 45
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 64
Branch analysis from position: 57
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
Branch analysis from position: 67
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 42
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 54
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
Branch analysis from position: 54
Branch analysis from position: 42
Branch analysis from position: 42
Branch analysis from position: 27
filename:       /in/H7dds
function name:  __set
number of ops:  73
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_FCALL                                               'trim'
          3        INIT_FCALL                                               'strtolower'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                         $3      
          8        ASSIGN                                                   !0, $3
   16     9        INIT_FCALL                                               'property_exists'
         10        FETCH_THIS                                       ~5      
         11        SEND_VAL                                                 ~5
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        BOOL_NOT                                         ~7      $6
         15      > JMPZ                                                     ~7, ->22
   17    16    >   NEW                                              $8      'Exception'
         17        NOP                                                      
         18        FAST_CONCAT                                      ~9      !0, '+does+not+exists'
         19        SEND_VAL_EX                                              ~9
         20        DO_FCALL                                      0          
         21      > THROW                                         0          $8
   20    22    >   ISSET_ISEMPTY_CV                                 ~11     !1
         23        BOOL_NOT                                         ~12     ~11
         24      > JMPZ_EX                                          ~12     ~12, ->27
         25    >   ISSET_ISEMPTY_CV                                 ~13     !1
         26        BOOL                                             ~12     ~13
         27    > > JMPZ                                                     ~12, ->34
   21    28    >   NEW                                              $14     'Exception'
         29        NOP                                                      
         30        FAST_CONCAT                                      ~15     !0, '+Can+not+be+NULL+or+EMPTY'
         31        SEND_VAL_EX                                              ~15
         32        DO_FCALL                                      0          
         33      > THROW                                         0          $14
   24    34    > > SWITCH_STRING                                            !0, [ 'firstname':->42, 'lastname':->42, 'age':->54, ], ->67
   25    35    >   IS_EQUAL                                                 !0, 'firstname'
         36      > JMPNZ                                                    ~17, ->42
   26    37    >   IS_EQUAL                                                 !0, 'lastname'
         38      > JMPNZ                                                    ~17, ->42
   32    39    >   IS_EQUAL                                                 !0, 'age'
         40      > JMPNZ                                                    ~17, ->54
         41    > > JMP                                                      ->67
   27    42    >   TYPE_CHECK                                   64  ~18     !1
         43        BOOL_NOT                                         ~19     ~18
         44      > JMPZ                                                     ~19, ->51
   28    45    >   NEW                                              $20     'Exception'
         46        NOP                                                      
         47        FAST_CONCAT                                      ~21     !0, '+must+be+a+String'
         48        SEND_VAL_EX                                              ~21
         49        DO_FCALL                                      0          
         50      > THROW                                         0          $20
   30    51    >   ASSIGN_OBJ                                               !0
         52        OP_DATA                                                  !1
   31    53      > JMP                                                      ->72
   33    54    >   TYPE_CHECK                                   16  ~24     !1
         55        BOOL_NOT                                         ~25     ~24
         56      > JMPZ                                                     ~25, ->64
   34    57    >   NEW                                              $26     'Exception'
         58        ROPE_INIT                                     3  ~28     'TypeError+%3A+'
         59        ROPE_ADD                                      1  ~28     ~28, !0
         60        ROPE_END                                      2  ~27     ~28, '+must+be+an+Integer+Value'
         61        SEND_VAL_EX                                              ~27
         62        DO_FCALL                                      0          
         63      > THROW                                         0          $26
   36    64    >   ASSIGN_OBJ                                               !0
         65        OP_DATA                                                  !1
   37    66      > JMP                                                      ->72
   39    67    >   NEW                                              $32     'Exception'
         68        SEND_VAL_EX                                              'Invalid+Exception.'
         69        DO_FCALL                                      0          
         70      > THROW                                         0          $32
   40    71*       JMP                                                      ->72
   43    72    > > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/H7dds
function name:  __get
number of ops:  16
compiled vars:  !0 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   46     1        INIT_FCALL                                               'property_exists'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        BOOL_NOT                                         ~2      $1
          5      > JMPZ                                                     ~2, ->13
   47     6    >   NEW                                              $3      'Exception'
          7        ROPE_INIT                                     3  ~5      'Invalid+Arguments%3A+'
          8        ROPE_ADD                                      1  ~5      ~5, !0
          9        ROPE_END                                      2  ~4      ~5, '+Does+not+Exists'
         10        SEND_VAL_EX                                              ~4
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $3
   49    13    >   FETCH_OBJ_R                                      ~8      !0
         14      > RETURN                                                   ~8
   50    15*     > RETURN                                                   null

End of function __get

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
191.59 ms | 1404 KiB | 19 Q