Skip to content

Commit 907d06a

Browse files
authored
Merge pull request #5 from qkdreyer/feat-php-8.2
feat: add php 8.2 compatibility
2 parents 065c994 + 48ffda8 commit 907d06a

35 files changed

+136
-73
lines changed

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.1
1+
FROM php:8.2
22
WORKDIR /tmp/cassandra-php-driver
33

44
RUN apt update -y \
@@ -32,11 +32,16 @@ RUN ext/doc/generate_doc.sh
3232
COPY composer.json .
3333
RUN composer install -n
3434

35+
ARG CI
36+
ENV CI=$CI
37+
3538
COPY support support
3639
COPY tests tests
3740
COPY phpunit.xml .
3841
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/
39-
RUN bin/phpunit --stop-on-error --stop-on-failure
42+
RUN bin/phpunit --stop-on-error --stop-on-failure --testsuite unit
43+
RUN bin/phpunit --stop-on-error --stop-on-failure --testsuite integration --exclude-group flaky
44+
RUN bash -c "for i in {1..10}; do bin/phpunit --stop-on-error --stop-on-failure --testsuite integration --group flaky && exit 0 || sleep 1; done; exit 1;"
4045

4146
COPY features features
4247
COPY behat.yml .

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
all: build
22
build:
3-
docker build . -t cassandra-php-driver
3+
docker build . -t cassandra-php-driver --build-arg CI=$(CI)
44
run:
55
docker run -v $$PWD/ext/doc:/tmp/cassandra-php-driver/ext/doc -it cassandra-php-driver

behat.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
default:
2+
formatters:
3+
pretty: true
4+
suites:
5+
default:
6+
filters:
7+
tags: "~@cassandra-version-less-2.1&&~@cassandra-version-only-2.0&&~@broken"
8+
contexts:
9+
- FeatureContext:
10+
cassandra_version: "4.1.0"
11+
12+
cassandra-version-3.11:
213
formatters:
314
pretty: true
415
suites:

ext/php_driver.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ typedef zend_object php7to8_object;
129129
#define PHP7TO8_ARG_INFO_VOID_RETURN(arginfo) \
130130
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo, 0, 0, IS_VOID, 0) \
131131
ZEND_END_ARG_INFO()
132+
#define PHP7TO8_ARG_INFO_STRING_RETURN(arginfo) \
133+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo, 0, 0, IS_STRING, 0) \
134+
ZEND_END_ARG_INFO()
132135
#define PHP7TO8_ARG_INFO_BOOL_RETURN(arginfo) \
133136
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo, 0, 0, _IS_BOOL, 0) \
134137
ZEND_END_ARG_INFO()
@@ -172,6 +175,9 @@ typedef zval php7to8_object;
172175
#define PHP7TO8_ARG_INFO_VOID_RETURN(arginfo) \
173176
ZEND_BEGIN_ARG_INFO_EX(arginfo, 0, ZEND_RETURN_VALUE, 0) \
174177
ZEND_END_ARG_INFO()
178+
#define PHP7TO8_ARG_INFO_STRING_RETURN(arginfo) \
179+
ZEND_BEGIN_ARG_INFO_EX(arginfo, 0, ZEND_RETURN_VALUE, 0) \
180+
ZEND_END_ARG_INFO()
175181
#define PHP7TO8_ARG_INFO_BOOL_RETURN(arginfo) \
176182
ZEND_BEGIN_ARG_INFO_EX(arginfo, 0, ZEND_RETURN_VALUE, 0) \
177183
ZEND_END_ARG_INFO()
@@ -200,6 +206,12 @@ typedef zval php7to8_object;
200206
ZEND_END_ARG_INFO()
201207
#endif
202208

209+
#if ((PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION > 8)
210+
#define PHP7TO82_ZEND_KEY() __key ? __key->val : NULL
211+
#else
212+
#define PHP7TO82_ZEND_KEY() _p->key ? _p->key->val : NULL
213+
#endif
214+
203215
#if PHP_MAJOR_VERSION >= 7
204216
#define php5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC);
205217

@@ -276,11 +288,7 @@ php5to7_string_compare(php5to7_string s1, php5to7_string s2)
276288

277289
#define PHP5TO7_ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val) \
278290
ZEND_HASH_FOREACH(ht, 0); \
279-
if (_p->key) { \
280-
(_key) = _p->key->val; \
281-
} else { \
282-
(_key) = NULL; \
283-
} \
291+
_key = PHP7TO82_ZEND_KEY(); \
284292
_val = _z;
285293

286294
#define PHP5TO7_ZEND_HASH_FOREACH_END(ht) ZEND_HASH_FOREACH_END()

ext/src/Bigint.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_num, 0, ZEND_RETURN_VALUE, 1)
371371
ZEND_ARG_INFO(0, num)
372372
ZEND_END_ARG_INFO()
373373

374+
PHP7TO8_ARG_INFO_STRING_RETURN(arginfo_string_return)
375+
374376
static zend_function_entry php_driver_bigint_methods[] = {
375377
PHP_ME(Bigint, __construct, arginfo__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
376-
PHP_ME(Bigint, __toString, arginfo_none, ZEND_ACC_PUBLIC)
378+
PHP_ME(Bigint, __toString, arginfo_string_return, ZEND_ACC_PUBLIC)
377379
PHP_ME(Bigint, type, arginfo_none, ZEND_ACC_PUBLIC)
378380
PHP_ME(Bigint, value, arginfo_none, ZEND_ACC_PUBLIC)
379381
PHP_ME(Bigint, add, arginfo_num, ZEND_ACC_PUBLIC)

ext/src/Blob.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ ZEND_END_ARG_INFO()
101101
ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, ZEND_RETURN_VALUE, 0)
102102
ZEND_END_ARG_INFO()
103103

104+
PHP7TO8_ARG_INFO_STRING_RETURN(arginfo_string_return)
105+
104106
static zend_function_entry php_driver_blob_methods[] = {
105107
PHP_ME(Blob, __construct, arginfo__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
106-
PHP_ME(Blob, __toString, arginfo_none, ZEND_ACC_PUBLIC)
108+
PHP_ME(Blob, __toString, arginfo_string_return, ZEND_ACC_PUBLIC)
107109
PHP_ME(Blob, type, arginfo_none, ZEND_ACC_PUBLIC)
108110
PHP_ME(Blob, bytes, arginfo_none, ZEND_ACC_PUBLIC)
109111
PHP_ME(Blob, toBinaryString, arginfo_none, ZEND_ACC_PUBLIC)

ext/src/Date.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,15 @@ ZEND_END_ARG_INFO()
180180
ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, ZEND_RETURN_VALUE, 0)
181181
ZEND_END_ARG_INFO()
182182

183+
PHP7TO8_ARG_INFO_STRING_RETURN(arginfo_string_return)
184+
183185
static zend_function_entry php_driver_date_methods[] = {
184186
PHP_ME(Date, __construct, arginfo__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
185187
PHP_ME(Date, type, arginfo_none, ZEND_ACC_PUBLIC)
186188
PHP_ME(Date, seconds, arginfo_none, ZEND_ACC_PUBLIC)
187189
PHP_ME(Date, toDateTime, arginfo_time, ZEND_ACC_PUBLIC)
188190
PHP_ME(Date, fromDateTime, arginfo_datetime, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
189-
PHP_ME(Date, __toString, arginfo_none, ZEND_ACC_PUBLIC)
191+
PHP_ME(Date, __toString, arginfo_string_return, ZEND_ACC_PUBLIC)
190192
PHP_FE_END
191193
};
192194

ext/src/Decimal.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_num, 0, ZEND_RETURN_VALUE, 1)
490490
ZEND_ARG_INFO(0, num)
491491
ZEND_END_ARG_INFO()
492492

493+
PHP7TO8_ARG_INFO_STRING_RETURN(arginfo_string_return)
494+
493495
static zend_function_entry php_driver_decimal_methods[] = {
494496
PHP_ME(Decimal, __construct, arginfo__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
495-
PHP_ME(Decimal, __toString, arginfo_none, ZEND_ACC_PUBLIC)
497+
PHP_ME(Decimal, __toString, arginfo_string_return, ZEND_ACC_PUBLIC)
496498
PHP_ME(Decimal, type, arginfo_none, ZEND_ACC_PUBLIC)
497499
PHP_ME(Decimal, value, arginfo_none, ZEND_ACC_PUBLIC)
498500
PHP_ME(Decimal, scale, arginfo_none, ZEND_ACC_PUBLIC)

ext/src/Duration.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,15 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo__construct, 0, ZEND_RETURN_VALUE, 3)
213213
ZEND_ARG_INFO(0, nanos)
214214
ZEND_END_ARG_INFO()
215215

216+
PHP7TO8_ARG_INFO_STRING_RETURN(arginfo_string_return)
217+
216218
static zend_function_entry php_driver_duration_methods[] = {
217219
PHP_ME(Duration, __construct, arginfo__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
218220
PHP_ME(Duration, type, arginfo_none, ZEND_ACC_PUBLIC)
219221
PHP_ME(Duration, months, arginfo_none, ZEND_ACC_PUBLIC)
220222
PHP_ME(Duration, days, arginfo_none, ZEND_ACC_PUBLIC)
221223
PHP_ME(Duration, nanos, arginfo_none, ZEND_ACC_PUBLIC)
222-
PHP_ME(Duration, __toString, arginfo_none, ZEND_ACC_PUBLIC)
224+
PHP_ME(Duration, __toString, arginfo_string_return, ZEND_ACC_PUBLIC)
223225
PHP_FE_END
224226
};
225227

ext/src/Float.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_num, 0, ZEND_RETURN_VALUE, 1)
346346
ZEND_ARG_INFO(0, num)
347347
ZEND_END_ARG_INFO()
348348

349+
PHP7TO8_ARG_INFO_STRING_RETURN(arginfo_string_return)
350+
349351
static zend_function_entry php_driver_float_methods[] = {
350352
PHP_ME(Float, __construct, arginfo__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
351-
PHP_ME(Float, __toString, arginfo_none, ZEND_ACC_PUBLIC)
353+
PHP_ME(Float, __toString, arginfo_string_return, ZEND_ACC_PUBLIC)
352354
PHP_ME(Float, type, arginfo_none, ZEND_ACC_PUBLIC)
353355
PHP_ME(Float, value, arginfo_none, ZEND_ACC_PUBLIC)
354356
PHP_ME(Float, isInfinite, arginfo_none, ZEND_ACC_PUBLIC)

0 commit comments

Comments
 (0)