3v4l.org

run code in 300+ 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 = 56
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 56
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 36
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 43
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 47
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 19
filename:       /in/c7B5i
function name:  (null)
number of ops:  58
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, ->56
         25    > > FE_FETCH_R                                       ~28     $27, !7, ->56
         26    >   ASSIGN                                                   !8, ~28
   15    27        ASSIGN                                                   !9, !8
   16    28        ASSIGN                                                   !10, !7
   17    29        INIT_FCALL                                               'property_exists'
         30        SEND_VAL                                                 'Enrollee'
         31        SEND_VAR                                                 !9
         32        DO_ICALL                                         $32     
         33        BOOL_NOT                                         ~33     $32
         34      > JMPZ                                                     ~33, ->36
   18    35    > > JMP                                                      ->25
   20    36    >   FETCH_DIM_R                                      ~34     !5, !9
         37        ASSIGN                                                   !4, ~34
   21    38        IS_IDENTICAL                                             !4, 'string'
         39      > JMPZ                                                     ~36, ->43
   22    40    >   CAST                                          6  ~37     !10
         41        ASSIGN                                                   !10, ~37
   21    42      > JMP                                                      ->47
   23    43    >   IS_IDENTICAL                                             !4, 'int'
         44      > JMPZ                                                     ~39, ->47
   24    45    >   CAST                                          4  ~40     !10
         46        ASSIGN                                                   !10, ~40
   26    47    >   INIT_FCALL                                               'trim'
         48        SEND_VAR                                                 !10
         49        DO_ICALL                                         $42     
         50        ASSIGN                                                   !10, $42
   27    51        INIT_METHOD_CALL                                         !6, 'set'
         52        SEND_VAR_EX                                              !9
         53        SEND_VAR_EX                                              !10
         54        DO_FCALL                                      0          
   14    55      > JMP                                                      ->25
         56    >   FE_FREE                                                  $27
   28    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.11 ms | 1004 KiB | 15 Q