Skip to content

Commit

Permalink
Fix incompatibilities with some null values for PHP 8.1 (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
W0rma authored Jan 30, 2022
1 parent 9785ce2 commit 68e9ea0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Negotiation/BaseAccept.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ public function hasParameter($key)

/**
*
* @param string $acceptPart
* @param string|null $acceptPart
* @return array
*/
private function parseParameters($acceptPart)
{
if ($acceptPart === null) {
return ['', []];
}

$parts = explode(';', $acceptPart);
$type = array_shift($parts);

Expand Down
4 changes: 2 additions & 2 deletions src/Negotiation/LanguageNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ protected function match(AcceptHeader $acceptLanguage, AcceptHeader $priority, $
$as = $acceptLanguage->getSubPart();
$ps = $priority->getSubPart();

$baseEqual = !strcasecmp($ab, $pb);
$subEqual = !strcasecmp($as, $ps);
$baseEqual = !strcasecmp((string)$ab, (string)$pb);
$subEqual = !strcasecmp((string)$as, (string)$ps);

if (($ab == '*' || $baseEqual) && ($as === null || $subEqual || null === $ps)) {
$score = 10 * $baseEqual + $subEqual;
Expand Down

0 comments on commit 68e9ea0

Please sign in to comment.