3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = ['legendaryName' => 'legendary_name']; $data = ['legendary_name' => 'The Hammer']; class Warrior { use DbHydrate; private $legendaryName; } trait DbHydrate { public function hydrate($config, $data) { foreach($config as $attributeName => $column) { if(property_exists($this, $attributeName)) { $this->{$attributeName} = $data[$column]; } throw \Exception('The property %s does not exists in %s', $attributeName, self::class); } } } $legendaryWarrior = new Warrior; $legendaryWarrior->hydrate($config, $data); var_dump($legendaryWarrior); $config = ['classicalName' => 'classical_name']; $data = ['classical_name' => 'John']; $testWarrior = new Warrior; $testWarrior->hydrate($config, $data); var_dump($testWarrior);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZpPJX
function name:  (null)
number of ops:  26
compiled vars:  !0 = $config, !1 = $data, !2 = $legendaryWarrior, !3 = $testWarrior
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    7     2        DECLARE_CLASS                                            'warrior'
   26     3        NEW                                              $6      'Warrior'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $6
   27     6        INIT_METHOD_CALL                                         !2, 'hydrate'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
   28    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
   30    13        ASSIGN                                                   !0, <array>
   32    14        ASSIGN                                                   !1, <array>
   34    15        NEW                                              $13     'Warrior'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !3, $13
   35    18        INIT_METHOD_CALL                                         !3, 'hydrate'
         19        SEND_VAR_EX                                              !0
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0          
   36    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Class Warrior: [no user functions]
Class DbHydrate:
Function hydrate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/ZpPJX
function name:  hydrate
number of ops:  24
compiled vars:  !0 = $config, !1 = $data, !2 = $column, !3 = $attributeName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2      > FE_RESET_R                                       $4      !0, ->22
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->22
          4    >   ASSIGN                                                   !3, ~5
   18     5        INIT_FCALL                                               'property_exists'
          6        FETCH_THIS                                       ~7      
          7        SEND_VAL                                                 ~7
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                         $8      
         10      > JMPZ                                                     $8, ->14
   19    11    >   FETCH_DIM_R                                      ~10     !1, !2
         12        ASSIGN_OBJ                                               !3
         13        OP_DATA                                                  ~10
   21    14    >   INIT_FCALL_BY_NAME                                       'Exception'
         15        SEND_VAL_EX                                              'The+property+%25s+does+not+exists+in+%25s'
         16        SEND_VAR_EX                                              !3
         17        FETCH_CLASS_NAME                                 ~11     
         18        SEND_VAL_EX                                              ~11
         19        DO_FCALL                                      0  $12     
         20      > THROW                                         0          $12
   16    21*       JMP                                                      ->3
         22    >   FE_FREE                                                  $4
   23    23      > RETURN                                                   null

End of function hydrate

End of class DbHydrate.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.05 ms | 945 KiB | 18 Q