Skip to content

Commit 4ec4cb5

Browse files
committed
feat: add php 8.4 compatibility
1 parent 907d06a commit 4ec4cb5

File tree

15 files changed

+68
-30
lines changed

15 files changed

+68
-30
lines changed

Dockerfile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
FROM php:8.2
1+
FROM php:8.4
22
WORKDIR /tmp/cassandra-php-driver
33

44
RUN apt update -y \
5-
&& apt install python3 pip cmake unzip mlocate build-essential git libuv1-dev libssl-dev libgmp-dev openssl zlib1g-dev libpcre3-dev openjdk-11-jre openjdk-11-jdk -y \
6-
&& pip install git+https://github.com/riptano/ccm.git@master
5+
&& apt install python3 pip cmake unzip plocate build-essential git libuv1-dev libssl-dev libgmp-dev openssl zlib1g-dev libpcre2-dev -y \
6+
&& pip install --break-system-packages setuptools git+https://github.com/apache/cassandra-ccm \
7+
&& apt-get install -y wget gnupg ca-certificates \
8+
&& mkdir -p /etc/apt/keyrings \
9+
&& wget -O /etc/apt/keyrings/adoptium.gpg https://packages.adoptium.net/artifactory/api/gpg/key/public \
10+
&& echo "deb [signed-by=/etc/apt/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb bookworm main" > /etc/apt/sources.list.d/adoptium.list \
11+
&& apt-get update \
12+
&& apt-get install -y temurin-11-jdk \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
RUN mkdir -p ~/.ccm && echo '[repositories]\ncassandra = https://dlcdn.apache.org/cassandra' > ~/.ccm/config
716

817
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin
918
RUN docker-php-source extract \
@@ -17,7 +26,7 @@ RUN cmake -DCMAKE_CXX_FLAGS="-fPIC" -DCASS_BUILD_STATIC=OFF -DCASS_BUILD_SHARED=
1726
RUN docker-php-source extract
1827

1928
COPY ext ext
20-
ENV NO_INTERACTION true
29+
ENV NO_INTERACTION=true
2130
RUN cd ext \
2231
&& phpize \
2332
&& LDFLAGS="-L/usr/local/lib" LIBS="-lssl -lz -luv -lm -lgmp -lstdc++" ./configure --with-cassandra=/usr/local \
@@ -38,10 +47,9 @@ ENV CI=$CI
3847
COPY support support
3948
COPY tests tests
4049
COPY phpunit.xml .
41-
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64/
50+
ENV JAVA_HOME=/usr
4251
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;"
52+
RUN bin/phpunit --stop-on-error --stop-on-failure --testsuite integration
4553

4654
COPY features features
4755
COPY behat.yml .

behat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default:
77
tags: "~@cassandra-version-less-2.1&&~@cassandra-version-only-2.0&&~@broken"
88
contexts:
99
- FeatureContext:
10-
cassandra_version: "4.1.0"
10+
cassandra_version: "4.1.10"
1111

1212
cassandra-version-3.11:
1313
formatters:

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "datastax/php-driver",
3-
"type": "library",
3+
"type": "php-ext",
44
"description": "DataStax PHP Driver for Apache Cassandra",
55
"keywords": [
66
"cassandra",
@@ -26,6 +26,9 @@
2626
"require": {
2727
"php": ">=8.1"
2828
},
29+
"php-ext": {
30+
"extension-name": "cassandra"
31+
},
2932
"require-dev": {
3033
"behat/behat": "^3.7",
3134
"phpunit/php-code-coverage": "^7.0",

ext/doc/generate_doc.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ function isAlreadyImplementedByBase($current, $implemented) {
6666
function replaceKeyword($string) {
6767
if ($string == "Function") {
6868
return "Function_";
69-
} else if ($string == "function") {
70-
return "function_";
7169
} else if ($string == "Float") {
7270
return "Float_";
7371
}
@@ -383,6 +381,7 @@ function writeMethod($doc, $file, $class, $method, &$singleEOL) {
383381
fwrite($file, "...\$params");
384382
} else {
385383
$parameterType = parseDocMetadata($doc, $className, $methodName, $parameterName);
384+
$defaultValue = NULL;
386385
if ($parameter->isOptional()) {
387386
$defaultValue = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null;
388387
if (empty($defaultValue)) {
@@ -397,6 +396,9 @@ function writeMethod($doc, $file, $class, $method, &$singleEOL) {
397396
}
398397
$parameterName = "$parameterName = $defaultValue";
399398
}
399+
if ($parameterType && rtrim($parameterType) !== 'mixed' && $defaultValue === 'null') {
400+
$parameterType = "?$parameterType";
401+
}
400402
fwrite($file, "$parameterType\$$parameterName");
401403
}
402404
$first = false;

ext/src/Column.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ Column:
1313
comment: Type of the column
1414
type: \Cassandra\Type
1515
isReversed:
16-
comment: Returns whether the column is in descending or ascending order.
16+
comment: |-
17+
Returns whether the column is in descending or ascending order.
18+
19+
@deprecated
1720
return:
1821
comment: Whether the column is stored in descending order.
1922
type: bool
@@ -28,12 +31,18 @@ Column:
2831
comment: Whether the column is frozen
2932
type: bool
3033
indexName:
31-
comment: Returns name of the index if defined.
34+
comment: |-
35+
Returns name of the index if defined.
36+
37+
@deprecated
3238
return:
3339
comment: Name of the index if defined or null
3440
type: string
3541
indexOptions:
36-
comment: Returns index options if present.
42+
comment: |-
43+
Returns index options if present.
44+
45+
@deprecated
3746
return:
3847
comment: Index options if present or null
3948
type: string

ext/src/Keyspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Keyspace:
3030
type: string
3131
return:
3232
comment: Table instance or null
33-
type: \Cassandra\Table|null
33+
type: \Cassandra\DefaultTable|null
3434
tables:
3535
comment: Returns all tables defined in this keyspace
3636
return:

ext/src/Schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Schema:
1010
type: string
1111
return:
1212
comment: Keyspace instance or null
13-
type: \Cassandra\Keyspace
13+
type: \Cassandra\DefaultKeyspace
1414
keyspaces:
1515
comment: Returns all keyspaces defined in the schema.
1616
return:

ext/src/Session.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Session:
104104
comment: Get a snapshot of the cluster's current schema.
105105
return:
106106
comment: A snapshot of the cluster's schema.
107-
type: \Cassandra\Schema
107+
type: \Cassandra\DefaultSchema
108108
metrics:
109109
comment: Get performance and diagnostic metrics.
110110
return:

ext/util/hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ php_driver_value_compare(zval* zvalue1, zval* zvalue2 TSRMLS_DC) {
136136
return 1;
137137
}
138138

139-
int php_driver_data_compare(const void* a, const void* b TSRMLS_DC) {
139+
int php_driver_data_compare(Bucket* a, Bucket* b TSRMLS_DC) {
140140
Bucket *f, *s;
141141
zval *first, *second;
142142

ext/util/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct php_driver_set_entry_ {
5151

5252
unsigned php_driver_value_hash(zval* zvalue TSRMLS_DC);
5353
int php_driver_value_compare(zval* zvalue1, zval* zvalue2 TSRMLS_DC);
54-
int php_driver_data_compare(const void* a, const void* b TSRMLS_DC);
54+
int php_driver_data_compare(Bucket* a, Bucket* b TSRMLS_DC);
5555

5656
unsigned php_driver_mpz_hash(unsigned seed, mpz_t n);
5757

0 commit comments

Comments
 (0)