Skip to content

Commit 8c47d85

Browse files
committed
Apply changes suggested during PR review
- Fix the title to match the sniff name. - Be specific about the @ operator in the standard description. - Mention the exception for certain functions without listing them. - Simplify the code examples to focus on the presence/absence of @. - Rename the variable from $conn_id to $connection as `ftp_connect()` does not return a connection ID.
1 parent c9c7a49 commit 8c47d85

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

WordPress/Docs/PHP/NoSilencedErrorsStandard.xml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,22 @@
11
<?xml version="1.0"?>
22
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd"
4-
title="Discourage the use of the PHP error silencing operator"
4+
title="No Silenced Errors"
55
>
66
<standard>
77
<![CDATA[
8-
Silencing errors is strongly discouraged. Use proper error checking instead.
9-
10-
Using the error operator with certain functions is allowed because no amount of error checking can fully prevent PHP from throwing errors when these functions are executed. The functions where this is permitted include, but are not limited to:
11-
12-
- `file_exists()`
13-
- `file_get_contents()`
14-
- `filesize()`
15-
- `filetype()`
16-
- `fopen()`
17-
- `ftp_login()`
18-
- `ftp_rename()`
8+
The error silencing operator (@) should not be used. As an exception, the operator is allowed for certain functions where errors cannot be prevented through error checking.
199
]]>
2010
</standard>
2111
<code_comparison>
22-
<code title="Valid: Using proper error checking when calling functions not in the allowed list.">
12+
<code title="Valid: Calling a function without error silencing.">
2313
<![CDATA[
24-
$conn_id = ftp_connect( $ftp_server );
25-
if ( ! $conn_id ) {
26-
// Handle it as needed.
27-
}
14+
$connection = <em></em>ftp_connect( $ftp_server );
2815
]]>
2916
</code>
30-
<code title="Invalid: Using the error operator to silence errors.">
17+
<code title="Invalid: Using the @ operator to silence errors.">
3118
<![CDATA[
32-
$conn_id = <em>@ftp_connect( $ftp_server );</em>
19+
$connection = <em>@</em>ftp_connect( $ftp_server );
3320
]]>
3421
</code>
3522
</code_comparison>

0 commit comments

Comments
 (0)