Skip to content

Commit 4545ecf

Browse files
committed
Downgrade Symfony/Process
A bit messier than expected. Current version of symfony/process (used only in dev) has a security advisory. There is no version that can be upgraded to which supports Php8.0. However, a downgrade to V5 will work. When running with Php8.4, PhpUnit references E_STRICT, which is deprecated in 8.4. I don't understand why this doesn't happen with release1291. Be that as it may, we can't upgrade Phpunit to V10 because we need to support Php8.0. So, monkey around with tests/bootstrap.php to avoid problems.
1 parent 2aee18e commit 4545ecf

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"phpstan/phpstan-phpunit": "^1.0",
9898
"phpunit/phpunit": "^9.6",
9999
"squizlabs/php_codesniffer": "^3.7",
100+
"symfony/process": "^5",
100101
"tecnickcom/tcpdf": "^6.5"
101102
},
102103
"suggest": {

composer.lock

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/bootstrap.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,31 @@ function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int
2525
return true; // message suppressed - stop error handling
2626
}
2727

28-
throw new Exception("$errstr $filename $lineno");
28+
// This code applies only when running release210 with Php8.4.
29+
// I don't get it at all. I think mitoteam is the victim of circumstance.
30+
// We need to run PhpUnit 9 because we need to support Php8.0.
31+
// We are at the highest release of PhpUnit9,
32+
// but it refers to E_STRICT,
33+
// which is deprecated in 8.4.
34+
if (
35+
str_contains($errstr, 'Constant ')
36+
&& str_contains($errstr, ' already defined')
37+
&& str_contains($filename, 'mitoteam')
38+
) {
39+
return true;
40+
}
41+
42+
if (!method_exists(PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
43+
throw new Exception("$errstr $filename $lineno");
44+
}
45+
46+
throw new Exception("$errstr");
2947
}
3048

3149
return false; // continue error handling
3250
}
3351

34-
if (!method_exists(PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
52+
if (!method_exists(PHPUnit\Framework\TestCase::class, 'setOutputCallback') || PHP_VERSION_ID >= 80400) {
3553
ini_set('error_reporting', (string) E_ALL);
3654
set_error_handler('phpunit10ErrorHandler');
3755
}

0 commit comments

Comments
 (0)