From bfe33d7d080fb317e6650cf1682ed1f412dbf13a Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 20 Jan 2022 09:33:58 +1100 Subject: [PATCH] php 7.0 support instead of using the void return type, add more ReturnTypeWillChange annotations --- php/composer.json | 2 +- php/src/Google/Protobuf/Internal/MapField.php | 6 ++++-- php/src/Google/Protobuf/Internal/MapFieldIter.php | 6 ++++-- php/src/Google/Protobuf/Internal/RepeatedField.php | 6 ++++-- php/src/Google/Protobuf/Internal/RepeatedFieldIter.php | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/php/composer.json b/php/composer.json index d0d50ce713..71a1e758f1 100644 --- a/php/composer.json +++ b/php/composer.json @@ -6,7 +6,7 @@ "homepage": "https://developers.google.com/protocol-buffers/", "license": "BSD-3-Clause", "require": { - "php": ">=7.1.0", + "php": ">=7.0.0", "ext-bcmath": "*" }, "require-dev": { diff --git a/php/src/Google/Protobuf/Internal/MapField.php b/php/src/Google/Protobuf/Internal/MapField.php index 20ac6c2d66..86463a9a47 100644 --- a/php/src/Google/Protobuf/Internal/MapField.php +++ b/php/src/Google/Protobuf/Internal/MapField.php @@ -154,7 +154,8 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable * @throws \ErrorException Invalid type for value. * @throws \ErrorException Non-existing key. */ - public function offsetSet($key, $value): void + #[\ReturnTypeWillChange] + public function offsetSet($key, $value) { $this->checkKey($this->key_type, $key); @@ -212,7 +213,8 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable * @return void * @throws \ErrorException Invalid type for key. */ - public function offsetUnset($key): void + #[\ReturnTypeWillChange] + public function offsetUnset($key) { $this->checkKey($this->key_type, $key); unset($this->container[$key]); diff --git a/php/src/Google/Protobuf/Internal/MapFieldIter.php b/php/src/Google/Protobuf/Internal/MapFieldIter.php index 8370787876..a3c834bd2c 100644 --- a/php/src/Google/Protobuf/Internal/MapFieldIter.php +++ b/php/src/Google/Protobuf/Internal/MapFieldIter.php @@ -68,7 +68,8 @@ class MapFieldIter implements \Iterator * * @return void */ - public function rewind(): void + #[\ReturnTypeWillChange] + public function rewind() { reset($this->container); } @@ -119,7 +120,8 @@ class MapFieldIter implements \Iterator * * @return void */ - public function next(): void + #[\ReturnTypeWillChange] + public function next() { next($this->container); } diff --git a/php/src/Google/Protobuf/Internal/RepeatedField.php b/php/src/Google/Protobuf/Internal/RepeatedField.php index e589b644fe..704123ad15 100644 --- a/php/src/Google/Protobuf/Internal/RepeatedField.php +++ b/php/src/Google/Protobuf/Internal/RepeatedField.php @@ -140,7 +140,8 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable * @throws \ErrorException Non-existing index. * @throws \ErrorException Incorrect type of the element. */ - public function offsetSet($offset, $value): void + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) { switch ($this->type) { case GPBType::SFIXED32: @@ -211,7 +212,8 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable * @throws \ErrorException The element to be removed is not at the end of the * RepeatedField. */ - public function offsetUnset($offset): void + #[\ReturnTypeWillChange] + public function offsetUnset($offset) { $count = count($this->container); if (!is_numeric($offset) || $count === 0 || $offset !== $count - 1) { diff --git a/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php b/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php index ad86f95f94..3c85869989 100644 --- a/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php +++ b/php/src/Google/Protobuf/Internal/RepeatedFieldIter.php @@ -71,7 +71,8 @@ class RepeatedFieldIter implements \Iterator * * @return void */ - public function rewind(): void + #[\ReturnTypeWillChange] + public function rewind() { $this->position = 0; } @@ -103,7 +104,8 @@ class RepeatedFieldIter implements \Iterator * * @return void */ - public function next(): void + #[\ReturnTypeWillChange] + public function next() { ++$this->position; }