From 4c3150f9072fe93e24d07f2d56d2c85c472eb68c Mon Sep 17 00:00:00 2001 From: NickSdot Date: Wed, 12 Aug 2026 00:21:31 +0700 Subject: [PATCH] docs: added exception class assertion reminder --- CODING_STANDARDS.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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