3v4l.org

run code in 500+ PHP versions simultaneously
<?php $accept = [ 'application/ld+json', 'application/json', 'text/html', ]; $selector = new HeaderSelector(); $headers = $selector->selectHeaders($accept, 'application/json', false); $accept = $headers['Accept']; var_dump($accept); /** * HeaderSelector Class Doc Comment * * @category Class * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ class HeaderSelector { /** * @param string[] $accept * @param string $contentType * @param bool $isMultipart * @return string[] */ public function selectHeaders(array $accept, string $contentType, bool $isMultipart): array { $headers = []; $accept = $this->selectAcceptHeader($accept); if ($accept !== null) { $headers['Accept'] = $accept; } if (!$isMultipart) { if($contentType === '') { $contentType = 'application/json'; } $headers['Content-Type'] = $contentType; } return $headers; } /** * Return the header 'Accept' based on an array of Accept provided. * * @param string[] $accept Array of header * * @return null|string Accept (e.g. application/json) */ private function selectAcceptHeader(array $accept): ?string { # filter out empty entries $accept = array_filter($accept); if (count($accept) === 0) { return null; } # If there's only one Accept header, just use it if (count($accept) === 1) { return reset($accept); } # If none of the available Accept headers is of type "json", then just use all them $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); if (count($headersWithJson) === 0) { return implode(',', $accept); } # If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1, # to give the highest priority to json-like headers - recalculating the existing ones, if needed return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson); } /** * Create an Accept header string from the given "Accept" headers array, recalculating all weights * * @param string[] $accept Array of Accept Headers * @param string[] $headersWithJson Array of Accept Headers of type "json" * * @return string "Accept" Header (e.g. "application/json, text/html; q=0.9") */ private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string { $processedHeaders = [ 'withApplicationJson' => [], 'withJson' => [], 'withoutJson' => [], ]; foreach ($accept as $header) { $headerData = $this->getHeaderAndWeight($header); if (stripos($headerData['header'], 'application/json') === 0) { $processedHeaders['withApplicationJson'][] = $headerData; } elseif (in_array($header, $headersWithJson, true)) { $processedHeaders['withJson'][] = $headerData; } else { $processedHeaders['withoutJson'][] = $headerData; } } $acceptHeaders = []; $currentWeight = 1000; $hasMoreThan28Headers = count($accept) > 28; foreach($processedHeaders as $headers) { if (count($headers) > 0) { $acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers); } } $acceptHeaders = array_merge(...$acceptHeaders); return implode(',', $acceptHeaders); } /** * Given an Accept header, returns an associative array splitting the header and its weight * * @param string $header "Accept" Header * * @return array with the header and its weight */ private function getHeaderAndWeight(string $header): array { # matches headers with weight, splitting the header and the weight in $outputArray if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) { $headerData = [ 'header' => $outputArray[1], 'weight' => (int)($outputArray[2] * 1000), ]; } else { $headerData = [ 'header' => trim($header), 'weight' => 1000, ]; } return $headerData; } /** * @param array[] $headers * @param float $currentWeight * @param bool $hasMoreThan28Headers * @return string[] array of adjusted "Accept" headers */ private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array { usort($headers, function (array $a, array $b) { return $b['weight'] - $a['weight']; }); $acceptHeaders = []; foreach ($headers as $index => $header) { if($index > 0 && $headers[$index - 1]['weight'] > $header['weight']) { $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); } $weight = $currentWeight; $acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight); } $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); return $acceptHeaders; } /** * @param string $header * @param int $weight * @return string */ private function buildAcceptHeader(string $header, int $weight): string { if($weight === 1000) { return $header; } return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0'); } /** * Calculate the next weight, based on the current one. * * If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the * following formula: * * next weight = current weight - 10 ^ (floor(log(current weight - 1))) * * ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) ) * * Starting from 1000, this generates the following series: * * 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 * * The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. * * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) * @param bool $hasMoreThan28Headers * @return int */ public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int { if ($currentWeight <= 1) { return 1; } if ($hasMoreThan28Headers) { return $currentWeight - 1; } return $currentWeight - 10 ** floor( log10($currentWeight - 1) ); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JphEQ
function name:  (null)
number of ops:  16
compiled vars:  !0 = $accept, !1 = $selector, !2 = $headers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1        NEW                                                  $4      'HeaderSelector'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $4
   10     4        INIT_METHOD_CALL                                             !1, 'selectHeaders'
          5        SEND_VAR_EX                                                  !0
          6        SEND_VAL_EX                                                  'application%2Fjson'
          7        SEND_VAL_EX                                                  <false>
          8        DO_FCALL                                          0  $7      
          9        ASSIGN                                                       !2, $7
   11    10        FETCH_DIM_R                                          ~9      !2, 'Accept'
         11        ASSIGN                                                       !0, ~9
   12    12        INIT_FCALL                                                   'var_dump'
         13        SEND_VAR                                                     !0
         14        DO_ICALL                                                     
  229    15      > RETURN                                                       1

Class HeaderSelector:
Function selectheaders:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 19
Branch analysis from position: 12
filename:       /in/JphEQ
function name:  selectHeaders
number of ops:  23
compiled vars:  !0 = $accept, !1 = $contentType, !2 = $isMultipart, !3 = $headers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   30     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   32     3        ASSIGN                                                       !3, <array>
   34     4        INIT_METHOD_CALL                                             'selectAcceptHeader'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0  $5      
          7        ASSIGN                                                       !0, $5
   35     8        TYPE_CHECK                                      1020          !0
          9      > JMPZ                                                         ~7, ->12
   36    10    >   ASSIGN_DIM                                                   !3, 'Accept'
         11        OP_DATA                                                      !0
   39    12    >   BOOL_NOT                                             ~9      !2
         13      > JMPZ                                                         ~9, ->19
   40    14    >   IS_IDENTICAL                                                 !1, ''
         15      > JMPZ                                                         ~10, ->17
   41    16    >   ASSIGN                                                       !1, 'application%2Fjson'
   44    17    >   ASSIGN_DIM                                                   !3, 'Content-Type'
         18        OP_DATA                                                      !1
   47    19    >   VERIFY_RETURN_TYPE                                           !3
         20      > RETURN                                                       !3
   48    21*       VERIFY_RETURN_TYPE                                           
         22*     > RETURN                                                       null

End of function selectheaders

Function selectacceptheader:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JphEQ
function name:  selectAcceptHeader
number of ops:  36
compiled vars:  !0 = $accept, !1 = $headersWithJson
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   57     0  E >   RECV                                                 !0      
   60     1        INIT_FCALL                                                   'array_filter'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $2      
          4        ASSIGN                                                       !0, $2
   62     5        COUNT                                                ~4      !0
          6        IS_IDENTICAL                                                 ~4, 0
          7      > JMPZ                                                         ~5, ->9
   63     8    > > RETURN                                                       null
   67     9    >   COUNT                                                ~6      !0
         10        IS_IDENTICAL                                                 ~6, 1
         11      > JMPZ                                                         ~7, ->17
   68    12    >   INIT_FCALL                                                   'reset'
         13        SEND_REF                                                     !0
         14        DO_ICALL                                             $8      
         15        VERIFY_RETURN_TYPE                                           $8
         16      > RETURN                                                       $8
   72    17    >   INIT_FCALL                                                   'preg_grep'
         18        SEND_VAL                                                     '%7E%28%3Fi%29%5E%28application%2Fjson%7C%5B%5E%3B%2F+%5Ct%5D%2B%2F%5B%5E%3B%2F+%5Ct%5D%2B%5B%2B%5Djson%29%5B+%5Ct%5D%2A%28%3B.%2A%29%3F%24%7E'
         19        SEND_VAR                                                     !0
         20        DO_ICALL                                             $9      
         21        ASSIGN                                                       !1, $9
   73    22        COUNT                                                ~11     !1
         23        IS_IDENTICAL                                                 ~11, 0
         24      > JMPZ                                                         ~12, ->28
   74    25    >   FRAMELESS_ICALL_2                implode             ~13     '%2C', !0
         26        VERIFY_RETURN_TYPE                                           ~13
         27      > RETURN                                                       ~13
   79    28    >   INIT_METHOD_CALL                                             'getAcceptHeaderWithAdjustedWeight'
         29        SEND_VAR_EX                                                  !0
         30        SEND_VAR_EX                                                  !1
         31        DO_FCALL                                          0  $14     
         32        VERIFY_RETURN_TYPE                                           $14
         33      > RETURN                                                       $14
   80    34*       VERIFY_RETURN_TYPE                                           
         35*     > RETURN                                                       null

End of function selectacceptheader

Function getacceptheaderwithadjustedweight:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 31
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 31
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 31
2 jumps found. (Code = 77) Position 1 = 38, Position 2 = 50
Branch analysis from position: 38
2 jumps found. (Code = 78) Position 1 = 39, Position 2 = 50
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 49
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 49
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
Branch analysis from position: 31
filename:       /in/JphEQ
function name:  getAcceptHeaderWithAdjustedWeight
number of ops:  61
compiled vars:  !0 = $accept, !1 = $headersWithJson, !2 = $processedHeaders, !3 = $header, !4 = $headerData, !5 = $acceptHeaders, !6 = $currentWeight, !7 = $hasMoreThan28Headers, !8 = $headers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   90     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   92     2        ASSIGN                                                       !2, <array>
   98     3      > FE_RESET_R                                           $10     !0, ->31
          4    > > FE_FETCH_R                                                   $10, !3, ->31
  100     5    >   INIT_METHOD_CALL                                             'getHeaderAndWeight'
          6        SEND_VAR_EX                                                  !3
          7        DO_FCALL                                          0  $11     
          8        ASSIGN                                                       !4, $11
  102     9        INIT_FCALL                                                   'stripos'
         10        FETCH_DIM_R                                          ~13     !4, 'header'
         11        SEND_VAL                                                     ~13
         12        SEND_VAL                                                     'application%2Fjson'
         13        DO_ICALL                                             $14     
         14        IS_IDENTICAL                                                 $14, 0
         15      > JMPZ                                                         ~15, ->20
  103    16    >   FETCH_DIM_W                                          $16     !2, 'withApplicationJson'
         17        ASSIGN_DIM                                                   $16
         18        OP_DATA                                                      !4
  102    19      > JMP                                                          ->30
  104    20    >   FRAMELESS_ICALL_3                in_array            ~18     !3, !1
         21        OP_DATA                                                      <true>
         22      > JMPZ                                                         ~18, ->27
  105    23    >   FETCH_DIM_W                                          $19     !2, 'withJson'
         24        ASSIGN_DIM                                                   $19
         25        OP_DATA                                                      !4
  104    26      > JMP                                                          ->30
  107    27    >   FETCH_DIM_W                                          $21     !2, 'withoutJson'
         28        ASSIGN_DIM                                                   $21
         29        OP_DATA                                                      !4
   98    30    > > JMP                                                          ->4
         31    >   FE_FREE                                                      $10
  111    32        ASSIGN                                                       !5, <array>
  112    33        ASSIGN                                                       !6, 1000
  114    34        COUNT                                                ~25     !0
         35        IS_SMALLER                                           ~26     28, ~25
         36        ASSIGN                                                       !7, ~26
  116    37      > FE_RESET_R                                           $28     !2, ->50
         38    > > FE_FETCH_R                                                   $28, !8, ->50
  117    39    >   COUNT                                                ~29     !8
         40        IS_SMALLER                                                   0, ~29
         41      > JMPZ                                                         ~30, ->49
  118    42    >   INIT_METHOD_CALL                                             'adjustWeight'
         43        SEND_VAR_EX                                                  !8
         44        SEND_VAR_EX                                                  !6
         45        SEND_VAR_EX                                                  !7
         46        DO_FCALL                                          0  $32     
         47        ASSIGN_DIM                                                   !5
         48        OP_DATA                                                      $32
  116    49    > > JMP                                                          ->38
         50    >   FE_FREE                                                      $28
  122    51        INIT_FCALL                                                   'array_merge'
         52        SEND_UNPACK                                                  !5
         53        CHECK_UNDEF_ARGS                                             
         54        DO_ICALL                                             $33     
         55        ASSIGN                                                       !5, $33
  124    56        FRAMELESS_ICALL_2                implode             ~35     '%2C', !5
         57        VERIFY_RETURN_TYPE                                           ~35
         58      > RETURN                                                       ~35
  125    59*       VERIFY_RETURN_TYPE                                           
         60*     > RETURN                                                       null

End of function getacceptheaderwithadjustedweight

Function getheaderandweight:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JphEQ
function name:  getHeaderAndWeight
number of ops:  24
compiled vars:  !0 = $header, !1 = $outputArray, !2 = $headerData
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  134     0  E >   RECV                                                 !0      
  137     1        INIT_FCALL                                                   'preg_match'
          2        SEND_VAL                                                     '%2F%28.%2A%29%3B%5Cs%2Aq%3D%281%28%3F%3A%5C.0%2B%29%3F%7C0%5C.%5Cd%2B%29%24%2F'
          3        SEND_VAR                                                     !0
          4        SEND_REF                                                     !1
          5        DO_ICALL                                             $3      
          6        IS_IDENTICAL                                                 $3, 1
          7      > JMPZ                                                         ~4, ->16
  139     8    >   FETCH_DIM_R                                          ~5      !1, 1
          9        INIT_ARRAY                                           ~6      ~5, 'header'
  140    10        FETCH_DIM_R                                          ~7      !1, 2
         11        MUL                                                  ~8      ~7, 1000
         12        CAST                                              4  ~9      ~8
         13        ADD_ARRAY_ELEMENT                                    ~6      ~9, 'weight'
  138    14        ASSIGN                                                       !2, ~6
  137    15      > JMP                                                          ->20
  144    16    >   FRAMELESS_ICALL_1                trim                ~11     !0
         17        INIT_ARRAY                                           ~12     ~11, 'header'
  145    18        ADD_ARRAY_ELEMENT                                    ~12     1000, 'weight'
  143    19        ASSIGN                                                       !2, ~12
  149    20    >   VERIFY_RETURN_TYPE                                           !2
         21      > RETURN                                                       !2
  150    22*       VERIFY_RETURN_TYPE                                           
         23*     > RETURN                                                       null

End of function getheaderandweight

Function adjustweight:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 36
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 36
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 26
Branch analysis from position: 20
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/JphEQ
function name:  adjustWeight
number of ops:  46
compiled vars:  !0 = $headers, !1 = $currentWeight, !2 = $hasMoreThan28Headers, !3 = $acceptHeaders, !4 = $header, !5 = $index, !6 = $weight
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  158     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
  160     3        INIT_FCALL                                                   'usort'
          4        SEND_REF                                                     !0
          5        DECLARE_LAMBDA_FUNCTION                              ~7      [0]
  162     6        SEND_VAL                                                     ~7
  160     7        DO_ICALL                                                     
  164     8        ASSIGN                                                       !3, <array>
  165     9      > FE_RESET_R                                           $10     !0, ->36
         10    > > FE_FETCH_R                                           ~11     $10, !4, ->36
         11    >   ASSIGN                                                       !5, ~11
  166    12        IS_SMALLER                                           ~13     0, !5
         13      > JMPZ_EX                                              ~13     ~13, ->20
         14    >   SUB                                                  ~14     !5, 1
         15        FETCH_DIM_R                                          ~15     !0, ~14
         16        FETCH_DIM_R                                          ~16     ~15, 'weight'
         17        FETCH_DIM_R                                          ~17     !4, 'weight'
         18        IS_SMALLER                                           ~18     ~17, ~16
         19        BOOL                                                 ~13     ~18
         20    > > JMPZ                                                         ~13, ->26
  168    21    >   INIT_METHOD_CALL                                             'getNextWeight'
         22        SEND_VAR_EX                                                  !1
         23        SEND_VAR_EX                                                  !2
         24        DO_FCALL                                          0  $19     
         25        ASSIGN                                                       !1, $19
  171    26    >   ASSIGN                                                       !6, !1
  173    27        INIT_METHOD_CALL                                             'buildAcceptHeader'
         28        CHECK_FUNC_ARG                                               
         29        FETCH_DIM_FUNC_ARG                                   $23     !4, 'header'
         30        SEND_FUNC_ARG                                                $23
         31        SEND_VAR_EX                                                  !6
         32        DO_FCALL                                          0  $24     
         33        ASSIGN_DIM                                                   !3
         34        OP_DATA                                                      $24
  165    35      > JMP                                                          ->10
         36    >   FE_FREE                                                      $10
  176    37        INIT_METHOD_CALL                                             'getNextWeight'
         38        SEND_VAR_EX                                                  !1
         39        SEND_VAR_EX                                                  !2
         40        DO_FCALL                                          0  $25     
         41        ASSIGN                                                       !1, $25
  178    42        VERIFY_RETURN_TYPE                                           !3
         43      > RETURN                                                       !3
  179    44*       VERIFY_RETURN_TYPE                                           
         45*     > 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/JphEQ
function name:  {closure:HeaderSelector::adjustWeight():160}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  160     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  161     2        FETCH_DIM_R                                          ~2      !1, 'weight'
          3        FETCH_DIM_R                                          ~3      !0, 'weight'
          4        SUB                                                  ~4      ~2, ~3
          5      > RETURN                                                       ~4
  162     6*     > RETURN                                                       null

End of Dynamic Function 0

End of function adjustweight

Function buildacceptheader:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JphEQ
function name:  buildAcceptHeader
number of ops:  22
compiled vars:  !0 = $header, !1 = $weight
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  186     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  188     2        IS_IDENTICAL                                                 !1, 1000
          3      > JMPZ                                                         ~2, ->6
  189     4    >   VERIFY_RETURN_TYPE                                           !0
          5      > RETURN                                                       !0
  192     6    >   FRAMELESS_ICALL_2                trim                ~3      !0, '%3B+'
          7        CONCAT                                               ~4      ~3, '%3Bq%3D'
          8        INIT_FCALL                                                   'rtrim'
          9        INIT_FCALL                                                   'sprintf'
         10        SEND_VAL                                                     '%250.3f'
         11        DIV                                                  ~5      !1, 1000
         12        SEND_VAL                                                     ~5
         13        DO_ICALL                                             $6      
         14        SEND_VAR                                                     $6
         15        SEND_VAL                                                     '0'
         16        DO_ICALL                                             $7      
         17        CONCAT                                               ~8      ~4, $7
         18        VERIFY_RETURN_TYPE                                           ~8
         19      > RETURN                                                       ~8
  193    20*       VERIFY_RETURN_TYPE                                           
         21*     > RETURN                                                       null

End of function buildacceptheader

Function getnextweight:
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 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JphEQ
function name:  getNextWeight
number of ops:  22
compiled vars:  !0 = $currentWeight, !1 = $hasMoreThan28Headers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  217     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  219     2        IS_SMALLER_OR_EQUAL                                          !0, 1
          3      > JMPZ                                                         ~2, ->5
  220     4    > > RETURN                                                       1
  223     5    > > JMPZ                                                         !1, ->9
  224     6    >   SUB                                                  ~3      !0, 1
          7        VERIFY_RETURN_TYPE                                           ~3
          8      > RETURN                                                       ~3
  227     9    >   INIT_FCALL                                                   'floor'
         10        INIT_FCALL                                                   'log10'
         11        SUB                                                  ~4      !0, 1
         12        SEND_VAL                                                     ~4
         13        DO_ICALL                                             $5      
         14        SEND_VAR                                                     $5
         15        DO_ICALL                                             $6      
         16        POW                                                  ~7      10, $6
         17        SUB                                                  ~8      !0, ~7
         18        VERIFY_RETURN_TYPE                                           ~8
         19      > RETURN                                                       ~8
  228    20*       VERIFY_RETURN_TYPE                                           
         21*     > RETURN                                                       null

End of function getnextweight

End of class HeaderSelector.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.82 ms | 1206 KiB | 20 Q