Skip to content

Commit 68e9ea0

Browse files
authored
Fix incompatibilities with some null values for PHP 8.1 (#114)
1 parent 9785ce2 commit 68e9ea0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Negotiation/BaseAccept.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,15 @@ public function hasParameter($key)
112112

113113
/**
114114
*
115-
* @param string $acceptPart
115+
* @param string|null $acceptPart
116116
* @return array
117117
*/
118118
private function parseParameters($acceptPart)
119119
{
120+
if ($acceptPart === null) {
121+
return ['', []];
122+
}
123+
120124
$parts = explode(';', $acceptPart);
121125
$type = array_shift($parts);
122126

src/Negotiation/LanguageNegotiator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ protected function match(AcceptHeader $acceptLanguage, AcceptHeader $priority, $
2727
$as = $acceptLanguage->getSubPart();
2828
$ps = $priority->getSubPart();
2929

30-
$baseEqual = !strcasecmp($ab, $pb);
31-
$subEqual = !strcasecmp($as, $ps);
30+
$baseEqual = !strcasecmp((string)$ab, (string)$pb);
31+
$subEqual = !strcasecmp((string)$as, (string)$ps);
3232

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

0 commit comments

Comments
 (0)