mirror of
https://github.com/php/php-src.git
synced 2026-10-28 17:56:50 +08:00
[skip ci] CODING_STANDARDS.md: added exception class assertion reminder (#23220)
Co-authored-by: Weilin Du <weilindu@php.net>
This commit is contained in:
1 parent
a1fdc0b934
commit
849d955f1e
1 file changed
+15
@@ -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
|
||||
|
||||
Reference in new issue
Block a user