3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataHolder { private $rawData; private $parsedData; private $mapping = [ 'dbField1' => 'outputField1', 'dbField2' => ['outputField2' => ['parseFn1', 'parseFn2']] ]; private function parserFn1($value) { return $value * 2; } private function parserFn2($value) { return $value . "$"; } public function __construct(array $data) { $this->rawData = $data; $this->mapData(); } // Yes, I know the methods shouldn't be here but it rather be decoupled in another class and // injected with a DI it but I wrote it like this with example purposes only private function mapData() { var_dump($this->rawData); var_dump($this->mapping); foreach($this->rawData as $dataItem) { foreach($this->mapping as $dbFieldName => $content) { if(isset($dataItem[$dbFieldName])) { var_dump($dataItem[$dbFieldName]); } } } } } $data = ['dbField1' => 5, 'dbField2' => 13]; $dh = new DataHolder($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eZ05W
function name:  (null)
number of ops:  6
compiled vars:  !0 = $data, !1 = $dh
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   ASSIGN                                                   !0, <array>
   41     1        NEW                                              $3      'DataHolder'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
          5      > RETURN                                                   1

Class DataHolder:
Function parserfn1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eZ05W
function name:  parserFn1
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        MUL                                              ~1      !0, 2
          2      > RETURN                                                   ~1
   13     3*     > RETURN                                                   null

End of function parserfn1

Function parserfn2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eZ05W
function name:  parserFn2
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        CONCAT                                           ~1      !0, '%24'
          2      > RETURN                                                   ~1
   17     3*     > RETURN                                                   null

End of function parserfn2

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eZ05W
function name:  __construct
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN_OBJ                                               'rawData'
          2        OP_DATA                                                  !0
   21     3        INIT_METHOD_CALL                                         'mapData'
          4        DO_FCALL                                      0          
   22     5      > RETURN                                                   null

End of function __construct

Function mapdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 24
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/eZ05W
function name:  mapData
number of ops:  26
compiled vars:  !0 = $dataItem, !1 = $content, !2 = $dbFieldName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_OBJ_R                                      ~3      'rawData'
          2        SEND_VAL                                                 ~3
          3        DO_ICALL                                                 
   28     4        INIT_FCALL                                               'var_dump'
          5        FETCH_OBJ_R                                      ~5      'mapping'
          6        SEND_VAL                                                 ~5
          7        DO_ICALL                                                 
   29     8        FETCH_OBJ_R                                      ~7      'rawData'
          9      > FE_RESET_R                                       $8      ~7, ->24
         10    > > FE_FETCH_R                                               $8, !0, ->24
   30    11    >   FETCH_OBJ_R                                      ~9      'mapping'
         12      > FE_RESET_R                                       $10     ~9, ->22
         13    > > FE_FETCH_R                                       ~11     $10, !1, ->22
         14    >   ASSIGN                                                   !2, ~11
   31    15        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
         16      > JMPZ                                                     ~13, ->21
   32    17    >   INIT_FCALL                                               'var_dump'
         18        FETCH_DIM_R                                      ~14     !0, !2
         19        SEND_VAL                                                 ~14
         20        DO_ICALL                                                 
   30    21    > > JMP                                                      ->13
         22    >   FE_FREE                                                  $10
   29    23      > JMP                                                      ->10
         24    >   FE_FREE                                                  $8
   37    25      > RETURN                                                   null

End of function mapdata

End of class DataHolder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.45 ms | 1400 KiB | 15 Q