From b36f25e2a523d79965ec6da8b534dc776e703c83 Mon Sep 17 00:00:00 2001 From: gggeek Date: Thu, 2 Feb 2023 08:28:13 +0000 Subject: [PATCH] fix structeach on php 8.0 and later --- src/Value.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Value.php b/src/Value.php index 0a5c7cb3..5d13ea13 100644 --- a/src/Value.php +++ b/src/Value.php @@ -619,8 +619,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess /** * Return next member element for xml-rpc values of type struct. * - * @return Value - * @throws \Error starting with php 8.0, this function should not be used, as it will always throw + * @return array having the same format as PHP's `each` method * * @deprecated iterate directly over the object using foreach instead */ @@ -628,11 +627,14 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess { $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated'); - return @each($this->me['struct']); + $key = key($this->me['struct']); + $value = current($this->me['struct']); + next($this->me['struct']); + return array(1 => $value, 'value' => $value, 0 => $key, 'key' => $key); } /** - * Returns the m-th member of an xml-rpc value of array type. + * Returns the n-th member of an xml-rpc value of array type. * * @param integer $key the index of the value to be retrieved (zero based) * -- 2.47.0