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

End of function __get

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.92 ms | 1404 KiB | 17 Q