Hello,
Following Symfony 7.4 latest upgrade (containing security fixes) I got trouble with our test suite.
AI suggesting root cause from Assert lib.
PHPUnitHandler::isVerbose() directly reads $_SERVER['argv'].
In HTTP/non-CLI contexts, $_SERVER['argv'] can be missing. When an assertion fails, the failure formatting triggers an Undefined array key "argv" warning/type error and masks the original assertion failure.
Reproducer:
require 'vendor/autoload.php';
unset($_SERVER['argv']);
Zenstruck\Assert::try(
fn () => throw new RuntimeException('original failure'),
'Assertion wrapper failure',
);
Actual result:
Undefined array key "argv" from PHPUnitHandler::isVerbose().
Expected result:
The original assertion failure should be reported.
Potential fix:
public static function isVerbose(): bool
{
$argv = $_SERVER['argv'] ?? [];
return \in_array('--verbose', $argv, true) || \in_array('-v', $argv, true);
}
This appeared through zenstruck/messenger-test because TestTransport calls Assert::try() when test_serialization is enabled, but the crashing code is in zenstruck/assert.
I can make a MR if you think this is a valid bug.
Hello,
Following Symfony 7.4 latest upgrade (containing security fixes) I got trouble with our test suite.
AI suggesting root cause from Assert lib.
PHPUnitHandler::isVerbose()directly reads$_SERVER['argv'].In HTTP/non-CLI contexts,
$_SERVER['argv']can be missing. When an assertion fails, the failure formatting triggers anUndefined array key "argv"warning/type error and masks the original assertion failure.Reproducer:
Actual result:
Undefined array key "argv" from PHPUnitHandler::isVerbose().
Expected result:
The original assertion failure should be reported.
Potential fix:
This appeared through zenstruck/messenger-test because TestTransport calls Assert::try() when test_serialization is enabled, but the crashing code is in zenstruck/assert.
I can make a MR if you think this is a valid bug.