Skip to content

Commit

Permalink
Merge pull request #9370 from brettmc/bugfix/php-8.1-deprecations
Browse files Browse the repository at this point in the history
fixing php 8.1 deprecation warnings
  • Loading branch information
haberman committed Feb 2, 2022
2 parents 55645ca + 4c03fcf commit 8c8fb0e
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 63 deletions.
32 changes: 30 additions & 2 deletions kokoro/linux/dockerfile/test/php80/Dockerfile
@@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
81 changes: 55 additions & 26 deletions php/ext/google/protobuf/array.c
Expand Up @@ -287,7 +287,7 @@ PHP_METHOD(RepeatedField, append) {
}

/**
* RepeatedField::offsetExists()
* RepeatedField::offsetExists(): bool
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
Expand All @@ -309,7 +309,7 @@ PHP_METHOD(RepeatedField, offsetExists) {
}

/**
* RepeatedField::offsetGet()
* RepeatedField::offsetGet(): mixed
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
Expand Down Expand Up @@ -341,7 +341,7 @@ PHP_METHOD(RepeatedField, offsetGet) {
}

/**
* RepeatedField::offsetSet()
* RepeatedField::offsetSet(): void
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
Expand Down Expand Up @@ -386,7 +386,7 @@ PHP_METHOD(RepeatedField, offsetSet) {
}

/**
* RepeatedField::offsetUnset()
* RepeatedField::offsetUnset(): void
*
* Implements the ArrayAccess interface. Invoked when PHP code calls:
*
Expand Down Expand Up @@ -416,7 +416,7 @@ PHP_METHOD(RepeatedField, offsetUnset) {
}

/**
* RepeatedField::count()
* RepeatedField::count(): int
*
* Implements the Countable interface. Invoked when PHP code calls:
*
Expand All @@ -436,7 +436,7 @@ PHP_METHOD(RepeatedField, count) {
}

/**
* RepeatedField::getIterator()
* RepeatedField::getIterator(): Traversable
*
* Implements the IteratorAggregate interface. Invoked when PHP code calls:
*
Expand All @@ -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
};

Expand Down Expand Up @@ -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.
*/
Expand All @@ -560,7 +574,7 @@ PHP_METHOD(RepeatedFieldIter, rewind) {
}

/**
* RepeatedFieldIter::current()
* RepeatedFieldIter::current(): mixed
*
* Implements the Iterator interface. Returns the current value.
*/
Expand All @@ -583,7 +597,7 @@ PHP_METHOD(RepeatedFieldIter, current) {
}

/**
* RepeatedFieldIter::key()
* RepeatedFieldIter::key(): mixed
*
* Implements the Iterator interface. Returns the current key.
*/
Expand All @@ -593,7 +607,7 @@ PHP_METHOD(RepeatedFieldIter, key) {
}

/**
* RepeatedFieldIter::next()
* RepeatedFieldIter::next(): void
*
* Implements the Iterator interface. Advances to the next element.
*/
Expand All @@ -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.
*/
Expand All @@ -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
};

Expand Down

0 comments on commit 8c8fb0e

Please sign in to comment.