Skip to content

Commit 4bf49ce

Browse files
authored
Merge pull request #11169 from vimeo/update_dictionaries
PHP 8.4 support, dictionary refactoring
2 parents 765dcbf + e430a0b commit 4bf49ce

Some content is hidden

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

64 files changed

+1659948
-80141
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ jobs:
134134
- "8.1"
135135
- "8.2"
136136
- "8.3"
137+
- "8.4"
137138
count: ${{ fromJson(needs.chunk-matrix.outputs.count) }}
138139
chunk: ${{ fromJson(needs.chunk-matrix.outputs.chunks) }}
139140

.github/workflows/windows-ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ jobs:
5454
- name: Set up PHP
5555
uses: shivammathur/setup-php@v2
5656
with:
57-
php-version: '8.1'
58-
#ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
59-
ini-values: zend.assertions=1, assert.exception=1
57+
php-version: '8.4'
58+
ini-values: zend.assertions=1, assert.exception=1, opcache.enable_cli=1, opcache.jit=function, opcache.jit_buffer_size=512M
59+
#ini-values: zend.assertions=1, assert.exception=1
6060
tools: composer:v2
6161
coverage: none
6262
#extensions: none, curl, dom, filter, intl, json, libxml, mbstring, openssl, opcache, pcre, phar, reflection, simplexml, spl, tokenizer, xml, xmlwriter

bin/Dockerfile_7.0

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:7.0-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_7.1

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:7.1-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_7.2

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:7.2-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_7.3

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:7.3-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_7.4

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:7.4-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl ffi pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_8.0

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:8.0-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl uv-beta ffi pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_8.1

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:8.1-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl uv-beta ffi pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_8.2

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:8.2-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl uv-beta ffi pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_8.3

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM php:8.3-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions memcached grpc soap swoole zookeeper
7+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl uv-beta ffi pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
8+
9+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/Dockerfile_8.4

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM php:8.4-alpine
2+
3+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
7+
RUN install-php-extensions memcached grpc soap swoole zookeeper
8+
RUN install-php-extensions amqp apcu zmq ds event ev redis mongodb imagick pcntl uv-beta ffi pgsql intl gmp mbstring pdo_mysql xml dom iconv zip igbinary gd bcmath
9+
10+
RUN echo 'zend_extension=opcache' > /usr/local/etc/php/php.ini

bin/README-CALLMAP.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Working with the callmap
2+
3+
```
4+
bin/gen_callmap.sh
5+
```

bin/gen_base_callmap.php

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php // phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
2+
3+
4+
declare(strict_types=1);
5+
6+
$callmap = [];
7+
8+
function namedTypeName(ReflectionNamedType $refl): string
9+
{
10+
return $refl->getName();
11+
}
12+
13+
/**
14+
* @psalm-param ?ReflectionType $reflection_type
15+
*/
16+
function typeToString($reflection_type, string $defaultType): string
17+
{
18+
if (!$reflection_type) {
19+
return $defaultType;
20+
}
21+
22+
if ($reflection_type instanceof ReflectionNamedType) {
23+
$type = $reflection_type->getName();
24+
} elseif ($reflection_type instanceof ReflectionUnionType) {
25+
$type = implode('|', array_map('namedTypeName', $reflection_type->getTypes()));
26+
} elseif ($reflection_type instanceof ReflectionType) {
27+
$type = $reflection_type->__toString();
28+
} else {
29+
throw new LogicException('Unexpected reflection class ' . get_class($reflection_type) . ' found.');
30+
}
31+
32+
if ($reflection_type->allowsNull() && $type !== 'mixed') {
33+
$type .= '|null';
34+
}
35+
36+
return $type;
37+
}
38+
39+
/**
40+
* @return array<string, array{byRef: bool, refMode: 'rw'|'w'|'r', variadic: bool, optional: bool, type: string}>
41+
*/
42+
function paramsToEntries(ReflectionFunctionAbstract $reflectionFunction, string $defaultReturnType): array
43+
{
44+
// phpcs:disable SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator.RequiredNumericLiteralSeparator
45+
$res = PHP_VERSION_ID >= 80100 ? (
46+
$reflectionFunction->getTentativeReturnType() ?? $reflectionFunction->getReturnType()
47+
) : $reflectionFunction->getReturnType();
48+
49+
$res = [typeToString($res, $defaultReturnType)];
50+
51+
foreach ($reflectionFunction->getParameters() as $param) {
52+
$key = $param->getName();
53+
if ($param->isVariadic()) {
54+
$key = "...$key";
55+
}
56+
if ($param->isPassedByReference()) {
57+
$key = "&$key";
58+
}
59+
if ($param->isOptional()) {
60+
$key .= '=';
61+
}
62+
63+
$res[$key] = typeToString($param->getType(), 'mixed');
64+
}
65+
66+
return $res;
67+
}
68+
69+
// TEMP: not recommended, install the extension in the Dockerfile, instead
70+
foreach ([
71+
'couchbase/couchbase.php',
72+
'ibm_db2/ibm_db2.php',
73+
] as $stub) {
74+
if ($stub === 'ibm_db2/ibm_db2.php' && PHP_MAJOR_VERSION < 8) {
75+
continue;
76+
}
77+
$stub = file_get_contents("https://github.com/JetBrains/phpstorm-stubs/raw/refs/heads/master/$stub");
78+
if (PHP_MAJOR_VERSION === 7 && PHP_MINOR_VERSION === 0) {
79+
$stub = str_replace(['?', '<php'], ['', '<?php'], $stub);
80+
$stub = str_replace(['public const', 'protected const', 'private const'], 'const', $stub);
81+
}
82+
file_put_contents('temp.php', $stub);
83+
require 'temp.php';
84+
}
85+
86+
foreach (get_defined_functions() as $sub) {
87+
foreach ($sub as $name) {
88+
$name = strtolower($name);
89+
if ($name === 'paramstoentries') {
90+
continue;
91+
}
92+
if ($name === 'typetostring') {
93+
continue;
94+
}
95+
if ($name === 'namedtypename') {
96+
continue;
97+
}
98+
$func = new ReflectionFunction($name);
99+
100+
$args = paramsToEntries($func, 'mixed');
101+
102+
$callmap[$name] = $args;
103+
}
104+
}
105+
106+
foreach (get_declared_classes() as $class) {
107+
$refl = new ReflectionClass($class);
108+
109+
foreach ($refl->getMethods() as $method) {
110+
$args = paramsToEntries($method, $method->getName() === '__construct' ? 'void' : 'mixed');
111+
112+
$callmap[strtolower($class.'::'.$method->getName())] = $args;
113+
}
114+
}
115+
116+
$payload = '<?php // phpcs:ignoreFile
117+
118+
return '.var_export($callmap, true).';';
119+
$f = __DIR__.'/../dictionaries/autogen/CallMap_'.PHP_MAJOR_VERSION.PHP_MINOR_VERSION.'.php';
120+
121+
file_put_contents($f, $payload);

0 commit comments

Comments
 (0)