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 extractA(self $aFoo) { return $aFoo->a; } } function max_by(array $aList, callable $aCallback) { return array_reduce($aList, function($carry, $item) use ($aCallback) { return ($carry == null || $aCallback($item) > $aCallback($carry)) ? $item : $carry; }); } $list = [ $foo1 = new Foo(2), $foo2 = new Foo(5), $foo3 = new Foo(1), ]; assert(max_by($list, ['Foo', 'extractA']) === $foo2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i1BSZ
function name:  (null)
number of ops:  27
compiled vars:  !0 = $list, !1 = $foo1, !2 = $foo2, !3 = $foo3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $4      'Foo'
          1        SEND_VAL_EX                                              2
          2        DO_FCALL                                      0          
          3        ASSIGN                                           ~6      !1, $4
          4        INIT_ARRAY                                       ~7      ~6
   27     5        NEW                                              $8      'Foo'
          6        SEND_VAL_EX                                              5
          7        DO_FCALL                                      0          
          8        ASSIGN                                           ~10     !2, $8
          9        ADD_ARRAY_ELEMENT                                ~7      ~10
   28    10        NEW                                              $11     'Foo'
         11        SEND_VAL_EX                                              1
         12        DO_FCALL                                      0          
         13        ASSIGN                                           ~13     !3, $11
         14        ADD_ARRAY_ELEMENT                                ~7      ~13
   25    15        ASSIGN                                                   !0, ~7
   31    16        ASSERT_CHECK                                             
         17        INIT_FCALL                                               'assert'
         18        INIT_FCALL                                               'max_by'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 <array>
         21        DO_FCALL                                      0  $15     
         22        IS_IDENTICAL                                     ~16     !2, $15
         23        SEND_VAL                                                 ~16
         24        SEND_VAL                                                 'assert%28max_by%28%24list%2C+%5B%27Foo%27%2C+%27extractA%27%5D%29+%3D%3D%3D+%24foo2%29'
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Function max_by:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i1BSZ
function name:  max_by
number of ops:  10
compiled vars:  !0 = $aList, !1 = $aCallback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fi1BSZ%3A20%240'
          5        BIND_LEXICAL                                             ~2, !1
   22     6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   23     9*     > RETURN                                                   null

End of function max_by

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

End of function %00%7Bclosure%7D%2Fin%2Fi1BSZ%3A20%240

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i1BSZ
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 extracta:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i1BSZ
function name:  extractA
number of ops:  4
compiled vars:  !0 = $aFoo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      !0, 'a'
          2      > RETURN                                                   ~1
   15     3*     > RETURN                                                   null

End of function extracta

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.17 ms | 1403 KiB | 18 Q