Merge pull request #9370 from brettmc/bugfix/php-8.1-deprecations

fixing php 8.1 deprecation warnings
pull/9218/head^2
Joshua Haberman 3 years ago committed by GitHub
commit 8c8fb0ec97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      kokoro/linux/dockerfile/test/php80/Dockerfile
  2. 81
      php/ext/google/protobuf/array.c
  3. 78
      php/ext/google/protobuf/map.c
  4. 36
      php/ext/google/protobuf/protobuf.h
  5. 1
      php/src/Google/Protobuf/Internal/GPBUtil.php
  6. 2
      php/src/Google/Protobuf/Internal/GPBWire.php
  7. 11
      php/src/Google/Protobuf/Internal/MapField.php
  8. 10
      php/src/Google/Protobuf/Internal/MapFieldIter.php
  9. 10
      php/src/Google/Protobuf/Internal/RepeatedField.php
  10. 6
      php/src/Google/Protobuf/Internal/RepeatedFieldIter.php
  11. 6
      tests.sh

@ -1,4 +1,4 @@
FROM debian:jessie
FROM debian:stretch
# Install dependencies. We start with the basic ones require to build protoc
# and the C++ build
@ -29,7 +29,7 @@ RUN apt-get update && apt-get install -y \
# Install php dependencies
RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
php5 \
php \
libcurl4-openssl-dev \
libgmp-dev \
libgmp3-dev \
@ -90,6 +90,34 @@ RUN wget -O phpunit https://phar.phpunit.de/phpunit-9.phar \
&& cp phpunit /usr/local/php-8.0/bin \
&& mv phpunit /usr/local/php-8.0-zts/bin
# php 8.1
RUN cd php-src \
&& git checkout php-8.1.2 \
&& ./buildconf --force
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--enable-mbstring \
--with-gmp \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-8.1 \
&& make \
&& make install \
&& make clean
RUN cd php-src \
&& ./configure \
--enable-bcmath \
--enable-mbstring \
--enable-maintainer-zts \
--with-gmp \
--with-openssl \
--with-zlib \
--prefix=/usr/local/php-8.1-zts \
&& make \
&& make install \
&& make clean
# Install php dependencies
RUN apt-get clean && apt-get update && apt-get install -y --force-yes \
valgrind \

@ -287,7 +287,7 @@ PHP_METHOD(RepeatedField, append) {
}
/**
* RepeatedField::offsetExists()
* RepeatedField::offsetExists(): bool
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -309,7 +309,7 @@ PHP_METHOD(RepeatedField, offsetExists) {
}
/**
* RepeatedField::offsetGet()
* RepeatedField::offsetGet(): mixed
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -341,7 +341,7 @@ PHP_METHOD(RepeatedField, offsetGet) {
}
/**
* RepeatedField::offsetSet()
* RepeatedField::offsetSet(): void
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -386,7 +386,7 @@ PHP_METHOD(RepeatedField, offsetSet) {
}
/**
* RepeatedField::offsetUnset()
* RepeatedField::offsetUnset(): void
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -416,7 +416,7 @@ PHP_METHOD(RepeatedField, offsetUnset) {
}
/**
* RepeatedField::count()
* RepeatedField::count(): int
*
* Implements the Countable interface. Invoked when PHP code calls:
*
@ -436,7 +436,7 @@ PHP_METHOD(RepeatedField, count) {
}
/**
* RepeatedField::getIterator()
* RepeatedField::getIterator(): Traversable
*
* Implements the IteratorAggregate interface. Invoked when PHP code calls:
*
@ -459,24 +459,38 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_append, 0, 0, 1)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_offsetExists, 0, 0, _IS_BOOL, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetSet, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_offsetGet, 0, 0, IS_MIXED, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_offsetSet, 0, 2, IS_VOID, 0)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_offsetUnset, 0, 0, IS_VOID, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_count, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_getIterator, 0, 0, Traversable, 0)
ZEND_END_ARG_INFO()
static zend_function_entry repeated_field_methods[] = {
PHP_ME(RepeatedField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, append, arginfo_append, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetUnset, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, count, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, getIterator, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, append, arginfo_append, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetExists, arginfo_offsetExists, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, offsetUnset, arginfo_offsetUnset, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, count, arginfo_count, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedField, getIterator, arginfo_getIterator, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
@ -550,7 +564,7 @@ static void RepeatedFieldIter_make(zval *val, zval *repeated_field) {
*/
/**
* RepeatedFieldIter::rewind()
* RepeatedFieldIter::rewind(): void
*
* Implements the Iterator interface. Sets the iterator to the first element.
*/
@ -560,7 +574,7 @@ PHP_METHOD(RepeatedFieldIter, rewind) {
}
/**
* RepeatedFieldIter::current()
* RepeatedFieldIter::current(): mixed
*
* Implements the Iterator interface. Returns the current value.
*/
@ -583,7 +597,7 @@ PHP_METHOD(RepeatedFieldIter, current) {
}
/**
* RepeatedFieldIter::key()
* RepeatedFieldIter::key(): mixed
*
* Implements the Iterator interface. Returns the current key.
*/
@ -593,7 +607,7 @@ PHP_METHOD(RepeatedFieldIter, key) {
}
/**
* RepeatedFieldIter::next()
* RepeatedFieldIter::next(): void
*
* Implements the Iterator interface. Advances to the next element.
*/
@ -603,7 +617,7 @@ PHP_METHOD(RepeatedFieldIter, next) {
}
/**
* RepeatedFieldIter::valid()
* RepeatedFieldIter::valid(): bool
*
* Implements the Iterator interface. Returns true if this is a valid element.
*/
@ -613,12 +627,27 @@ PHP_METHOD(RepeatedFieldIter, valid) {
RETURN_BOOL(intern->position < upb_array_size(field->array));
}
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_current, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_key, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_next, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_valid, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rewind, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
static zend_function_entry repeated_field_iter_methods[] = {
PHP_ME(RepeatedFieldIter, rewind, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, current, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, key, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, next, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, valid, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, rewind, arginfo_rewind, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, current, arginfo_current, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, key, arginfo_key, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, next, arginfo_next, ZEND_ACC_PUBLIC)
PHP_ME(RepeatedFieldIter, valid, arginfo_valid, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

@ -305,7 +305,7 @@ PHP_METHOD(MapField, __construct) {
}
/**
* MapField::offsetExists()
* MapField::offsetExists(): bool
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -329,7 +329,7 @@ PHP_METHOD(MapField, offsetExists) {
}
/**
* MapField::offsetGet()
* MapField::offsetGet(): mixed
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -361,7 +361,7 @@ PHP_METHOD(MapField, offsetGet) {
}
/**
* MapField::offsetSet()
* MapField::offsetSet(): void
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -389,7 +389,7 @@ PHP_METHOD(MapField, offsetSet) {
}
/**
* MapField::offsetUnset()
* MapField::offsetUnset(): void
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
@ -413,7 +413,7 @@ PHP_METHOD(MapField, offsetUnset) {
}
/**
* MapField::count()
* MapField::count(): int
*
* Implements the Countable interface. Invoked when PHP code calls:
*
@ -433,7 +433,7 @@ PHP_METHOD(MapField, count) {
}
/**
* MapField::getIterator()
* MapField::getIterator(): Traversable
*
* Implements the IteratorAggregate interface. Invoked when PHP code calls:
*
@ -453,23 +453,38 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 2)
ZEND_ARG_INFO(0, value_class)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_offsetGet, 0, 0, IS_MIXED, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetSet, 0, 0, 2)
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_offsetSet, 0, 2, IS_VOID, 0)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_offsetUnset, 0, 0, IS_VOID, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_offsetExists, 0, 0, _IS_BOOL, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_getIterator, 0, 0, Traversable, 0)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_count, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
static zend_function_entry MapField_methods[] = {
PHP_ME(MapField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetExists, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetUnset, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, count, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(MapField, getIterator, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(MapField, __construct, arginfo_construct, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetExists, arginfo_offsetExists, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetGet, arginfo_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetSet, arginfo_offsetSet, ZEND_ACC_PUBLIC)
PHP_ME(MapField, offsetUnset, arginfo_offsetUnset, ZEND_ACC_PUBLIC)
PHP_ME(MapField, count, arginfo_count, ZEND_ACC_PUBLIC)
PHP_ME(MapField, getIterator, arginfo_getIterator, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
@ -547,7 +562,7 @@ static void MapFieldIter_make(zval *val, zval *map_field) {
*/
/**
* MapFieldIter::rewind()
* MapFieldIter::rewind(): void
*
* Implements the Iterator interface. Sets the iterator to the first element.
*/
@ -559,7 +574,7 @@ PHP_METHOD(MapFieldIter, rewind) {
}
/**
* MapFieldIter::current()
* MapFieldIter::current(): mixed
*
* Implements the Iterator interface. Returns the current value.
*/
@ -587,7 +602,7 @@ PHP_METHOD(MapFieldIter, key) {
}
/**
* MapFieldIter::next()
* MapFieldIter::next(): void
*
* Implements the Iterator interface. Advances to the next element.
*/
@ -598,7 +613,7 @@ PHP_METHOD(MapFieldIter, next) {
}
/**
* MapFieldIter::valid()
* MapFieldIter::valid(): bool
*
* Implements the Iterator interface. Returns true if this is a valid element.
*/
@ -609,12 +624,27 @@ PHP_METHOD(MapFieldIter, valid) {
RETURN_BOOL(!done);
}
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rewind, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_current, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_key, 0, 0, IS_MIXED, 0)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_next, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_valid, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
static zend_function_entry map_field_iter_methods[] = {
PHP_ME(MapFieldIter, rewind, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, current, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, key, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, next, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, valid, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, rewind, arginfo_rewind, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, current, arginfo_current, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, key, arginfo_key, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, next, arginfo_next, ZEND_ACC_PUBLIC)
PHP_ME(MapFieldIter, valid, arginfo_valid, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

@ -82,6 +82,42 @@ const zval *get_generated_pool();
// PHP 7.2.0.
#if PHP_VERSION_ID < 70200
#define zend_ce_countable spl_ce_Countable
#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \
ZEND_BEGIN_ARG_INFO_EX(name, return_reference, required_num_args, allow_null)
#endif
// polyfill for ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX, which changes between 7.1 and 7.2
#if PHP_VERSION_ID < 70200
#define PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, /*class_name*/ 0, allow_null)
#else
#define PROTOBUF_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)
#endif
// In PHP 8.1, mismatched tentative return types emit a deprecation notice.
// https://wiki.php.net/rfc/internal_method_return_types
//
// When compiling for earlier php versions, the return type is dropped.
#if PHP_VERSION_ID < 80100
#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
ZEND_BEGIN_ARG_INFO_EX(name, return_reference, required_num_args, allow_null)
#endif
#ifndef IS_VOID
#define IS_VOID 99
#endif
#ifndef IS_MIXED
#define IS_MIXED 99
#endif
#ifndef _IS_BOOL
#define _IS_BOOL 99
#endif
#ifndef IS_LONG
#define IS_LONG 99
#endif
ZEND_BEGIN_ARG_INFO(arginfo_void, 0)

@ -37,6 +37,7 @@ use Google\Protobuf\FieldMask;
use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\MapField;
use function bccomp;
function camel2underscore($input) {
preg_match_all(

@ -146,7 +146,7 @@ class GPBWire
return bcsub(bcmul(bcsub(0, $int64), 2), 1);
}
} else {
return ($int64 << 1) ^ ($int64 >> 63);
return ((int)$int64 << 1) ^ ((int)$int64 >> 63);
}
}

@ -37,6 +37,8 @@
namespace Google\Protobuf\Internal;
use Traversable;
/**
* MapField is used by generated protocol message classes to manipulate map
* fields. It can be used like native PHP array.
@ -134,6 +136,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->container[$key];
@ -151,6 +154,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
* @throws \ErrorException Invalid type for value.
* @throws \ErrorException Non-existing key.
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
$this->checkKey($this->key_type, $key);
@ -209,6 +213,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
* @return void
* @throws \ErrorException Invalid type for key.
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
$this->checkKey($this->key_type, $key);
@ -224,7 +229,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
* @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]);
@ -233,7 +238,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* @ignore
*/
public function getIterator()
public function getIterator(): Traversable
{
return new MapFieldIter($this->container, $this->key_type);
}
@ -245,7 +250,7 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
*
* @return integer The number of stored elements.
*/
public function count()
public function count(): int
{
return count($this->container);
}

@ -68,9 +68,10 @@ class MapFieldIter implements \Iterator
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
return reset($this->container);
reset($this->container);
}
/**
@ -78,6 +79,7 @@ class MapFieldIter implements \Iterator
*
* @return object The element at the current position.
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->container);
@ -88,6 +90,7 @@ class MapFieldIter implements \Iterator
*
* @return object The current key.
*/
#[\ReturnTypeWillChange]
public function key()
{
$key = key($this->container);
@ -117,9 +120,10 @@ class MapFieldIter implements \Iterator
*
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
{
return next($this->container);
next($this->container);
}
/**
@ -127,7 +131,7 @@ class MapFieldIter implements \Iterator
*
* @return bool True if there are more elements to iterate.
*/
public function valid()
public function valid(): bool
{
return key($this->container) !== null;
}

@ -39,6 +39,7 @@ namespace Google\Protobuf\Internal;
use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\GPBUtil;
use Traversable;
/**
* RepeatedField is used by generated protocol message classes to manipulate
@ -121,6 +122,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
* @throws \ErrorException Invalid type for index.
* @throws \ErrorException Non-existing index.
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->container[$offset];
@ -138,6 +140,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
* @throws \ErrorException Non-existing index.
* @throws \ErrorException Incorrect type of the element.
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
switch ($this->type) {
@ -209,6 +212,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
* @throws \ErrorException The element to be removed is not at the end of the
* RepeatedField.
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
$count = count($this->container);
@ -230,7 +234,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
* @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]);
}
@ -238,7 +242,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* @ignore
*/
public function getIterator()
public function getIterator(): Traversable
{
return new RepeatedFieldIter($this->container);
}
@ -250,7 +254,7 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
*
* @return integer The number of stored elements.
*/
public function count()
public function count(): int
{
return count($this->container);
}

@ -71,6 +71,7 @@ class RepeatedFieldIter implements \Iterator
*
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->position = 0;
@ -81,6 +82,7 @@ class RepeatedFieldIter implements \Iterator
*
* @return object The element at the current position.
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->container[$this->position];
@ -91,6 +93,7 @@ class RepeatedFieldIter implements \Iterator
*
* @return integer The current position.
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->position;
@ -101,6 +104,7 @@ class RepeatedFieldIter implements \Iterator
*
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
{
++$this->position;
@ -111,7 +115,7 @@ class RepeatedFieldIter implements \Iterator
*
* @return bool True if there are more elements to iterate.
*/
public function valid()
public function valid(): bool
{
return isset($this->container[$this->position]);
}

@ -496,6 +496,8 @@ build_php() {
use_php $1
pushd php
rm -rf vendor
php -v
php -m
composer update
composer test
popd
@ -505,6 +507,8 @@ build_php() {
test_php_c() {
pushd php
rm -rf vendor
php -v
php -m
composer update
composer test_c
popd
@ -572,7 +576,9 @@ build_php_multirequest() {
build_php8.0_all() {
build_php 8.0
build_php 8.1
build_php_c 8.0
build_php_c 8.1
}
build_php_all_32() {

Loading…
Cancel
Save