Skip to content

Commit 3a24c5c

Browse files
author
Dusan Malusev
committed
Adding support for PHP 8.1
Signed-off-by: Dusan Malusev <[email protected]>
1 parent c56f69b commit 3a24c5c

File tree

7 files changed

+52
-10
lines changed

7 files changed

+52
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
/tmp/*
1313
*.ac
1414
.phpunit.result.cache
15+
*.dep

ext/src/Collection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,11 @@ void php_driver_define_Collection(TSRMLS_D)
478478
#endif
479479
php_driver_collection_ce->ce_flags |= PHP5TO7_ZEND_ACC_FINAL;
480480
php_driver_collection_ce->create_object = php_driver_collection_new;
481+
#if PHP_VERSION_ID < 80100
481482
zend_class_implements(php_driver_collection_ce TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator);
483+
#else
484+
zend_class_implements(php_driver_collection_ce TSRMLS_CC, 2, zend_ce_countable, zend_ce_iterator);
485+
#endif
482486

483487
php_driver_collection_handlers.hash_value = php_driver_collection_hash_value;
484488
php_driver_collection_handlers.std.clone_obj = NULL;

ext/src/Map.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,12 @@ void php_driver_define_Map(TSRMLS_D)
624624
#endif
625625
php_driver_map_ce->ce_flags |= PHP5TO7_ZEND_ACC_FINAL;
626626
php_driver_map_ce->create_object = php_driver_map_new;
627+
628+
#if PHP_VERSION_ID < 80100
627629
zend_class_implements(php_driver_map_ce TSRMLS_CC, 3, spl_ce_Countable, zend_ce_iterator, zend_ce_arrayaccess);
630+
#else
631+
zend_class_implements(php_driver_map_ce TSRMLS_CC, 3, zend_ce_countable, zend_ce_iterator, zend_ce_arrayaccess);
632+
#endif
628633

629634
php_driver_map_handlers.hash_value = php_driver_map_hash_value;
630635
php_driver_map_handlers.std.clone_obj = NULL;

ext/src/SSLOptions/Builder.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,17 @@ PHP_METHOD(SSLOptionsBuilder, withTrustedCerts)
125125
PHP5TO7_MAYBE_EFREE(args);
126126
}
127127

128+
#if PHP_VERSION_ID < 80100
128129
php_stat(Z_STRVAL_P(path), Z_STRLEN_P(path), FS_IS_R, &readable TSRMLS_CC);
130+
#else
131+
zend_string* path_str = zend_string_init(Z_STRVAL_P(path), Z_STRLEN_P(path), false);
132+
php_stat(path_str, FS_IS_R, &readable TSRMLS_CC);
133+
zend_string_release(path_str);
134+
#endif
129135

130136
if (PHP5TO7_ZVAL_IS_FALSE_P(&readable)) {
131137
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
132-
"The path '%s' doesn't exist or is not readable", Z_STRVAL_P(path));
138+
"The path '%s' doesn't exist or is not readable", Z_STRVAL_P(path));
133139
PHP5TO7_MAYBE_EFREE(args);
134140
return;
135141
}
@@ -146,10 +152,10 @@ PHP_METHOD(SSLOptionsBuilder, withTrustedCerts)
146152
}
147153

148154
builder->trusted_certs_cnt = argc;
149-
builder->trusted_certs = ecalloc(argc, sizeof(char *));
155+
builder->trusted_certs = ecalloc(argc, sizeof(char*));
150156

151157
for (i = 0; i < argc; i++) {
152-
zval *path = PHP5TO7_ZVAL_ARG(args[i]);
158+
zval* path = PHP5TO7_ZVAL_ARG(args[i]);
153159

154160
builder->trusted_certs[i] = estrndup(Z_STRVAL_P(path), Z_STRLEN_P(path));
155161
}
@@ -161,7 +167,7 @@ PHP_METHOD(SSLOptionsBuilder, withTrustedCerts)
161167
PHP_METHOD(SSLOptionsBuilder, withVerifyFlags)
162168
{
163169
long flags;
164-
php_driver_ssl_builder *builder = NULL;
170+
php_driver_ssl_builder* builder = NULL;
165171

166172
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
167173
return;
@@ -176,20 +182,26 @@ PHP_METHOD(SSLOptionsBuilder, withVerifyFlags)
176182

177183
PHP_METHOD(SSLOptionsBuilder, withClientCert)
178184
{
179-
char *client_cert;
185+
char* client_cert;
180186
php5to7_size client_cert_len;
181187
zval readable;
182-
php_driver_ssl_builder *builder = NULL;
188+
php_driver_ssl_builder* builder = NULL;
183189

184190
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &client_cert, &client_cert_len) == FAILURE) {
185191
return;
186192
}
187193

194+
#if PHP_VERSION_ID < 80100
188195
php_stat(client_cert, client_cert_len, FS_IS_R, &readable TSRMLS_CC);
196+
#else
197+
zend_string* client_cert_str = zend_string_init(client_cert, client_cert_len, false);
198+
php_stat(client_cert_str, FS_IS_R, &readable TSRMLS_CC);
199+
zend_string_release(client_cert_str);
200+
#endif
189201

190202
if (PHP5TO7_ZVAL_IS_FALSE_P(&readable)) {
191203
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,
192-
"The path '%s' doesn't exist or is not readable", client_cert);
204+
"The path '%s' doesn't exist or is not readable", client_cert);
193205
return;
194206
}
195207

@@ -205,17 +217,23 @@ PHP_METHOD(SSLOptionsBuilder, withClientCert)
205217

206218
PHP_METHOD(SSLOptionsBuilder, withPrivateKey)
207219
{
208-
char *private_key;
209-
char *passphrase = NULL;
220+
char* private_key;
221+
char* passphrase = NULL;
210222
php5to7_size private_key_len, passphrase_len;
211223
zval readable;
212-
php_driver_ssl_builder *builder = NULL;
224+
php_driver_ssl_builder* builder = NULL;
213225

214226
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &private_key, &private_key_len, &passphrase, &passphrase_len) == FAILURE) {
215227
return;
216228
}
217229

230+
#if PHP_VERSION_ID < 80100
218231
php_stat(private_key, private_key_len, FS_IS_R, &readable TSRMLS_CC);
232+
#else
233+
zend_string* private_key_str = zend_string_init(private_key, private_key_len, false);
234+
php_stat(private_key_str, FS_IS_R, &readable TSRMLS_CC);
235+
zend_string_release(private_key_str);
236+
#endif
219237

220238
if (PHP5TO7_ZVAL_IS_FALSE_P(&readable)) {
221239
zend_throw_exception_ex(php_driver_invalid_argument_exception_ce, 0 TSRMLS_CC,

ext/src/Set.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,12 @@ void php_driver_define_Set(TSRMLS_D)
456456
#endif
457457
php_driver_set_ce->ce_flags |= PHP5TO7_ZEND_ACC_FINAL;
458458
php_driver_set_ce->create_object = php_driver_set_new;
459+
460+
#if PHP_VERSION_ID < 80100
459461
zend_class_implements(php_driver_set_ce TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator);
462+
#else
463+
zend_class_implements(php_driver_set_ce TSRMLS_CC, 2, zend_ce_countable, zend_ce_iterator);
464+
#endif
460465

461466
php_driver_set_handlers.hash_value = php_driver_set_hash_value;
462467
php_driver_set_handlers.std.clone_obj = NULL;

ext/src/Tuple.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,11 @@ void php_driver_define_Tuple(TSRMLS_D)
465465
#endif
466466
php_driver_tuple_ce->ce_flags |= PHP5TO7_ZEND_ACC_FINAL;
467467
php_driver_tuple_ce->create_object = php_driver_tuple_new;
468+
#if PHP_VERSION_ID < 80100
468469
zend_class_implements(php_driver_tuple_ce TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator);
470+
#else
471+
zend_class_implements(php_driver_tuple_ce TSRMLS_CC, 2, zend_ce_countable, zend_ce_iterator);
472+
#endif
469473

470474
php_driver_tuple_handlers.hash_value = php_driver_tuple_hash_value;
471475
php_driver_tuple_handlers.std.clone_obj = NULL;

ext/src/UserTypeValue.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,12 @@ void php_driver_define_UserTypeValue(TSRMLS_D)
504504
#endif
505505
php_driver_user_type_value_ce->ce_flags |= PHP5TO7_ZEND_ACC_FINAL;
506506
php_driver_user_type_value_ce->create_object = php_driver_user_type_value_new;
507+
508+
#if PHP_VERSION_ID < 80100
507509
zend_class_implements(php_driver_user_type_value_ce TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator);
510+
#else
511+
zend_class_implements(php_driver_user_type_value_ce TSRMLS_CC, 2, zend_ce_countable, zend_ce_iterator);
512+
#endif
508513

509514
php_driver_user_type_value_handlers.hash_value = php_driver_user_type_value_hash_value;
510515
php_driver_user_type_value_handlers.std.clone_obj = NULL;

0 commit comments

Comments
 (0)