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 extract($config) { $row = []; foreach($config as $attributeName => $column) { if(property_exists($this, $attributeName)) { $row[$column] = $this->{$attributeName}; } else { throw new \Exception(sprintf('The property %s does not exists in %s', $attributeName, self::class)); } } return $row; } public function hydrate($config, $data) { foreach($config as $attributeName => $column) { if(property_exists($this, $attributeName)) { $this->{$attributeName} = $data[$column]; } else { throw new \Exception(sprintf('The property %s does not exists in %s', $attributeName, self::class)); } } } } $legendaryWarrior = new Warrior; $legendaryWarrior->hydrate($config, $data); var_dump($legendaryWarrior->extract($config)); 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/pul1S
function name:  (null)
number of ops:  20
compiled vars:  !0 = $config, !1 = $data, !2 = $legendaryWarrior
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'
   42     3        NEW                                              $5      'Warrior'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $5
   43     6        INIT_METHOD_CALL                                         !2, 'hydrate'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
   44    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !2, 'extract'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR                                                 $9
         15        DO_ICALL                                                 
   45    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   53    19      > RETURN                                                   1

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

End of function extract

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

End of function hydrate

End of class DbHydrate.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.01 ms | 1404 KiB | 19 Q