3v4l.org

run code in 300+ PHP versions simultaneously
<?php $allPhpcsVersions = array( '3.1.0' => '3.1.0', '3.1.1' => '3.1.1', '3.2.0' => '3.2.0', '3.2.1' => '3.2.1', '3.2.2' => '3.2.2', '3.2.3' => '3.2.3', '3.3.0' => '3.3.0', '3.3.1' => '3.3.1', '3.3.2' => '3.3.2', '3.4.0' => '3.4.0', '3.4.1' => '3.4.1', '3.4.2' => '3.4.2', '3.5.0' => '3.5.0', '3.5.1' => '3.5.1', '3.5.2' => '3.5.2', '3.5.3' => '3.5.3', '3.5.4' => '3.5.4', '3.5.5' => '3.5.5', '3.5.6' => '3.5.6', '3.5.7' => '3.5.7', '3.5.8' => '3.5.8', '3.6.0' => '3.6.0', '3.6.1' => '3.6.1', '3.6.2' => '3.6.2', '3.7.0' => '3.7.0', '3.7.1' => '3.7.1', '3.7.2' => '3.7.2', '3.8.0' => '3.8.0', '3.8.1' => '3.8.1', '3.9.0' => '3.9.0', '3.9.1' => '3.9.1', '3.9.2' => '3.9.2', '3.10.0' => '3.10.0', '3.10.1' => '3.10.1', '3.10.2' => '3.10.2', '3.10.3' => '3.10.3', '3.11.0' => '3.11.0', '3.11.1' => '3.11.1', '3.11.2' => '3.11.2', '3.11.3' => '3.11.3', '3.12.0' => '3.12.0', '3.12.1' => '3.12.1', '3.12.2' => '3.12.2', '3.13.0' => '3.13.0', '3.13.1' => '3.13.1', '3.13.2' => '3.13.2', '3.13.3' => '3.13.3', '3.13.4' => '3.13.4', ); var_dump(min($allPhpcsVersions)); var_dump(max($allPhpcsVersions)); function my_min($versions) { return array_reduce( $versions, static function ($carry, $item) { if ($carry === null) { // First iteration. return $item; } return version_compare($carry, $item, '<') ? $carry : $item; } ); } function my_max($versions) { return array_reduce( $versions, static function ($carry, $item) { if ($carry === null) { // First iteration. return $item; } return version_compare($carry, $item, '>') ? $carry : $item; } ); } var_dump(my_min($allPhpcsVersions)); var_dump(my_max($allPhpcsVersions));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbHOY
function name:  (null)
number of ops:  26
compiled vars:  !0 = $allPhpcsVersions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   54     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'min'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   55     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'max'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                                 
   86    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL                                               'my_min'
         15        SEND_VAR                                                 !0
         16        DO_FCALL                                      0  $6      
         17        SEND_VAR                                                 $6
         18        DO_ICALL                                                 
   87    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'my_max'
         21        SEND_VAR                                                 !0
         22        DO_FCALL                                      0  $8      
         23        SEND_VAR                                                 $8
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Function my_min:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbHOY
function name:  my_min
number of ops:  8
compiled vars:  !0 = $versions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
   58     1        INIT_FCALL                                               'array_reduce'
   59     2        SEND_VAR                                                 !0
   60     3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   67     4        SEND_VAL                                                 ~1
   58     5        DO_ICALL                                         $2      
   67     6      > RETURN                                                   $2
   69     7*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbHOY
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   61     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->5
   63     4    > > RETURN                                                   !1
   66     5    >   INIT_FCALL                                               'version_compare'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 '%3C'
          9        DO_ICALL                                         $3      
         10      > JMPZ                                                     $3, ->13
         11    >   QM_ASSIGN                                        ~4      !0
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~4      !1
         14    > > RETURN                                                   ~4
   67    15*     > RETURN                                                   null

End of Dynamic Function 0

End of function my_min

Function my_max:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbHOY
function name:  my_max
number of ops:  8
compiled vars:  !0 = $versions
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   RECV                                             !0      
   72     1        INIT_FCALL                                               'array_reduce'
   73     2        SEND_VAR                                                 !0
   74     3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   81     4        SEND_VAL                                                 ~1
   72     5        DO_ICALL                                         $2      
   81     6      > RETURN                                                   $2
   84     7*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XbHOY
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   75     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~2, ->5
   77     4    > > RETURN                                                   !1
   80     5    >   INIT_FCALL                                               'version_compare'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 '%3E'
          9        DO_ICALL                                         $3      
         10      > JMPZ                                                     $3, ->13
         11    >   QM_ASSIGN                                        ~4      !0
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~4      !1
         14    > > RETURN                                                   ~4
   81    15*     > RETURN                                                   null

End of Dynamic Function 0

End of function my_max

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.19 ms | 1021 KiB | 20 Q