3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ReportController { protected $source; protected $data; public function __construct(array $source, $dataObject = null, \Closure $transformer = null) { $this->source = $source; $this->data = ($dataObject) ? [] : $dataObject; $this->transform($transformer); } public function transform(\Closure $transformer = null) { array_walk($this->source, $transformer); } public function getData() { return $this->data; } } $source = [ ['type'=>'open'], ['type'=>'closed'], ['type'=>'pending'], ['type'=>'accepted'] ]; $transformer = function($ticket, $key) { (isset($this->data[$ticket['type']]))? $this->data[$ticket['type']]++: $this->data[$ticket['type']]=1; }; $report = new ReportController($source); var_dump($report->getData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lAhIs
function name:  (null)
number of ops:  13
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%2FlAhIs%3A33%240'
          2        ASSIGN                                                   !1, ~4
   37     3        NEW                                              $6      'ReportController'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $6
   39     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !2, 'getData'
          9        DO_FCALL                                      0  $9      
         10        SEND_VAR                                                 $9
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

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

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

Class ReportController:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lAhIs
function name:  __construct
number of ops:  15
compiled vars:  !0 = $source, !1 = $dataObject, !2 = $transformer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
   10     3        ASSIGN_OBJ                                               'source'
          4        OP_DATA                                                  !0
   11     5      > JMPZ                                                     !1, ->8
          6    >   QM_ASSIGN                                        ~5      <array>
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      !1
          9    >   ASSIGN_OBJ                                               'data'
         10        OP_DATA                                                  ~5
   13    11        INIT_METHOD_CALL                                         'transform'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
   14    14      > 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/lAhIs
function name:  transform
number of ops:  7
compiled vars:  !0 = $transformer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                        !0      null
   18     1        INIT_FCALL                                               'array_walk'
          2        FETCH_OBJ_W                                      $1      'source'
          3        SEND_REF                                                 $1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   19     6      > 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/lAhIs
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:
158.39 ms | 1392 KiB | 17 Q