3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; public function __construct($a) { $this->a = (int) $a; } public static function maxA(array $fooList) { return array_reduce($fooList, function($carry, Foo $item) { return ($carry == null || $item->a > $carry->a) ? $item : $carry; }); } } $fooList = [ new Foo(1), new Foo(5), new Foo(2), ]; var_dump(Foo::maxA($fooList));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tiupV
function name:  (null)
number of ops:  20
compiled vars:  !0 = $fooList
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'Foo'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~3      $1
   22     4        NEW                                              $4      'Foo'
          5        SEND_VAL_EX                                              5
          6        DO_FCALL                                      0          
          7        ADD_ARRAY_ELEMENT                                ~3      $4
   23     8        NEW                                              $6      'Foo'
          9        SEND_VAL_EX                                              2
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~3      $6
   20    12        ASSIGN                                                   !0, ~3
   26    13        INIT_FCALL                                               'var_dump'
         14        INIT_STATIC_METHOD_CALL                                  'Foo', 'maxA'
         15        SEND_VAR                                                 !0
         16        DO_FCALL                                      0  $9      
         17        SEND_VAR                                                 $9
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FtiupV%3A14%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/tiupV
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        IS_EQUAL                                         ~2      !0, null
          3      > JMPNZ_EX                                         ~2      ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      !1, 'a'
          5        FETCH_OBJ_R                                      ~4      !0, 'a'
          6        IS_SMALLER                                       ~5      ~4, ~3
          7        BOOL                                             ~2      ~5
          8    > > JMPZ                                                     ~2, ->11
          9    >   QM_ASSIGN                                        ~6      !1
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~6      !0
         12    > > RETURN                                                   ~6
   16    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FtiupV%3A14%240

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tiupV
function name:  __construct
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        CAST                                          4  ~2      !0
          2        ASSIGN_OBJ                                               'a'
          3        OP_DATA                                                  ~2
   10     4      > RETURN                                                   null

End of function __construct

Function maxa:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tiupV
function name:  maxA
number of ops:  8
compiled vars:  !0 = $fooList
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FtiupV%3A14%240'
   16     4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   17     7*     > RETURN                                                   null

End of function maxa

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.63 ms | 1400 KiB | 17 Q