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

Port for php8 #8105

Merged
merged 7 commits into from Dec 4, 2020
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -137,6 +137,7 @@ conformance/*.class

# php test output
composer.lock
php/.phpunit.result.cache
php/tests/.phpunit.result.cache
php/tests/generated/
php/tests/old_protoc
Expand All @@ -162,6 +163,7 @@ php/ext/google/protobuf/configure.ac
php/ext/google/protobuf/configure.in
php/ext/google/protobuf/mkinstalldirs
php/ext/google/protobuf/run-tests.php
php/ext/google/protobuf/third_party/
vendor/

# JavaScript artifacts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -62,7 +62,7 @@ how to install protobuf runtime for that specific language:
| JavaScript | [js](js) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fjavascript%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fjavascript%2Fcontinuous) | |
| Ruby | [ruby](ruby) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby23.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby23%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby24.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby24%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby25.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby25%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby26.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby26%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-ruby-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fruby_release%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby23.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby23%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby24.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby24%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby25.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby25%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby26.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby26%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-ruby-release.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fruby_release%2Fcontinuous) | |
| Go | [protocolbuffers/protobuf-go](https://github.com/protocolbuffers/protobuf-go) | | | |
| PHP | [php](php) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-php_all.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fphp_all%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-32-bit.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2F32-bit%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-php5.6_mac.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fphp5.6_mac%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-php7.0_mac.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fphp7.0_mac%2Fcontinuous) | |
| PHP | [php](php) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-php_all.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fphp_all%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-32-bit.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2F32-bit%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-php80.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fphp80%2Fcontinuous) | [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-php5.6_mac.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fphp5.6_mac%2Fcontinuous)<br/>[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-php7.0_mac.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fphp7.0_mac%2Fcontinuous) | |
| Dart | [dart-lang/protobuf](https://github.com/dart-lang/protobuf) | [![Build Status](https://travis-ci.org/dart-lang/protobuf.svg?branch=master)](https://travis-ci.org/dart-lang/protobuf) | | |

Quick Start
Expand Down
2 changes: 1 addition & 1 deletion kokoro/linux/php80/build.sh
Expand Up @@ -11,7 +11,7 @@
cd $(dirname $0)/../../..

export DOCKERHUB_ORGANIZATION=protobuftesting
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/php
export DOCKERFILE_DIR=kokoro/linux/dockerfile/test/php80
export DOCKER_RUN_SCRIPT=kokoro/linux/pull_request_in_docker.sh
export OUTPUT_DIR=testoutput
export TEST_SET="php8.0_all"
Expand Down
4 changes: 2 additions & 2 deletions php/composer.json
Expand Up @@ -6,10 +6,10 @@
"homepage": "https://developers.google.com/protocol-buffers/",
"license": "BSD-3-Clause",
"require": {
"php": ">=5.5.0"
"php": ">=7.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops support for 5.5 and 5.6 in the native PHP library. Was this intentional? I see no mention of this anywhere in the PR or README.

},
"require-dev": {
"phpunit/phpunit": "^5|^4.8.0"
"phpunit/phpunit": ">=6.0.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 4 additions & 3 deletions php/ext/google/protobuf/array.c
Expand Up @@ -453,9 +453,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetSet, 0, 0, 2)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_void, 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)
Expand Down Expand Up @@ -636,7 +633,11 @@ void Array_ModuleInit() {
h = &RepeatedField_object_handlers;
memcpy(h, &std_object_handlers, sizeof(zend_object_handlers));
h->dtor_obj = RepeatedField_destructor;
#if PHP_VERSION_ID < 80000
h->compare_objects = RepeatedField_compare_objects;
#else
h->compare = RepeatedField_compare_objects;
#endif
h->get_properties = RepeatedField_GetProperties;
h->get_property_ptr_ptr = RepeatedField_GetPropertyPtrPtr;

Expand Down
61 changes: 33 additions & 28 deletions php/ext/google/protobuf/def.c
Expand Up @@ -103,8 +103,8 @@ PHP_METHOD(EnumValueDescriptor, getNumber) {
}

static zend_function_entry EnumValueDescriptor_methods[] = {
PHP_ME(EnumValueDescriptor, getName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(EnumValueDescriptor, getNumber, NULL, ZEND_ACC_PUBLIC)
PHP_ME(EnumValueDescriptor, getName, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(EnumValueDescriptor, getNumber, arginfo_void, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

Expand Down Expand Up @@ -224,9 +224,9 @@ PHP_METHOD(EnumDescriptor, getPublicDescriptor) {
}

static zend_function_entry EnumDescriptor_methods[] = {
PHP_ME(EnumDescriptor, getPublicDescriptor, NULL, ZEND_ACC_PUBLIC)
PHP_ME(EnumDescriptor, getValueCount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(EnumDescriptor, getValue, NULL, ZEND_ACC_PUBLIC)
PHP_ME(EnumDescriptor, getPublicDescriptor, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(EnumDescriptor, getValueCount, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(EnumDescriptor, getValue, arginfo_void, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

Expand Down Expand Up @@ -316,9 +316,9 @@ PHP_METHOD(OneofDescriptor, getFieldCount) {
}

static zend_function_entry OneofDescriptor_methods[] = {
PHP_ME(OneofDescriptor, getName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(OneofDescriptor, getField, NULL, ZEND_ACC_PUBLIC)
PHP_ME(OneofDescriptor, getFieldCount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(OneofDescriptor, getName, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(OneofDescriptor, getField, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(OneofDescriptor, getFieldCount, arginfo_void, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

Expand Down Expand Up @@ -480,13 +480,13 @@ PHP_METHOD(FieldDescriptor, getMessageType) {
}

static zend_function_entry FieldDescriptor_methods[] = {
PHP_ME(FieldDescriptor, getName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getNumber, NULL, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getLabel, NULL, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getType, NULL, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, isMap, NULL, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getEnumType, NULL, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getMessageType, NULL, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getName, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getNumber, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getLabel, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getType, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, isMap, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getEnumType, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(FieldDescriptor, getMessageType, arginfo_void, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

Expand Down Expand Up @@ -700,13 +700,13 @@ PHP_METHOD(Descriptor, getClass) {


static zend_function_entry Descriptor_methods[] = {
PHP_ME(Descriptor, getClass, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getFullName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getField, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getFieldCount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getOneofDecl, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getOneofDeclCount, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getPublicDescriptor, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getClass, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getFullName, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getField, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getFieldCount, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getOneofDecl, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getOneofDeclCount, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Descriptor, getPublicDescriptor, arginfo_void, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

Expand Down Expand Up @@ -1000,13 +1000,18 @@ PHP_METHOD(DescriptorPool, internalAddGeneratedFile) {
upb_arena_free(arena);
}

ZEND_BEGIN_ARG_INFO_EX(arginfo_addgeneratedfile, 0, 0, 2)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, data_len)
ZEND_END_ARG_INFO()

static zend_function_entry DescriptorPool_methods[] = {
PHP_ME(DescriptorPool, getGeneratedPool, NULL,
PHP_ME(DescriptorPool, getGeneratedPool, arginfo_void,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME(DescriptorPool, getDescriptorByClassName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(DescriptorPool, getDescriptorByProtoName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(DescriptorPool, getEnumDescriptorByClassName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(DescriptorPool, internalAddGeneratedFile, NULL, ZEND_ACC_PUBLIC)
PHP_ME(DescriptorPool, getDescriptorByClassName, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(DescriptorPool, getDescriptorByProtoName, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(DescriptorPool, getEnumDescriptorByClassName, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(DescriptorPool, internalAddGeneratedFile, arginfo_addgeneratedfile, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

Expand Down Expand Up @@ -1034,7 +1039,7 @@ PHP_METHOD(InternalDescriptorPool, getGeneratedPool) {
}

static zend_function_entry InternalDescriptorPool_methods[] = {
PHP_ME(InternalDescriptorPool, getGeneratedPool, NULL,
PHP_ME(InternalDescriptorPool, getGeneratedPool, arginfo_void,
ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_FE_END
};
Expand Down
7 changes: 4 additions & 3 deletions php/ext/google/protobuf/map.c
Expand Up @@ -437,9 +437,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetSet, 0, 0, 2)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_void, 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)
Expand Down Expand Up @@ -622,7 +619,11 @@ void Map_ModuleInit() {
h = &MapField_object_handlers;
memcpy(h, &std_object_handlers, sizeof(zend_object_handlers));
h->dtor_obj = MapField_destructor;
#if PHP_VERSION_ID < 80000
h->compare_objects = MapField_compare_objects;
#else
h->compare = MapField_compare_objects;
#endif
h->get_properties = Map_GetProperties;
h->get_property_ptr_ptr = Map_GetPropertyPtrPtr;

Expand Down
17 changes: 9 additions & 8 deletions php/ext/google/protobuf/message.c
Expand Up @@ -1021,9 +1021,6 @@ PHP_METHOD(Message, writeOneof) {
upb_msg_set(intern->msg, f, msgval, arena);
}

ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_mergeFrom, 0, 0, 1)
ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -1106,7 +1103,7 @@ PHP_METHOD(google_protobuf_Any, unpack) {
if (!TryStripUrlPrefix(&type_url)) {
zend_throw_exception(
NULL, "Type url needs to be type.googleapis.com/fully-qualified",
0 TSRMLS_CC);
0);
return;
}

Expand All @@ -1115,7 +1112,7 @@ PHP_METHOD(google_protobuf_Any, unpack) {
if (m == NULL) {
zend_throw_exception(
NULL, "Specified message in any hasn't been added to descriptor pool",
0 TSRMLS_CC);
0);
return;
}

Expand Down Expand Up @@ -1149,7 +1146,7 @@ PHP_METHOD(google_protobuf_Any, pack) {
const char *full_name;
char *buf;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &val) ==
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &val) ==
FAILURE) {
return;
}
Expand Down Expand Up @@ -1182,7 +1179,7 @@ PHP_METHOD(google_protobuf_Any, is) {
zend_class_entry *klass = NULL;
const upb_msgdef *m;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C", &klass) ==
if (zend_parse_parameters(ZEND_NUM_ARGS(), "C", &klass) ==
FAILURE) {
return;
}
Expand All @@ -1209,7 +1206,7 @@ PHP_METHOD(google_protobuf_Timestamp, fromDateTime) {
return;
}

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &datetime,
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &datetime,
date_interface_ce) == FAILURE) {
zend_error(E_USER_ERROR, "Expect DatetimeInterface.");
return;
Expand Down Expand Up @@ -1326,7 +1323,11 @@ void Message_ModuleInit() {

memcpy(h, &std_object_handlers, sizeof(zend_object_handlers));
h->dtor_obj = Message_dtor;
#if PHP_VERSION_ID < 80000
h->compare_objects = Message_compare_objects;
#else
h->compare = Message_compare_objects;
#endif
h->read_property = Message_read_property;
h->write_property = Message_write_property;
h->has_property = Message_has_property;
Expand Down
7 changes: 7 additions & 0 deletions php/ext/google/protobuf/protobuf.h
Expand Up @@ -69,6 +69,13 @@ const zval *get_generated_pool();
#define PROTO_STRLEN_P(obj) ZSTR_LEN(obj)
#endif

ZEND_BEGIN_ARG_INFO(arginfo_void, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

#define PHP_PROTOBUF_VERSION "3.14.0"

// ptr -> PHP object cache. This is a weak map that caches lazily-created
Expand Down