3v4l.org

run code in 300+ PHP versions simultaneously
<?php // SETUP CODE class A { function __construct($val) { $this->val = $val; } } $objs = [ new A(3), new A(5), new A(2), new A(8), new A(1), ]; // AMAZING max_by IMPL :P $res = array_reduce($objs, function ($c, $o) { $p = !is_null($c) ? $c->val : 0; $c = max($o->val, $p); return $o->val == $p ? $o : $c; }); var_dump($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FBL9W
function name:  (null)
number of ops:  31
compiled vars:  !0 = $objs, !1 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $2      'A'
          1        SEND_VAL_EX                                              3
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~4      $2
   12     4        NEW                                              $5      'A'
          5        SEND_VAL_EX                                              5
          6        DO_FCALL                                      0          
          7        ADD_ARRAY_ELEMENT                                ~4      $5
   13     8        NEW                                              $7      'A'
          9        SEND_VAL_EX                                              2
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~4      $7
   14    12        NEW                                              $9      'A'
         13        SEND_VAL_EX                                              8
         14        DO_FCALL                                      0          
         15        ADD_ARRAY_ELEMENT                                ~4      $9
   15    16        NEW                                              $11     'A'
         17        SEND_VAL_EX                                              1
         18        DO_FCALL                                      0          
         19        ADD_ARRAY_ELEMENT                                ~4      $11
   10    20        ASSIGN                                                   !0, ~4
   19    21        INIT_FCALL                                               'array_reduce'
         22        SEND_VAR                                                 !0
         23        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFBL9W%3A19%240'
   23    24        SEND_VAL                                                 ~14
         25        DO_ICALL                                         $15     
   19    26        ASSIGN                                                   !1, $15
   24    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FFBL9W%3A19%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
Branch analysis from position: 21
filename:       /in/FBL9W
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $c, !1 = $o, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        TYPE_CHECK                                    2  ~3      !0
          3        BOOL_NOT                                         ~4      ~3
          4      > JMPZ                                                     ~4, ->8
          5    >   FETCH_OBJ_R                                      ~5      !0, 'val'
          6        QM_ASSIGN                                        ~6      ~5
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~6      0
          9    >   ASSIGN                                                   !2, ~6
   21    10        INIT_FCALL                                               'max'
         11        FETCH_OBJ_R                                      ~8      !1, 'val'
         12        SEND_VAL                                                 ~8
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !0, $9
   22    16        FETCH_OBJ_R                                      ~11     !1, 'val'
         17        IS_EQUAL                                                 !2, ~11
         18      > JMPZ                                                     ~12, ->21
         19    >   QM_ASSIGN                                        ~13     !1
         20      > JMP                                                      ->22
         21    >   QM_ASSIGN                                        ~13     !0
         22    > > RETURN                                                   ~13
   23    23*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FFBL9W%3A19%240

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

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.92 ms | 1400 KiB | 19 Q