Skip to content

Commit

Permalink
Merge pull request #6 from ViniciusDuranteBagio/CLI-10407---Corrigind…
Browse files Browse the repository at this point in the history
…o-validacoes-para-suportar-php8

CLI-10407 - Corrigindo validações de header para suportar o php 8 lançar exception
  • Loading branch information
idealizetecnologia authored Aug 8, 2023
2 parents 1340ad7 + fd555e3 commit 37d2cca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/HeaderSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function selectHeadersForMultipart($accept, $accessToken)
*/
private function selectAcceptHeader($accept)
{
if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) {
$countAccept = $accept ? count($accept) : 0;
if ($countAccept === 0 || $countAccept === 1 && $accept[0] === '') {
return null;
} elseif ($jsonAccept = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept)) {
return implode(',', $jsonAccept);
Expand All @@ -99,7 +100,8 @@ private function selectAcceptHeader($accept)
*/
private function selectContentTypeHeader($contentType)
{
if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) {
$countContentType = $contentType ? count($contentType) : 0;
if ( $countContentType === 0 || $countContentType === 1 && $contentType[0] === '') {
return 'application/json';
} elseif (preg_grep("/application\/json/i", $contentType)) {
return 'application/json';
Expand Down

0 comments on commit 37d2cca

Please sign in to comment.