Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 0cfda50

Browse files
authored
feat: add PHP 8 compatibility (#270)
1 parent 007b35d commit 0cfda50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+399
-256
lines changed

.circleci/config.yml

+126-26
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ unit-config: &unit-config
6464

6565
- run:
6666
name: PHP unit tests
67-
command: vendor/bin/phpunit
67+
command: XDEBUG_MODE=coverage vendor/bin/phpunit
6868

6969
- run:
7070
name: PHP unit tests with extension
7171
command: |
7272
if [ $RUN_EXTENSION_TESTS -eq "1" ]; then
73-
php -d extension=opencensus.so vendor/bin/phpunit
73+
XDEBUG_MODE=coverage php -d extension=opencensus.so vendor/bin/phpunit
7474
else
7575
echo "Skipping units tests with extension"
7676
fi
@@ -107,29 +107,30 @@ jobs:
107107
docker:
108108
- image: circleci/php:7.3-zts-node
109109

110-
php71-32bit:
110+
php74:
111111
<<: *unit-config
112112
docker:
113-
- image: gcr.io/php-stackdriver/php71-32bit
114-
environment:
115-
TEST_PHP_ARGS: -q
116-
REPORT_EXIT_STATUS: 1
117-
RUN_EXTENSION_TESTS: 1
118-
SUDO_CMD: ""
113+
- image: circleci/php:7.4-node
119114

120-
php71-debug:
115+
php74-zts:
121116
<<: *unit-config
122117
docker:
123-
- image: gcr.io/php-stackdriver/php71-debug
124-
environment:
125-
TEST_PHP_ARGS: -q
126-
REPORT_EXIT_STATUS: 1
127-
RUN_EXTENSION_TESTS: 1
128-
SUDO_CMD: ""
118+
- image: circleci/php:7.4-zts-node
129119

130-
integration:
120+
php80:
121+
<<: *unit-config
131122
docker:
132-
- image: circleci/php:7.2-node
123+
- image: circleci/php:8.0-node
124+
125+
php80-zts:
126+
<<: *unit-config
127+
docker:
128+
- image: circleci/php:8.0-zts-node
129+
130+
# Integration tests running on PHP 7.4. When updating these, please also update `integration-8.0` further down.
131+
integration-7.4:
132+
docker:
133+
- image: circleci/php:7.4-node
133134
- image: memcached
134135
- image: mysql:5.7
135136
environment:
@@ -202,11 +203,13 @@ jobs:
202203
- run:
203204
name: Pgsql test
204205
command: tests/integration/pgsql/test.sh
205-
- run:
206-
name: Symfony 4 test
207-
command: tests/integration/symfony4/test.sh
208-
environment:
209-
DATABASE_URL: mysql://mysql:[email protected]:3306/mysqldb
206+
# Skipped due to a dependency incompatibility between "cache/adapter-common" and "psr/cache".
207+
# TODO(mrmage): Re-enable this step once "cache/adapter-common" supports "psr/cache" v2.0/v3.0.
208+
# - run:
209+
# name: Symfony 4 test
210+
# command: tests/integration/symfony4/test.sh
211+
# environment:
212+
# DATABASE_URL: mysql://mysql:[email protected]:3306/mysqldb
210213
- run:
211214
name: Wordpress test
212215
command: tests/integration/wordpress/test.sh
@@ -216,6 +219,100 @@ jobs:
216219
DB_PASSWORD: mysql
217220
DB_DATABASE: mysqldb
218221

222+
# Integration tests running on PHP 8.0. When updating these, please also update `integration-7.4` further down.
223+
integration-8.0:
224+
docker:
225+
- image: circleci/php:8.0-node
226+
- image: memcached
227+
- image: mysql:5.7
228+
environment:
229+
MYSQL_USER: mysql
230+
MYSQL_PASSWORD: mysql
231+
MYSQL_DATABASE: mysqldb
232+
MYSQL_RANDOM_ROOT_PASSWORD: yes
233+
- image: postgres:9.6
234+
environment:
235+
POSTGRES_PASSWORD: pgsql
236+
POSTGRES_USER: postgres
237+
steps:
238+
- checkout
239+
- run:
240+
name: Install build tools
241+
command: |
242+
sudo apt-get update -y
243+
sudo apt-get install -y -q --no-install-recommends \
244+
build-essential \
245+
g++ \
246+
gcc \
247+
libc-dev \
248+
libpqxx-dev \
249+
make \
250+
autoconf \
251+
git \
252+
unzip
253+
- run:
254+
name: Install opencensus extension
255+
command: |
256+
cd ext
257+
phpize
258+
./configure --enable-opencensus
259+
sudo make install
260+
sudo docker-php-ext-enable opencensus
261+
- run:
262+
name: Install memcached extension
263+
command: |
264+
sudo apt-get install -y -q --no-install-recommends \
265+
libmemcached11 libmemcached-dev zlib1g-dev zlib1g
266+
sudo pecl install memcached <<<''
267+
sudo docker-php-ext-enable memcached
268+
- run:
269+
name: Install pdo_mysql extension
270+
command: sudo docker-php-ext-install pdo_mysql
271+
- run:
272+
name: Install mysqli extension
273+
command: sudo docker-php-ext-install mysqli
274+
- run:
275+
name: Install pgsql extension
276+
command: sudo docker-php-ext-install pgsql
277+
- run:
278+
name: Install pcntl extension
279+
command: sudo docker-php-ext-install pcntl
280+
- run:
281+
name: Curl test
282+
command: tests/integration/curl/test.sh
283+
- run:
284+
name: Guzzle 5 test
285+
command: tests/integration/guzzle5/test.sh
286+
- run:
287+
name: Guzzle 6 test
288+
command: tests/integration/guzzle6/test.sh
289+
- run:
290+
name: Laravel test
291+
command: tests/integration/laravel/test.sh
292+
- run:
293+
name: Memcached test
294+
command: tests/integration/memcached/test.sh
295+
- run:
296+
name: Pgsql test
297+
command: tests/integration/pgsql/test.sh
298+
# Skipped due to a dependency incompatibility between "cache/adapter-common" and "psr/cache".
299+
# TODO(mrmage): Re-enable this step once "cache/adapter-common" supports "psr/cache" v2.0/v3.0.
300+
# - run:
301+
# name: Symfony 4 test
302+
# command: tests/integration/symfony4/test.sh
303+
# environment:
304+
# DATABASE_URL: mysql://mysql:[email protected]:3306/mysqldb
305+
# Skipped because "wp-cli" is currently not compatible with PHP 8 (see https://github.com/wp-cli/wp-cli/issues/5452).
306+
# TODO(mrmage): Re-enable this step once "wp-cli" supports PHP 8.
307+
# - run:
308+
# name: Wordpress test
309+
# command: tests/integration/wordpress/test.sh
310+
environment:
311+
DB_HOST: 127.0.0.1
312+
DB_USERNAME: mysql
313+
DB_PASSWORD: mysql
314+
DB_DATABASE: mysqldb
315+
219316
workflows:
220317
version: 2
221318
units:
@@ -226,6 +323,9 @@ workflows:
226323
- php72-zts
227324
- php73
228325
- php73-zts
229-
- php71-32bit
230-
- php71-debug
231-
- integration
326+
- php74
327+
- php74-zts
328+
- php80
329+
- php80-zts
330+
- integration-7.4
331+
- integration-8.0

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
"minimum-stability": "stable",
1717
"require": {
1818
"php": ">=7.1",
19-
"ramsey/uuid": "~3",
19+
"ramsey/uuid": "^3.0 || ^4.0",
2020
"psr/log": "^1.0",
21-
"psr/cache": "^1.0",
21+
"psr/cache": "^1.0 || ^2.0 || ^3.0",
2222
"cache/adapter-common": "^1.0"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^5.0",
26-
"squizlabs/php_codesniffer": "2.*",
25+
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
26+
"squizlabs/php_codesniffer": "^3.0",
2727
"twig/twig": "~2.0 || ~1.35",
2828
"symfony/yaml": "~3.3",
2929
"guzzlehttp/guzzle": "~5.3",

examples/symfony/web/app.php

-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
use Symfony\Component\HttpFoundation\Request;
44

55
require __DIR__.'/../vendor/autoload.php';
6-
if (PHP_VERSION_ID < 70000) {
7-
include_once __DIR__.'/../var/bootstrap.php.cache';
8-
}
96

107
$kernel = new AppKernel('prod', false);
11-
if (PHP_VERSION_ID < 70000) {
12-
$kernel->loadClassCache();
13-
}
148
//$kernel = new AppCache($kernel);
159

1610
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter

examples/symfony/web/app_dev.php

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
Debug::enable();
2323

2424
$kernel = new AppKernel('dev', true);
25-
if (PHP_VERSION_ID < 70000) {
26-
$kernel->loadClassCache();
27-
}
2825
$request = Request::createFromGlobals();
2926
$response = $kernel->handle($request);
3027
$response->send();

ext/opencensus.c

+9-14
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_opencensus_trace_add_message_event, 0, 0, 2)
7070
ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0)
7171
ZEND_ARG_ARRAY_INFO(0, options, 0)
7272
ZEND_END_ARG_INFO()
73+
74+
ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
75+
ZEND_END_ARG_INFO();
76+
7377
/* }}} */
7478

7579
static PHP_MINFO_FUNCTION(opencensus);
@@ -85,16 +89,16 @@ PHP_FUNCTION(opencensus_version);
8589
/* {{{ opencensus_functions[]
8690
*/
8791
static zend_function_entry opencensus_functions[] = {
88-
PHP_FE(opencensus_version, NULL)
92+
PHP_FE(opencensus_version, arginfo_void)
8993
PHP_FE(opencensus_core_send_to_daemonclient, arginfo_opencensus_core_send_to_daemon)
9094
PHP_FE(opencensus_trace_function, arginfo_opencensus_trace_function)
9195
PHP_FE(opencensus_trace_method, arginfo_opencensus_trace_method)
92-
PHP_FE(opencensus_trace_list, NULL)
96+
PHP_FE(opencensus_trace_list, arginfo_void)
9397
PHP_FE(opencensus_trace_begin, arginfo_opencensus_trace_begin)
94-
PHP_FE(opencensus_trace_finish, NULL)
95-
PHP_FE(opencensus_trace_clear, NULL)
98+
PHP_FE(opencensus_trace_finish, arginfo_void)
99+
PHP_FE(opencensus_trace_clear, arginfo_void)
96100
PHP_FE(opencensus_trace_set_context, arginfo_opencensus_trace_set_context)
97-
PHP_FE(opencensus_trace_context, NULL)
101+
PHP_FE(opencensus_trace_context, arginfo_void)
98102
PHP_FE(opencensus_trace_add_attribute, arginfo_opencensus_trace_add_attribute)
99103
PHP_FE(opencensus_trace_add_annotation, arginfo_opencensus_trace_add_annotation)
100104
PHP_FE(opencensus_trace_add_link, arginfo_opencensus_trace_add_link)
@@ -122,9 +126,6 @@ zend_module_entry opencensus_module_entry = {
122126
};
123127

124128
#ifdef COMPILE_DL_OPENCENSUS
125-
#ifdef ZTS
126-
ZEND_TSRMLS_CACHE_DEFINE()
127-
#endif
128129
ZEND_GET_MODULE(opencensus)
129130
#endif
130131

@@ -149,9 +150,6 @@ PHP_MINFO_FUNCTION(opencensus)
149150
*/
150151
PHP_GINIT_FUNCTION(opencensus)
151152
{
152-
#if defined(COMPILE_DL_OPENCENSUS) && defined(ZTS)
153-
ZEND_TSRMLS_CACHE_UPDATE()
154-
#endif
155153
opencensus_trace_ginit();
156154
}
157155
/* }}} */
@@ -168,9 +166,6 @@ PHP_GSHUTDOWN_FUNCTION(opencensus)
168166
*/
169167
PHP_MINIT_FUNCTION(opencensus)
170168
{
171-
#if defined(COMPILE_DL_OPENCENSUS) && defined(ZTS)
172-
ZEND_TSRMLS_CACHE_UPDATE()
173-
#endif
174169
REGISTER_INI_ENTRIES();
175170

176171
#ifndef PHP_WIN32

0 commit comments

Comments
 (0)