[php-src] PR #22799: Test hardening
| From: | NickSdot | Date: | Sat, 18 Jul 2026 19:35:56 +0000 |
| Subject: | [php-src] PR #22799: Test hardening | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-37142@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22799
Author: NickSdot
Test files sweep to make exception assertions more robust, and slightly unify style.
**Specifically:**
- adds thrown class to all exception assertions to protected against regressions
- further established the already recommended single exception formatting
- adds missing last line whitespaces were missing
**Target format:**
```php
echo $e::class, ': ', $e->getMessage(), \PHP_EOL; // + variations like line(), code(),
etc.
```
**Approach:**
Rewrites are handled by [this](https://github.com/NickSdot/php__internals-cs) deterministic helper
for conservative and safe, automated replacements. All exception assertion "flavours" from
php-src were extracted, and the tests where they were found promoted to source
fixtures. Rules were then ran against the fixtures, the results manually reviewed, and promoted to
target
[fixtures](https://github.com/NickSdot/php__internals-cs/tree/main/tests/Fixtures/exception_output_styles).
All replacement rules are tested against the source and target fixtures. The actual
"fixing" works as follows:
1. Scan PHPT files for exception-message output inside catch blocks.
2. Run the original PHPT through run-tests.php; skipped or already failing tests are
not rewritten.
3. Rewrite the PHPT to the normalised exception-output shape.
4. Run the rewritten PHPT through run-tests.php.
5. If output changed as expected, update the expected section from the actual run output.
6. Run the updated PHPT once more.
7. Keep only rewrites that pass verification.
## Modules & Commits
### Extensions
| Module | Commit |
|------------|--------------------------------------------------------------------------------|
| ext/random | https://github.com/php/php-src/commit/9dc4e194eddbe543f098c61bde8917a37c232bde
|
| ext/uri | https://github.com/php/php-src/commit/179f176cdcac47fa8c631e6afd46ca708a28e14c
|
### Zend
| Module | Commit |
|--------|--------|
| Zend | tbd |
---
PoC, marked as draft for now, and in coordination with Tim for now only applied to
ext/random and ext/uri.