3v4l.org

run code in 300+ PHP versions simultaneously
<?php const PERMANENT = -1; function mergeMaxAges() { $max_ages = func_get_args(); // Filter out all max-age values set to cache permanently. if (in_array(PERMANENT, $max_ages)) { $max_ages = array_filter($max_ages, function ($max_age) { return $max_age !== PERMANENT; }); // If nothing is left, then all max-age values were set to cache // permanently, and then that is the result. if (empty($max_ages)) { return PERMANENT; } } return min($max_ages); } for ($i = 0; $i < 10000; $i++) { mergeMaxAges(0, 60); mergeMaxAges(0, 0); mergeMaxAges(0, PERMANENT); mergeMaxAges(PERMANENT, 60); mergeMaxAges(PERMANENT, PERMANENT); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 3
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 3
Branch analysis from position: 30
Branch analysis from position: 3
filename:       /in/6pKmr
function name:  (null)
number of ops:  31
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CONST                                            'PERMANENT', -1
   21     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->28
   22     3    >   INIT_FCALL                                               'mergemaxages'
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 60
          6        DO_FCALL                                      0          
   23     7        INIT_FCALL                                               'mergemaxages'
          8        SEND_VAL                                                 0
          9        SEND_VAL                                                 0
         10        DO_FCALL                                      0          
   24    11        INIT_FCALL                                               'mergemaxages'
         12        SEND_VAL                                                 0
         13        FETCH_CONSTANT                                   ~4      'PERMANENT'
         14        SEND_VAL                                                 ~4
         15        DO_FCALL                                      0          
   25    16        INIT_FCALL                                               'mergemaxages'
         17        FETCH_CONSTANT                                   ~6      'PERMANENT'
         18        SEND_VAL                                                 ~6
         19        SEND_VAL                                                 60
         20        DO_FCALL                                      0          
   26    21        INIT_FCALL                                               'mergemaxages'
         22        FETCH_CONSTANT                                   ~8      'PERMANENT'
         23        SEND_VAL                                                 ~8
         24        FETCH_CONSTANT                                   ~9      'PERMANENT'
         25        SEND_VAL                                                 ~9
         26        DO_FCALL                                      0          
   21    27        PRE_INC                                                  !0
         28    >   IS_SMALLER                                               !0, 10000
         29      > JMPNZ                                                    ~12, ->3
   27    30    > > RETURN                                                   1

Function mergemaxages:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/6pKmr
function name:  mergeMaxAges
number of ops:  23
compiled vars:  !0 = $max_ages
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
    7     2        INIT_FCALL                                               'in_array'
          3        FETCH_CONSTANT                                   ~3      'PERMANENT'
          4        SEND_VAL                                                 ~3
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7      > JMPZ                                                     $4, ->18
    8     8    >   INIT_FCALL                                               'array_filter'
          9        SEND_VAR                                                 !0
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6pKmr%3A8%240'
   10    11        SEND_VAL                                                 ~5
         12        DO_ICALL                                         $6      
    8    13        ASSIGN                                                   !0, $6
   14    14        ISSET_ISEMPTY_CV                                         !0
         15      > JMPZ                                                     ~8, ->18
   15    16    >   FETCH_CONSTANT                                   ~9      'PERMANENT'
         17      > RETURN                                                   ~9
   19    18    >   INIT_FCALL                                               'min'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $10     
         21      > RETURN                                                   $10
   20    22*     > RETURN                                                   null

End of function mergemaxages

Function %00%7Bclosure%7D%2Fin%2F6pKmr%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6pKmr
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $max_age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        FETCH_CONSTANT                                   ~1      'PERMANENT'
          2        IS_NOT_IDENTICAL                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
   10     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6pKmr%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.72 ms | 1407 KiB | 24 Q