Skip to content

Commit 5f44ece

Browse files
dingo-djrfnl
andcommitted
Final minor grammar changes
Co-authored-by: Juliette <[email protected]>
1 parent 36243c8 commit 5f44ece

File tree

1 file changed

+9
-9
lines changed
  • wordpress-coding-standards

1 file changed

+9
-9
lines changed

wordpress-coding-standards/php.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ While not all code may fully comply with these standards (yet), all newly commit
66

77
Keep the following rules in mind when writing PHP code for WordPress, whether for core programming code, plugins, or themes.
88

9-
See also: [PHP Inline Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/).
9+
Also see [PHP Inline Documentation Standards](https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/) for further guidelines.
1010

1111
## Single and Double Quotes
1212

@@ -133,7 +133,7 @@ Note that requiring the use of braces means that _single-statement inline contro
133133

134134
Using long array syntax ( `array( 1, 2, 3 )` ) for declaring arrays is generally more readable than short array syntax ( `[ 1, 2, 3 ]` ), particularly for those with vision difficulties. Additionally, it's much more descriptive for beginners.
135135

136-
Arrays must be declared using the long array syntax.
136+
Arrays must be declared using long array syntax.
137137

138138
## Closures (Anonymous Functions)
139139

@@ -237,11 +237,11 @@ Incorrect:
237237

238238
## Remove Trailing Spaces
239239

240-
Remove trailing whitespace at the end of each line. Omitting the closing PHP tag at the end of a file is preferred. If you use the tag, make sure you remove the trailing whitespace.
240+
Remove trailing whitespace at the end of each line. Omitting the closing PHP tag at the end of a file is preferred. If you use the tag, make sure you remove trailing whitespace.
241241

242242
## Space Usage
243243

244-
Always put spaces after commas, and on both sides of the logical, comparison, string, and assignment operators.
244+
Always put spaces after commas, and on both sides of logical, comparison, string and assignment operators.
245245

246246
```php
247247
x === 23
@@ -279,7 +279,7 @@ When performing logical comparisons, do it like so:
279279
if ( ! $foo ) { ...
280280
```
281281

282-
[Type casts](https://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting) must be lowercase. Always prefer the short form of type casts, `(int)` instead of `(integer)` and `(bool)` rather than `(boolean)`. For float casts use `(float)`, not `(real)` which is [deprecated](https://wiki.php.net/rfc/deprecations_php_7_4#the_real_type) in PHP 7.4, and removed in PHP 8:
282+
[Type casts](https://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting) must be lowercase. Always prefer the short form of type casts, `(int)` instead of `(integer)` and `(bool)` rather than `(boolean)`. For float casts use `(float)`, not `(real)` which is [deprecated](https://www.php.net/manual/en/migration74.deprecated.php#migration74.deprecated.core.real) in PHP 7.4, and removed in PHP 8:
283283

284284
```php
285285
foreach ( (array) $foo as $bar ) { ...
@@ -348,7 +348,7 @@ See [Data Validation](https://developer.wordpress.org/plugins/security/data-vali
348348

349349
Avoid touching the database directly. If there is a defined function that can get the data you need, use it. Database abstraction (using functions instead of queries) helps keep your code forward-compatible and, in cases where results are cached in memory, it can be many times faster.
350350

351-
If you must touch the database, consider discussing it in Slack and creating a [Trac](https://core.trac.wordpress.org/) ticket.
351+
If you must touch the database, consider creating a [Trac](https://core.trac.wordpress.org/) ticket. There you can discuss the possibility of adding a new function to cover the functionality you wanted, for the next WordPress version.
352352

353353
## Naming Conventions
354354

@@ -457,7 +457,7 @@ Dynamic hooks should be named using interpolation rather than concatenation for
457457

458458
Dynamic hooks are hooks that include dynamic values in their tag name, e.g. `{$new_status}_{$post->post_type}` (publish_post).
459459

460-
Variables used in hook tags should be wrapped in curly braces `{` and `}`, with the complete outer tag name wrapped in double-quotes. This is to ensure PHP can correctly parse the given variables' types within the interpolated string.
460+
Variables used in hook tags should be wrapped in curly braces `{` and `}`, with the complete outer tag name wrapped in double quotes. This is to ensure PHP can correctly parse the given variables' types within the interpolated string.
461461

462462
```php
463463
do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
@@ -575,11 +575,11 @@ The `eval()` construct is _very dangerous_ and is impossible to secure. Addition
575575

576576
As noted in the [PHP docs](https://www.php.net/manual/en/language.operators.errorcontrol.php):
577577

578-
> PHP supports one error control operator: the at sign (`@`). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
578+
> PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any diagnostic error that might be generated by that expression will be suppressed.
579579
580580
While this operator does exist in Core, it is often used lazily instead of doing proper error checking. Its use is highly discouraged, as even the PHP docs also state:
581581

582-
> Warning: Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.
582+
> Warning: Prior to PHP 8.0.0, it was possible for the @ operator to disable critical errors that will terminate script execution. For example, prepending @ to a call of a function that did not exist, by being unavailable or mistyped, would cause the script to terminate with no indication as to why.
583583
584584
## Don't `extract()`
585585

0 commit comments

Comments
 (0)