From e7284d85140825b85f717384976589504e038bf6 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 13 Apr 2022 13:45:58 +1200 Subject: [PATCH] ENH PHP 8.1 compatibility --- src/Filter/SlugFilter.php | 4 ++-- tests/SegmentFieldTest.php | 2 +- tests/SegmentFieldTestModifier.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Filter/SlugFilter.php b/src/Filter/SlugFilter.php index 4e52de5..d1fd5d9 100644 --- a/src/Filter/SlugFilter.php +++ b/src/Filter/SlugFilter.php @@ -33,11 +33,11 @@ public function filter($value) } foreach ($replacements as $regex => $replace) { - $value = preg_replace($regex, $replace, $value); + $value = preg_replace($regex ?? '', $replace ?? '', $value ?? ''); } if ($this->getAllowMultibyte()) { - $value = rawurlencode($value); + $value = rawurlencode($value ?? ''); } return $value; diff --git a/tests/SegmentFieldTest.php b/tests/SegmentFieldTest.php index c7af611..20ffddc 100644 --- a/tests/SegmentFieldTest.php +++ b/tests/SegmentFieldTest.php @@ -20,7 +20,7 @@ public function testSuggest() )); $encoded = $field->suggest($this->getNewRequestMock()); - $decoded = json_decode($encoded); + $decoded = json_decode($encoded ?? ''); $this->assertEquals('ARRAY-SUGGESTION', $decoded->suggestion); $this->assertEquals('array-preview', $decoded->preview); diff --git a/tests/SegmentFieldTestModifier.php b/tests/SegmentFieldTestModifier.php index 93714b8..58a6ab9 100644 --- a/tests/SegmentFieldTestModifier.php +++ b/tests/SegmentFieldTestModifier.php @@ -15,7 +15,7 @@ class SegmentFieldTestModifier extends AbstractSegmentFieldModifier */ public function getSuggestion($value) { - return strtoupper($value); + return strtoupper($value ?? ''); } /** @@ -27,6 +27,6 @@ public function getSuggestion($value) */ public function getPreview($value) { - return strtolower($value); + return strtolower($value ?? ''); } }