3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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());
based on n8XaY
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/Efi29
function name:  (null)
number of ops:  15
compiled vars:  !0 = $source, !1 = $transformer, !2 = $report
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  27     1        ASSIGN                                                   !0, <array>
  33     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEfi290x7f4292704319'
  36     3        ASSIGN                                                   !1, ~5
  38     4        NEW                                              $7      :-4
         5        SEND_VAR_EX                                              !0
         6        SEND_VAR_EX                                              !1
         7        DO_FCALL                                      0          
         8        ASSIGN                                                   !2, $7
  40     9        INIT_FCALL                                               'var_dump'
        10        INIT_METHOD_CALL                                         !2, 'getData'
        11        DO_FCALL                                      0  $10     
        12        SEND_VAR                                                 $10
        13        DO_ICALL                                                 
        14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FEfi290x7f4292704319:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
Jump found. Position 1 = 19
Branch analysis from position: 19
Jump found. Position 1 = -2
Branch analysis from position: 15
Jump found. 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                       33554432  ~5      !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%2FEfi290x7f4292704319

Class ReportController:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
Jump found. Position 1 = 11
Branch analysis from position: 11
Jump found. Position 1 = -2
Branch analysis from position: 10
Jump found. 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      :-3
         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
Jump found. 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
Jump found. 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 7.3.0