[php-src] master: [skip ci] CODING_STANDARDS.md: added exception class assertion reminder (#23220)
| From: | NickSdot via GitHub | Date: | Wed, 12 Aug 2026 11:22:21 +0000 |
| Subject: | [php-src] master: [skip ci] CODING_STANDARDS.md: added exception class assertion reminder (#23220) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-140675@lists.php.net to get a copy of this message | ||
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-08-12T19:22:18+08:00
Commit: https://github.com/php/php-src/commit/849d955f1e7311e5aa0c8fcebbfc851f4d3c3639
Raw diff: https://github.com/php/php-src/commit/849d955f1e7311e5aa0c8fcebbfc851f4d3c3639.diff
[skip ci] CODING_STANDARDS.md: added exception class assertion reminder (#23220)
Co-authored-by: Weilin Du <weilindu@php.net>
Changed paths:
M CODING_STANDARDS.md
Diff:
diff --git a/CODING_STANDARDS.md b/CODING_STANDARDS.md
index 3a53d0e258ca..f2c559a389ff 100644
--- a/CODING_STANDARDS.md
+++ b/CODING_STANDARDS.md
@@ -295,6 +295,21 @@ rewritten to comply with these rules.
1. Extensions should be well tested using
*.phpt tests. Read more at
[qa.php.net](https://qa.php.net/write-test.php) documentation.
+2. When testing exceptions, assert the error class in the catch block.
+
+```diff
+ try {
+ throw new ValueError('foo');
+ } catch (ValueError $e) {
+- echo $e->getMessage(), "\n";
++ echo $e::class, ': ', $e->getMessage(), "\n";
+ }
+
+ --EXPECT--
+- foo
++ ValueError: foo
+```
+
## New and experimental functions
To reduce the problems normally associated with the first public implementation