From 4b17ba0dfa6617cdfb18fe7cd62b5d5cbaf66709 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 29 Oct 2025 16:45:21 -0300 Subject: [PATCH] Simplify PHP type cast documentation - Remove reference to deprecated (real) cast and PHP version-specific deprecation details. - Update code example to show correct/incorrect usage with (bool) and (boolean). Fixes 154. Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- wordpress-coding-standards/php.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wordpress-coding-standards/php.md b/wordpress-coding-standards/php.md index 9f4e728..377a348 100644 --- a/wordpress-coding-standards/php.md +++ b/wordpress-coding-standards/php.md @@ -202,12 +202,11 @@ When performing logical comparisons, do it like so: if ( ! $foo ) { ... ``` -[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: +[Type casts](https://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting) must be lowercase. Always prefer the short, canonical form of type casts, `(int)` instead of `(integer)` and `(bool)` rather than `(boolean)`. For float casts use `(float)`. ```php -foreach ( (array) $foo as $bar ) { ... - -$foo = (bool) $bar; +$foo = (bool) $bar; // Correct. +$foo = (boolean) $bar; // Incorrect. ``` When referring to array items, only include a space around the index if it is a variable, for example: