3v4l.org

run code in 500+ 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 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/6pKmr
function name:  mergeMaxAges
number of ops:  20
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        FETCH_CONSTANT                                       ~3      'PERMANENT'
          3        FRAMELESS_ICALL_2                in_array            ~4      ~3, !0
          4      > JMPZ                                                         ~4, ->15
    8     5    >   INIT_FCALL                                                   'array_filter'
          6        SEND_VAR                                                     !0
          7        DECLARE_LAMBDA_FUNCTION                              ~5      [0]
   10     8        SEND_VAL                                                     ~5
    8     9        DO_ICALL                                             $6      
         10        ASSIGN                                                       !0, $6
   14    11        ISSET_ISEMPTY_CV                                             !0
         12      > JMPZ                                                         ~8, ->15
   15    13    >   FETCH_CONSTANT                                       ~9      'PERMANENT'
         14      > RETURN                                                       ~9
   19    15    >   INIT_FCALL                                                   'min'
         16        SEND_VAR                                                     !0
         17        DO_ICALL                                             $10     
         18      > RETURN                                                       $10
   20    19*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6pKmr
function name:  {closure:mergeMaxAges():8}
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 Dynamic Function 0

End of function mergemaxages

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
177.11 ms | 3266 KiB | 20 Q