Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 8.1 compatibility #9359

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions php/src/Google/Protobuf/Internal/MapField.php
Expand Up @@ -134,6 +134,7 @@ public function getLegacyValueClass()
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->container[$key];
Expand All @@ -151,6 +152,7 @@ public function offsetGet($key)
* @throws \ErrorException Invalid type for value.
* @throws \ErrorException Non-existing key.
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
$this->checkKey($this->key_type, $key);
Expand Down Expand Up @@ -209,6 +211,7 @@ public function offsetSet($key, $value)
* @return void
* @throws \ErrorException Invalid type for key.
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
$this->checkKey($this->key_type, $key);
Expand All @@ -224,6 +227,7 @@ public function offsetUnset($key)
* @return bool True if the element at the given key exists.
* @throws \ErrorException Invalid type for key.
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
$this->checkKey($this->key_type, $key);
Expand All @@ -233,6 +237,7 @@ public function offsetExists($key)
/**
* @ignore
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new MapFieldIter($this->container, $this->key_type);
Expand All @@ -245,6 +250,7 @@ public function getIterator()
*
* @return integer The number of stored elements.
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->container);
Expand Down
5 changes: 5 additions & 0 deletions php/src/Google/Protobuf/Internal/MapFieldIter.php
Expand Up @@ -68,6 +68,7 @@ public function __construct($container, $key_type)
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
return reset($this->container);
Expand All @@ -78,6 +79,7 @@ public function rewind()
*
* @return object The element at the current position.
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->container);
Expand All @@ -88,6 +90,7 @@ public function current()
*
* @return object The current key.
*/
#[\ReturnTypeWillChange]
public function key()
{
$key = key($this->container);
Expand Down Expand Up @@ -117,6 +120,7 @@ public function key()
*
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
{
return next($this->container);
Expand All @@ -127,6 +131,7 @@ public function next()
*
* @return bool True if there are more elements to iterate.
*/
#[\ReturnTypeWillChange]
public function valid()
{
return key($this->container) !== null;
Expand Down
6 changes: 6 additions & 0 deletions php/src/Google/Protobuf/Internal/RepeatedField.php
Expand Up @@ -121,6 +121,7 @@ public function getLegacyClass()
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->container[$offset];
Expand All @@ -138,6 +139,7 @@ public function offsetGet($offset)
* @throws \ErrorException Non-existing index.
* @throws \ErrorException Incorrect type of the element.
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
switch ($this->type) {
Expand Down Expand Up @@ -209,6 +211,7 @@ public function offsetSet($offset, $value)
* @throws \ErrorException The element to be removed is not at the end of the
* RepeatedField.
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
$count = count($this->container);
Expand All @@ -230,6 +233,7 @@ public function offsetUnset($offset)
* @return bool True if the element at the given offset exists.
* @throws \ErrorException Invalid type for index.
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->container[$offset]);
Expand All @@ -238,6 +242,7 @@ public function offsetExists($offset)
/**
* @ignore
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new RepeatedFieldIter($this->container);
Expand All @@ -250,6 +255,7 @@ public function getIterator()
*
* @return integer The number of stored elements.
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->container);
Expand Down
5 changes: 5 additions & 0 deletions php/src/Google/Protobuf/Internal/RepeatedFieldIter.php
Expand Up @@ -71,6 +71,7 @@ public function __construct($container)
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->position = 0;
Expand All @@ -81,6 +82,7 @@ public function rewind()
*
* @return object The element at the current position.
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->container[$this->position];
Expand All @@ -91,6 +93,7 @@ public function current()
*
* @return integer The current position.
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->position;
Expand All @@ -101,6 +104,7 @@ public function key()
*
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
{
++$this->position;
Expand All @@ -111,6 +115,7 @@ public function next()
*
* @return bool True if there are more elements to iterate.
*/
#[\ReturnTypeWillChange]
public function valid()
{
return isset($this->container[$this->position]);
Expand Down