Skip to content

Commit 5169675

Browse files
janedbalondrejmirtes
authored andcommitted
Fix asserts, add Dockerfile for PHP 8.4
1 parent a103cfe commit 5169675

File tree

5 files changed

+108
-19
lines changed

5 files changed

+108
-19
lines changed

src/Type/Doctrine/Query/QueryResultTypeWalker.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,11 @@ public function walkLiteral($literal): string
15871587
if (stripos($value, 'e') !== false) {
15881588
$type = new DqlConstantStringType((string) (float) $value, $literal->type);
15891589
} else {
1590+
// if ($this->phpVersion->getVersionId() >= 80400) {
1591+
// $type = new ConstantFloatType((float) $value);
1592+
// } else {
1593+
// $type = new DqlConstantStringType($value, $literal->type);
1594+
// }
15901595
$type = new DqlConstantStringType($value, $literal->type);
15911596
}
15921597

tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,7 @@ public static function provideCases(): iterable
27432743
'pdoPgsqlResult' => 0.125,
27442744
'pgsqlResult' => 0.125,
27452745
'mssqlResult' => 0.125,
2746-
'stringify' => self::STRINGIFY_DEFAULT,
2746+
'stringify' => self::STRINGIFY_PG_FLOAT,
27472747
];
27482748

27492749
yield 'MAX(t.col_decimal)' => [
@@ -4170,6 +4170,38 @@ public static function provideCases(): iterable
41704170
'stringify' => self::STRINGIFY_DEFAULT,
41714171
];
41724172

4173+
yield 'COALESCE(0, 0)' => [
4174+
'data' => self::dataDefault(),
4175+
'select' => 'SELECT COALESCE(0, 0) FROM %s t',
4176+
'mysql' => self::int(),
4177+
'sqlite' => self::int(),
4178+
'pdo_pgsql' => self::int(),
4179+
'pgsql' => self::int(),
4180+
'mssql' => self::mixed(),
4181+
'mysqlResult' => 0,
4182+
'sqliteResult' => 0,
4183+
'pdoPgsqlResult' => 0,
4184+
'pgsqlResult' => 0,
4185+
'mssqlResult' => 0,
4186+
'stringify' => self::STRINGIFY_DEFAULT,
4187+
];
4188+
4189+
yield 'COALESCE(1.0, 1.0)' => [
4190+
'data' => self::dataDefault(),
4191+
'select' => 'SELECT COALESCE(1.0, 1.0) FROM %s t',
4192+
'mysql' => self::numericString(),
4193+
'sqlite' => self::float(),
4194+
'pdo_pgsql' => self::numericString(),
4195+
'pgsql' => self::numericString(),
4196+
'mssql' => self::mixed(),
4197+
'mysqlResult' => '1.0',
4198+
'sqliteResult' => 1.0,
4199+
'pdoPgsqlResult' => '1.0',
4200+
'pgsqlResult' => '1.0',
4201+
'mssqlResult' => '1.0',
4202+
'stringify' => self::STRINGIFY_DEFAULT,
4203+
];
4204+
41734205
yield 'COALESCE(1e0, 1.0)' => [
41744206
'data' => self::dataDefault(),
41754207
'select' => 'SELECT COALESCE(1e0, 1.0) FROM %s t',
@@ -4255,15 +4287,17 @@ public static function provideCases(): iterable
42554287
'select' => 'SELECT COALESCE(t.col_float_nullable, 0) FROM %s t',
42564288
'mysql' => self::float(),
42574289
'sqlite' => TypeCombinator::union(self::float(), self::int()),
4258-
'pdo_pgsql' => TypeCombinator::union(self::float(), self::int()),
4290+
'pdo_pgsql' => PHP_VERSION_ID < 80400
4291+
? TypeCombinator::union(self::numericString(), self::int())
4292+
: TypeCombinator::union(self::float(), self::int()),
42594293
'pgsql' => TypeCombinator::union(self::float(), self::int()),
42604294
'mssql' => self::mixed(),
42614295
'mysqlResult' => 0.0,
42624296
'sqliteResult' => 0,
4263-
'pdoPgsqlResult' => 0.0,
4297+
'pdoPgsqlResult' => PHP_VERSION_ID < 80400 ? '0' : 0.0,
42644298
'pgsqlResult' => 0.0,
42654299
'mssqlResult' => 0.0,
4266-
'stringify' => self::STRINGIFY_PG_FLOAT,
4300+
'stringify' => self::STRINGIFY_DEFAULT,
42674301
];
42684302

42694303
yield 'COALESCE(t.col_float_nullable, 0.0)' => [
@@ -4303,63 +4337,71 @@ public static function provideCases(): iterable
43034337
'select' => 'SELECT COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, 0) FROM %s t',
43044338
'mysql' => self::float(),
43054339
'sqlite' => TypeCombinator::union(self::float(), self::int()),
4306-
'pdo_pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
4340+
'pdo_pgsql' => PHP_VERSION_ID < 80400
4341+
? TypeCombinator::union(self::numericString(), self::int())
4342+
: TypeCombinator::union(self::numericString(), self::int(), self::float()),
43074343
'pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
43084344
'mssql' => self::mixed(),
43094345
'mysqlResult' => 0.0,
43104346
'sqliteResult' => 0,
4311-
'pdoPgsqlResult' => 0.0,
4347+
'pdoPgsqlResult' => PHP_VERSION_ID < 80400 ? '0' : 0.0,
43124348
'pgsqlResult' => 0.0,
43134349
'mssqlResult' => 0.0,
4314-
'stringify' => self::STRINGIFY_PG_FLOAT,
4350+
'stringify' => self::STRINGIFY_DEFAULT,
43154351
];
43164352

43174353
yield 'COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, 0.0)' => [
43184354
'data' => self::dataDefault(),
43194355
'select' => 'SELECT COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, 0.0) FROM %s t',
43204356
'mysql' => self::float(),
43214357
'sqlite' => TypeCombinator::union(self::float(), self::int()),
4322-
'pdo_pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
4358+
'pdo_pgsql' => PHP_VERSION_ID < 80400
4359+
? TypeCombinator::union(self::numericString(), self::int())
4360+
: TypeCombinator::union(self::numericString(), self::int(), self::float()),
43234361
'pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
43244362
'mssql' => self::mixed(),
43254363
'mysqlResult' => 0.0,
43264364
'sqliteResult' => 0.0,
4327-
'pdoPgsqlResult' => 0.0,
4365+
'pdoPgsqlResult' => PHP_VERSION_ID < 80400 ? '0' : 0.0,
43284366
'pgsqlResult' => 0.0,
43294367
'mssqlResult' => 0.0,
4330-
'stringify' => self::STRINGIFY_PG_FLOAT,
4368+
'stringify' => self::STRINGIFY_DEFAULT,
43314369
];
43324370

43334371
yield 'COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, 0e0)' => [
43344372
'data' => self::dataDefault(),
43354373
'select' => 'SELECT COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, 0e0) FROM %s t',
43364374
'mysql' => self::float(),
43374375
'sqlite' => TypeCombinator::union(self::float(), self::int()),
4338-
'pdo_pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
4376+
'pdo_pgsql' => PHP_VERSION_ID < 80400
4377+
? TypeCombinator::union(self::numericString(), self::int())
4378+
: TypeCombinator::union(self::numericString(), self::int(), self::float()),
43394379
'pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
43404380
'mssql' => self::mixed(),
43414381
'mysqlResult' => 0.0,
43424382
'sqliteResult' => 0.0,
4343-
'pdoPgsqlResult' => 0.0,
4383+
'pdoPgsqlResult' => PHP_VERSION_ID < 80400 ? '0' : 0.0,
43444384
'pgsqlResult' => 0.0,
43454385
'mssqlResult' => 0.0,
4346-
'stringify' => self::STRINGIFY_PG_FLOAT,
4386+
'stringify' => self::STRINGIFY_DEFAULT,
43474387
];
43484388

43494389
yield "COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, '0')" => [
43504390
'data' => self::dataDefault(),
43514391
'select' => 'SELECT COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, \'0\') FROM %s t',
43524392
'mysql' => self::numericString(),
43534393
'sqlite' => TypeCombinator::union(self::float(), self::int(), self::numericString()),
4354-
'pdo_pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
4394+
'pdo_pgsql' => PHP_VERSION_ID < 80400
4395+
? TypeCombinator::union(self::numericString(), self::int())
4396+
: TypeCombinator::union(self::numericString(), self::int(), self::float()),
43554397
'pgsql' => TypeCombinator::union(self::numericString(), self::int(), self::float()),
43564398
'mssql' => self::mixed(),
43574399
'mysqlResult' => '0',
43584400
'sqliteResult' => '0',
4359-
'pdoPgsqlResult' => 0.0,
4401+
'pdoPgsqlResult' => PHP_VERSION_ID < 80400 ? '0' : 0.0,
43604402
'pgsqlResult' => 0.0,
43614403
'mssqlResult' => 0.0,
4362-
'stringify' => self::STRINGIFY_PG_FLOAT,
4404+
'stringify' => self::STRINGIFY_DEFAULT,
43634405
];
43644406

43654407
yield 'COALESCE(t.col_int_nullable, t.col_decimal_nullable, t.col_float_nullable, t.col_string)' => [

tests/Platform/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ Set current working directory to project root.
88
- `printf "UID=$(id -u)\nGID=$(id -g)" > .env`
99
- `docker-compose -f tests/Platform/docker/docker-compose.yml up -d`
1010

11-
# Test behaviour with old stringification
11+
# Test behaviour for PHP 8.0 (old stringification)
1212
- `docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php80 composer update`
1313
- `docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php80 php -d memory_limit=1G vendor/bin/phpunit --group=platform`
1414

15-
# Test behaviour with new stringification
15+
# Test behaviour for PHP 8.1 (adjusted stringification)
1616
- `docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php81 composer update`
1717
- `docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php81 php -d memory_limit=1G vendor/bin/phpunit --group=platform`
18+
19+
# Test behaviour for PHP 8.4 (pdo_pgsql float stringification fix)
20+
- `docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php84 composer update`
21+
- `docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php84 php -d memory_limit=1G vendor/bin/phpunit --group=platform`
1822
```
1923

2024
You can also run utilize those containers for PHPStorm PHPUnit configuration.
2125

2226
Since the dataset is huge and takes few minutes to run, you can filter only functions you are interested in:
2327
```sh
24-
docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php81 php -d memory_limit=1G vendor/bin/phpunit --group=platform --filter "AVG"
28+
docker-compose -f tests/Platform/docker/docker-compose.yml run --rm php84 php -d memory_limit=1G vendor/bin/phpunit --group=platform --filter "AVG"
2529
```

tests/Platform/docker/Dockerfile84

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM php:8.4.0beta4-cli
2+
3+
# MSSQL
4+
RUN apt update \
5+
&& apt install -y gnupg2 \
6+
&& apt install -y unixodbc-dev unixodbc \
7+
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
8+
&& curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | tee /etc/apt/sources.list.d/mssql-tools.list \
9+
&& apt update \
10+
&& ACCEPT_EULA=Y apt install -y msodbcsql17 \
11+
&& pecl install sqlsrv \
12+
&& pecl install pdo_sqlsrv \
13+
&& docker-php-ext-enable sqlsrv pdo_sqlsrv
14+
15+
RUN set -ex \
16+
&& apt update \
17+
&& apt install -y bash zip libpq-dev libsqlite3-dev \
18+
&& pecl install xdebug-3.4 mongodb \
19+
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
20+
&& docker-php-ext-install pdo mysqli pgsql pdo_mysql pdo_pgsql pdo_sqlite \
21+
&& docker-php-ext-enable mongodb # TODO xdebug not yet supported here
22+
23+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
24+

tests/Platform/docker/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,17 @@ services:
6363
user: ${UID:-1000}:${GID:-1000}
6464
volumes:
6565
- ../../../:/app
66+
67+
php84:
68+
depends_on: [mysql, pgsql]
69+
build:
70+
context: .
71+
dockerfile: ./Dockerfile84
72+
environment:
73+
MYSQL_HOST: mysql
74+
PGSQL_HOST: pgsql
75+
MSSQL_HOST: mssql
76+
working_dir: /app
77+
user: ${UID:-1000}:${GID:-1000}
78+
volumes:
79+
- ../../../:/app

0 commit comments

Comments
 (0)