-
-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for WordPress.PHP.NoSilencedErrors
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0"?> | ||
<documentation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://phpcsstandards.github.io/PHPCSDevTools/phpcsdocs.xsd" | ||
title="Discourage the use of the PHP error silencing operator" | ||
> | ||
<standard> | ||
<![CDATA[ | ||
Silencing errors is strongly discouraged. Use proper error checking instead. | ||
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: | ||
- `file_exists()` | ||
- `file_get_contents()` | ||
- `filesize()` | ||
- `filetype()` | ||
- `fopen()` | ||
- `ftp_login()` | ||
- `ftp_rename()` | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Using proper error checking when calling functions not in the allowed list."> | ||
<![CDATA[ | ||
$conn_id = ftp_connect( $ftp_server ); | ||
if ( ! $conn_id ) { | ||
// Handle it as needed. | ||
} | ||
]]> | ||
</code> | ||
<code title="Invalid: Using the error operator to silence errors."> | ||
<![CDATA[ | ||
$conn_id = <em>@ftp_connect( $ftp_server );</em> | ||
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |