From 729a4251fa36071c4d9b24065723e0f3c499ba09 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 13 Apr 2022 10:27:04 +1200 Subject: [PATCH] ENH PHP 8.1 compatibility --- src/Block/BannerBlock.php | 2 +- src/Form/BlockLinkField.php | 4 ++-- tests/Behat/Context/FixtureContext.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Block/BannerBlock.php b/src/Block/BannerBlock.php index 17a84a4..c732fee 100644 --- a/src/Block/BannerBlock.php +++ b/src/Block/BannerBlock.php @@ -110,7 +110,7 @@ protected function decodeLinkData($linkJson) return; } - $data = ArrayData::create(json_decode($linkJson)); + $data = ArrayData::create(json_decode($linkJson ?? '')); // Link page, if selected if ($data->PageID) { diff --git a/src/Form/BlockLinkField.php b/src/Form/BlockLinkField.php index 2483675..3dbb98a 100644 --- a/src/Form/BlockLinkField.php +++ b/src/Form/BlockLinkField.php @@ -55,7 +55,7 @@ public function getParsedValue() if ($this->parsedValue) { return $this->parsedValue; } - $parsedValue = json_decode($this->dataValue(), true); + $parsedValue = json_decode($this->dataValue() ?? '', true); return $this->parsedValue = ArrayData::create((array) $parsedValue); } @@ -80,7 +80,7 @@ public function getLinkPage() */ public function getLinkText() { - return trim($this->getParsedValue()->Text); + return trim($this->getParsedValue()->Text ?? ''); } /** * Get the link "description", used for titles or alt text diff --git a/tests/Behat/Context/FixtureContext.php b/tests/Behat/Context/FixtureContext.php index e1323b0..e2bc439 100644 --- a/tests/Behat/Context/FixtureContext.php +++ b/tests/Behat/Context/FixtureContext.php @@ -76,7 +76,7 @@ public function contentBlocksAreNotInLineEditable() $file = 'content-blocks-not-inline-editable.yml'; $path = $this->getDestinationConfigFolder($file); - file_put_contents($path, $config); + file_put_contents($path ?? '', $config); $this->activatedConfigFiles[] = $path;