From 591a8152da1e887ceaefc5226af09d17af034986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timi-Artturi=20M=C3=A4kel=C3=A4?= Date: Wed, 25 Jan 2023 11:16:28 +0200 Subject: [PATCH] Automatic conversion of false to array is deprecated hotfix --- CHANGELOG.md | 7 +++++++ src/Renderer/Dust.php | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba05cd..50a18ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +[unreleased] + +[php-81-automatic-conversion-hotfix] +### Fixed +- Fixes "Automatic conversion of false to array is deprecated" on Dust.php + +[released] ## [1.38.1] ### Fixed diff --git a/src/Renderer/Dust.php b/src/Renderer/Dust.php index bfa351c..a58c4bf 100644 --- a/src/Renderer/Dust.php +++ b/src/Renderer/Dust.php @@ -73,6 +73,12 @@ public function __construct( string $template ) { public function render( array $fields ) : string { $compiled = self::$dust->compileFile( $this->template ); + // In same cases this might be false. + // We need to set key as an array after PHP 8.1 in these situations. + if ( empty( $fields['data'] ) ) { + $fields['data'] = []; + } + // Pass on the block data $fields['data']['block'] = $fields['block'];