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

#2440 - Support PHP 8.4 #2441

Draft
wants to merge 12 commits into
base: development
Choose a base branch
from
5 changes: 5 additions & 0 deletions .docker/8.4/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

alias test-ext='php -d extension=ext/modules/stub.so vendor/bin/phpunit --bootstrap tests/ext-bootstrap.php --testsuite Extension'
alias test-zephir='php vendor/bin/phpunit --colors=always --testsuite Zephir'
alias test-all='test-ext; test-zephir'
25 changes: 25 additions & 0 deletions .docker/8.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM composer:latest AS composer
FROM php:8.4-fpm

RUN CPU_CORES="$(getconf _NPROCESSORS_ONLN)";
ENV MAKEFLAGS="-j${CPU_CORES}"

RUN apt update -y && apt install -y \
wget \
zip \
git \
apt-utils \
sudo \
libicu-dev \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser #xdebug

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser #xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
COPY ./.bashrc /root/.bashrc

CMD ["php-fpm"]
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]
php: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
ts: [ 'ts', 'nts' ]
arch: [ 'x64' ]

Expand Down
72 changes: 36 additions & 36 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ services:
- "USER=Zephir"
volumes:
- .:/srv

zephir-8.4:
container_name: zephir-8.4
hostname: zephir-84
build: .docker/8.4
working_dir: /srv
environment:
- "USER=Zephir"
volumes:
- .:/srv
2 changes: 2 additions & 0 deletions kernel/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include <php.h>
#include <ext/standard/php_string.h>
#include <ext/standard/php_math.h>
#if PHP_VERSION_ID < 80400
#include <ext/standard/php_rand.h>
#endif

#include "php_ext.h"
#include "kernel/main.h"
Expand Down
23 changes: 20 additions & 3 deletions kernel/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

#include <ext/standard/php_smart_string.h>
#include <ext/standard/php_string.h>
#if PHP_VERSION_ID < 80400
#include <ext/standard/php_rand.h>
#include <ext/standard/php_lcg.h>
#endif
#include <ext/standard/php_http.h>
#include <ext/standard/base64.h>
#include <ext/standard/md5.h>
Expand Down Expand Up @@ -107,7 +109,11 @@ void zephir_fast_strtolower(zval *return_value, zval *str)

length = Z_STRLEN_P(str);
lower_str = estrndup(Z_STRVAL_P(str), length);
#if PHP_VERSION_ID < 80400
php_strtolower(lower_str, length);
#else
zend_str_tolower(lower_str, length);
#endif

if (use_copy) {
zval_dtor(str);
Expand Down Expand Up @@ -136,7 +142,11 @@ void zephir_fast_strtoupper(zval *return_value, zval *str)

length = Z_STRLEN_P(str);
lower_str = estrndup(Z_STRVAL_P(str), length);
#if PHP_VERSION_ID < 80400
php_strtoupper(lower_str, length);
#else
zend_str_toupper(lower_str, length);
#endif

if (use_copy) {
zval_dtor(str);
Expand Down Expand Up @@ -1052,7 +1062,6 @@ void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *mat

/* Compile regex or get it from cache */
if ((pce = pcre_get_compiled_regex_cache(Z_STR_P(regex))) == NULL) {

if (use_copy) {
zval_dtor(subject);
}
Expand All @@ -1063,9 +1072,17 @@ void zephir_preg_match(zval *return_value, zval *regex, zval *subject, zval *mat
ZVAL_UNDEF(&tmp_matches);

if (flags != 0 || offset != 0) {
#if PHP_VERSION_ID < 80400
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, 1, flags, offset);
#else
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, flags, offset);
#endif
} else {
#if PHP_VERSION_ID < 80400
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, 0, 0, 0);
#else
php_pcre_match_impl(pce, Z_STR_P(subject), return_value, &tmp_matches, global, 0, 0);
#endif
}

if (matches) {
Expand Down Expand Up @@ -1223,8 +1240,8 @@ void zephir_crc32(zval *return_value, zval *str)
int use_copy = 0;
size_t nr;
char *p;
php_uint32 crc;
php_uint32 crcinit = 0;
uint32_t crc;
uint32_t crcinit = 0;

if (Z_TYPE_P(str) != IS_STRING) {
use_copy = zend_make_printable_zval(str, &copy);
Expand Down
2 changes: 1 addition & 1 deletion prototypes/memcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function pconnect($host, $port)
{
}

public function addserver($host, $port = 11211, $persistent = null, $weight = null, $timeout = null, $retry_interval = null, $status = null, callable $failure_callback = null, $timeoutms = null)
public function addserver($host, $port = 11211, $persistent = null, $weight = null, $timeout = null, $retry_interval = null, $status = null, ?callable $failure_callback = null, $timeoutms = null)
{
}

Expand Down
Loading
Loading