3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // SETUP CODE class A { function __construct($val) { $this->val = $val; } } $objs = [ new A(3), new A(5), new A(2), ]; // AMAZING max_by IMPL :P $res = array_reduce($objs, function ($c, $o) { $c = max($o->val, $c); return $o->val == $c ? $o->val : $c; }); var_dump($res);
based on FTc9G
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/IJrvU
function name:  (null)
number of ops:  24
compiled vars:  !0 = $objs, !1 = $res
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   NOP                                                      
  11     1        NEW                                              $3      :-6
         2        SEND_VAL_EX                                              3
         3        DO_FCALL                                      0          
         4        INIT_ARRAY                                       ~5      $3
  12     5        NEW                                              $6      :-3
         6        SEND_VAL_EX                                              5
         7        DO_FCALL                                      0          
         8        ADD_ARRAY_ELEMENT                                ~5      $6
  13     9        NEW                                              $8      :0
        10        SEND_VAL_EX                                              2
        11        DO_FCALL                                      0          
        12        ADD_ARRAY_ELEMENT                                ~5      $8
        13        ASSIGN                                                   !0, ~5
  17    14        INIT_FCALL                                               'array_reduce'
        15        SEND_VAR                                                 !0
        16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIJrvU0x7fdc2109112a'
  20    17        SEND_VAL                                                 ~11
        18        DO_ICALL                                         $12     
        19        ASSIGN                                                   !1, $12
  21    20        INIT_FCALL                                               'var_dump'
        21        SEND_VAR                                                 !1
        22        DO_ICALL                                                 
        23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FIJrvU0x7fdc2109112a:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
Jump found. Position 1 = 15
Branch analysis from position: 15
Jump found. Position 1 = -2
Branch analysis from position: 14
Jump found. Position 1 = -2
filename:       /in/IJrvU
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $c, !1 = $o
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  17     0  E >   RECV                                             !0      
         1        RECV                                             !1      
  18     2        INIT_FCALL                                               'max'
         3        FETCH_OBJ_R                                      $2      !1, 'val'
         4        SEND_VAR                                                 $2
         5        SEND_VAR                                                 !0
         6        DO_ICALL                                         $3      
         7        ASSIGN                                                   !0, $3
  19     8        FETCH_OBJ_R                                      $5      !1, 'val'
         9        IS_EQUAL                                         ~6      $5, !0
        10      > JMPZ                                                     ~6, ->14
        11    >   FETCH_OBJ_R                                      $7      !1, 'val'
        12        QM_ASSIGN                                        ~8      $7
        13      > JMP                                                      ->15
        14    >   QM_ASSIGN                                        ~8      !0
        15    > > RETURN                                                   ~8
  20    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FIJrvU0x7fdc2109112a

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/IJrvU
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 7.3.0