3v4l.org

run code in 500+ PHP versions simultaneously
<?php $class = new ReflectionClass(Enrollee::class); $properties = $class->getProperties(); foreach ($properties as $property) { $name = $property->getName(); $type = (string)$property->getType(); $standard[$name] = $type; } $enrollee = new Enrollee(); foreach ($_POST as $key => $value) { $nameField = $key; $valueField = $value; if (!property_exists(Enrollee::class, $nameField)) { continue; } $type = $standard[$nameField]; if ($type === 'string') { $valueField = strval($valueField); } elseif ($type === 'int') { $valueField = intval($valueField); } $valueField = trim($valueField); $enrollee->set($nameField, $valueField); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 51
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 51
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 44
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
Branch analysis from position: 19
filename:       /in/c7B5i
function name:  (null)
number of ops:  53
compiled vars:  !0 = $class, !1 = $properties, !2 = $property, !3 = $name, !4 = $type, !5 = $standard, !6 = $enrollee, !7 = $value, !8 = $key, !9 = $nameField, !10 = $valueField
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   NEW                                                  $11     'ReflectionClass'
          1        SEND_VAL_EX                                                  'Enrollee'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $11
    4     4        INIT_METHOD_CALL                                             !0, 'getProperties'
          5        DO_FCALL                                          0  $14     
          6        ASSIGN                                                       !1, $14
    6     7      > FE_RESET_R                                           $16     !1, ->19
          8    > > FE_FETCH_R                                                   $16, !2, ->19
    7     9    >   INIT_METHOD_CALL                                             !2, 'getName'
         10        DO_FCALL                                          0  $17     
         11        ASSIGN                                                       !3, $17
    8    12        INIT_METHOD_CALL                                             !2, 'getType'
         13        DO_FCALL                                          0  $19     
         14        CAST                                              6  ~20     $19
         15        ASSIGN                                                       !4, ~20
    9    16        ASSIGN_DIM                                                   !5, !3
         17        OP_DATA                                                      !4
    6    18      > JMP                                                          ->8
         19    >   FE_FREE                                                      $16
   12    20        NEW                                                  $23     'Enrollee'
         21        DO_FCALL                                          0          
         22        ASSIGN                                                       !6, $23
   14    23        FETCH_R                          global              ~26     '_POST'
         24      > FE_RESET_R                                           $27     ~26, ->51
         25    > > FE_FETCH_R                                           ~28     $27, !7, ->51
         26    >   ASSIGN                                                       !8, ~28
   15    27        ASSIGN                                                       !9, !8
   16    28        ASSIGN                                                       !10, !7
   17    29        FRAMELESS_ICALL_2                property_exists      ~32     'Enrollee', !9
         30        BOOL_NOT                                             ~33     ~32
         31      > JMPZ                                                         ~33, ->33
   18    32    > > JMP                                                          ->25
   20    33    >   FETCH_DIM_R                                          ~34     !5, !9
         34        ASSIGN                                                       !4, ~34
   21    35        IS_IDENTICAL                                                 !4, 'string'
         36      > JMPZ                                                         ~36, ->40
   22    37    >   CAST                                              6  ~37     !10
         38        ASSIGN                                                       !10, ~37
   21    39      > JMP                                                          ->44
   23    40    >   IS_IDENTICAL                                                 !4, 'int'
         41      > JMPZ                                                         ~39, ->44
   24    42    >   CAST                                              4  ~40     !10
         43        ASSIGN                                                       !10, ~40
   26    44    >   FRAMELESS_ICALL_1                trim                ~42     !10
         45        ASSIGN                                                       !10, ~42
   27    46        INIT_METHOD_CALL                                             !6, 'set'
         47        SEND_VAR_EX                                                  !9
         48        SEND_VAR_EX                                                  !10
         49        DO_FCALL                                          0          
   14    50      > JMP                                                          ->25
         51    >   FE_FREE                                                      $27
   28    52      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174 ms | 1612 KiB | 13 Q