From 3fdf6fed96b48886b3ef5187cbf7238150bb8255 Mon Sep 17 00:00:00 2001 From: Dwarfex Date: Thu, 15 Apr 2021 00:52:56 +0200 Subject: [PATCH] fix broken array_key_exists on ArrayAccess The parent class Json Model extends the Laminas View Model that implements the getVariables function with following type: array|ArrayAccess|Traversable As $this->variables may be an implementation of ArrayAccess, calling array_key_exists() on $this->variables throws an error (with PHP 8.0) see also: https://www.php.net/manual/de/class.arrayaccess.php#104061 --- src/ViewModel.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ViewModel.php b/src/ViewModel.php index 167960d..6272265 100644 --- a/src/ViewModel.php +++ b/src/ViewModel.php @@ -2,19 +2,18 @@ namespace Laminas\ApiTools\Documentation\Swagger; +use ArrayAccess; use Laminas\ApiTools\ContentNegotiation\JsonModel; use Traversable; -use function array_key_exists; - class ViewModel extends JsonModel { /** - * @return array|Traversable + * @return array|Traversable|ArrayAccess */ public function getVariables() { - if (! array_key_exists('type', $this->variables) || empty($this->variables['type'])) { + if (empty($this->variables['type'] || ! $this->variables->offsetExists('type'))) { return $this->variables; }