3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataHolder { private $rawData; private $parsedData; private $mapper = [ '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() { 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/e5EtE
function name:  (null)
number of ops:  6
compiled vars:  !0 = $data, !1 = $dh
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ASSIGN                                                   !0, <array>
   39     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/e5EtE
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/e5EtE
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/e5EtE
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 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 14
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/e5EtE
function name:  mapData
number of ops:  18
compiled vars:  !0 = $dataItem, !1 = $content, !2 = $dbFieldName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~3      'rawData'
          1      > FE_RESET_R                                       $4      ~3, ->16
          2    > > FE_FETCH_R                                               $4, !0, ->16
   28     3    >   FETCH_OBJ_R                                      ~5      'mapping'
          4      > FE_RESET_R                                       $6      ~5, ->14
          5    > > FE_FETCH_R                                       ~7      $6, !1, ->14
          6    >   ASSIGN                                                   !2, ~7
   29     7        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
          8      > JMPZ                                                     ~9, ->13
   30     9    >   INIT_FCALL                                               'var_dump'
         10        FETCH_DIM_R                                      ~10     !0, !2
         11        SEND_VAL                                                 ~10
         12        DO_ICALL                                                 
   28    13    > > JMP                                                      ->5
         14    >   FE_FREE                                                  $6
   27    15      > JMP                                                      ->2
         16    >   FE_FREE                                                  $4
   35    17      > RETURN                                                   null

End of function mapdata

End of class DataHolder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
252.88 ms | 1400 KiB | 16 Q