3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReportController { protected $source; protected $data; public function __construct(array $source, \Closure $transformer, $dataObject = null) { $this->source = $source; $this->data = ($dataObject) ? new stdClass() : $dataObject; $this->transform($transformer); } public function transform(\Closure $transformer) { array_walk($this->source, $transformer, "bob"); } public function getData() { return $this->data; } } $source = [ ['type'=>'open'], ['type'=>'closed'], ['type'=>'pending'], ['type'=>'accepted'] ]; $transformer = function($ticket, $key, $data) { var_dump($key, $data); (isset($data[$ticket['type']]))? $data[$ticket['type']]++: $data[$ticket['type']]=1; }; $report = new ReportController($source, $transformer); var_dump($report->getData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Efi29
function name:  (null)
number of ops:  14
compiled vars:  !0 = $source, !1 = $transformer, !2 = $report
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, <array>
   33     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEfi29%3A33%240'
          2        ASSIGN                                                   !1, ~4
   38     3        NEW                                              $6      'ReportController'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $6
   40     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !2, 'getData'
         10        DO_FCALL                                      0  $9      
         11        SEND_VAR                                                 $9
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FEfi29%3A33%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Efi29
function name:  {closure}
number of ops:  21
compiled vars:  !0 = $ticket, !1 = $key, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   34     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                                 
   35     7        FETCH_DIM_R                                      ~4      !0, 'type'
          8        ISSET_ISEMPTY_DIM_OBJ                         0          !2, ~4
          9      > JMPZ                                                     ~5, ->15
         10    >   FETCH_DIM_R                                      ~6      !0, 'type'
         11        FETCH_DIM_RW                                     $7      !2, ~6
         12        POST_INC                                         ~8      $7
         13        QM_ASSIGN                                        ~9      ~8
         14      > JMP                                                      ->19
         15    >   FETCH_DIM_R                                      ~10     !0, 'type'
         16        ASSIGN_DIM                                       ~11     !2, ~10
         17        OP_DATA                                                  1
         18        QM_ASSIGN                                        ~9      ~11
         19    >   FREE                                                     ~9
   36    20      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEfi29%3A33%240

Class ReportController:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Efi29
function name:  __construct
number of ops:  17
compiled vars:  !0 = $source, !1 = $transformer, !2 = $dataObject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   10     3        ASSIGN_OBJ                                               'source'
          4        OP_DATA                                                  !0
   11     5      > JMPZ                                                     !2, ->10
          6    >   NEW                                              $5      'stdClass'
          7        DO_FCALL                                      0          
          8        QM_ASSIGN                                        ~7      $5
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~7      !2
         11    >   ASSIGN_OBJ                                               'data'
         12        OP_DATA                                                  ~7
   13    13        INIT_METHOD_CALL                                         'transform'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
   14    16      > RETURN                                                   null

End of function __construct

Function transform:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Efi29
function name:  transform
number of ops:  8
compiled vars:  !0 = $transformer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'array_walk'
          2        FETCH_OBJ_W                                      $1      'source'
          3        SEND_REF                                                 $1
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'bob'
          6        DO_ICALL                                                 
   19     7      > RETURN                                                   null

End of function transform

Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Efi29
function name:  getData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1      > RETURN                                                   ~0
   23     2*     > RETURN                                                   null

End of function getdata

End of class ReportController.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.34 ms | 1400 KiB | 17 Q