Skip to content

Commit

Permalink
protocolbuffers#9293 - fix Missing function's return type declaration…
Browse files Browse the repository at this point in the history
… (incompatible return type php 8.1)
  • Loading branch information
oleg1540 committed Dec 13, 2021
1 parent 29b3d01 commit c7e9b8d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions php/src/Google/Protobuf/Internal/MapField.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function getLegacyValueClass()
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
*/
public function offsetGet($key)
public function offsetGet($key): object
{
return $this->container[$key];
}
Expand All @@ -151,7 +151,7 @@ public function offsetGet($key)
* @throws \ErrorException Invalid type for value.
* @throws \ErrorException Non-existing key.
*/
public function offsetSet($key, $value)
public function offsetSet($key, $value): void
{
$this->checkKey($this->key_type, $key);

Expand Down Expand Up @@ -209,7 +209,7 @@ public function offsetSet($key, $value)
* @return void
* @throws \ErrorException Invalid type for key.
*/
public function offsetUnset($key)
public function offsetUnset($key): void
{
$this->checkKey($this->key_type, $key);
unset($this->container[$key]);
Expand All @@ -224,7 +224,7 @@ public function offsetUnset($key)
* @return bool True if the element at the given key exists.
* @throws \ErrorException Invalid type for key.
*/
public function offsetExists($key)
public function offsetExists($key): bool
{
$this->checkKey($this->key_type, $key);
return isset($this->container[$key]);
Expand All @@ -233,7 +233,7 @@ public function offsetExists($key)
/**
* @ignore
*/
public function getIterator()
public function getIterator(): MapFieldIter
{
return new MapFieldIter($this->container, $this->key_type);
}
Expand All @@ -245,7 +245,7 @@ public function getIterator()
*
* @return integer The number of stored elements.
*/
public function count()
public function count(): int
{
return count($this->container);
}
Expand Down
14 changes: 7 additions & 7 deletions php/src/Google/Protobuf/Internal/MapFieldIter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ public function __construct($container, $key_type)
*
* @return void
*/
public function rewind()
public function rewind(): void
{
return reset($this->container);
reset($this->container);
}

/**
* Return the element at the current position.
*
* @return object The element at the current position.
*/
public function current()
public function current(): object
{
return current($this->container);
}
Expand All @@ -88,7 +88,7 @@ public function current()
*
* @return object The current key.
*/
public function key()
public function key(): object
{
$key = key($this->container);
switch ($this->key_type) {
Expand Down Expand Up @@ -117,17 +117,17 @@ public function key()
*
* @return void
*/
public function next()
public function next(): void
{
return next($this->container);
next($this->container);
}

/**
* Check whether there are more elements to iterate.
*
* @return bool True if there are more elements to iterate.
*/
public function valid()
public function valid(): bool
{
return key($this->container) !== null;
}
Expand Down
12 changes: 6 additions & 6 deletions php/src/Google/Protobuf/Internal/RepeatedField.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getLegacyClass()
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
*/
public function offsetGet($offset)
public function offsetGet($offset): object
{
return $this->container[$offset];
}
Expand All @@ -138,7 +138,7 @@ public function offsetGet($offset)
* @throws \ErrorException Non-existing index.
* @throws \ErrorException Incorrect type of the element.
*/
public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
switch ($this->type) {
case GPBType::SFIXED32:
Expand Down Expand Up @@ -209,7 +209,7 @@ public function offsetSet($offset, $value)
* @throws \ErrorException The element to be removed is not at the end of the
* RepeatedField.
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
$count = count($this->container);
if (!is_numeric($offset) || $count === 0 || $offset !== $count - 1) {
Expand All @@ -230,15 +230,15 @@ public function offsetUnset($offset)
* @return bool True if the element at the given offset exists.
* @throws \ErrorException Invalid type for index.
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->container[$offset]);
}

/**
* @ignore
*/
public function getIterator()
public function getIterator(): RepeatedFieldIter
{
return new RepeatedFieldIter($this->container);
}
Expand All @@ -250,7 +250,7 @@ public function getIterator()
*
* @return integer The number of stored elements.
*/
public function count()
public function count(): int
{
return count($this->container);
}
Expand Down
10 changes: 5 additions & 5 deletions php/src/Google/Protobuf/Internal/RepeatedFieldIter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct($container)
*
* @return void
*/
public function rewind()
public function rewind(): void
{
$this->position = 0;
}
Expand All @@ -81,7 +81,7 @@ public function rewind()
*
* @return object The element at the current position.
*/
public function current()
public function current(): object
{
return $this->container[$this->position];
}
Expand All @@ -91,7 +91,7 @@ public function current()
*
* @return integer The current position.
*/
public function key()
public function key(): int
{
return $this->position;
}
Expand All @@ -101,7 +101,7 @@ public function key()
*
* @return void
*/
public function next()
public function next(): void
{
++$this->position;
}
Expand All @@ -111,7 +111,7 @@ public function next()
*
* @return bool True if there are more elements to iterate.
*/
public function valid()
public function valid(): bool
{
return isset($this->container[$this->position]);
}
Expand Down

0 comments on commit c7e9b8d

Please sign in to comment.