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() { foreach($this->mapping as $dbFieldName => $content) { if(isset($this->rawData[$dbFieldName])) { var_dump($this->rawData[$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/pTpeX
function name:  (null)
number of ops:  6
compiled vars:  !0 = $data, !1 = $dh
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ASSIGN                                                   !0, <array>
   36     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/pTpeX
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/pTpeX
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/pTpeX
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 = 13
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/pTpeX
function name:  mapData
number of ops:  15
compiled vars:  !0 = $content, !1 = $dbFieldName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~2      'mapping'
          1      > FE_RESET_R                                       $3      ~2, ->13
          2    > > FE_FETCH_R                                       ~4      $3, !0, ->13
          3    >   ASSIGN                                                   !1, ~4
   28     4        FETCH_OBJ_IS                                     ~6      'rawData'
          5        ISSET_ISEMPTY_DIM_OBJ                         0          ~6, !1
          6      > JMPZ                                                     ~7, ->12
   29     7    >   INIT_FCALL                                               'var_dump'
          8        FETCH_OBJ_R                                      ~8      'rawData'
          9        FETCH_DIM_R                                      ~9      ~8, !1
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                                 
   27    12    > > JMP                                                      ->2
         13    >   FE_FREE                                                  $3
   32    14      > RETURN                                                   null

End of function mapdata

End of class DataHolder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.81 ms | 1392 KiB | 15 Q