While reviewing PR #2591 which adds documentation for the WordPress.PHP.TypeCasts sniff, I noticed that https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#space-usage doesn't fully document all the rules that the WordPress.PHP.TypeCasts sniff enforces in the paragraph about type casts.
The handbook currently documents:
- Type casts must be lowercase (enforced by another sniff).
- Use
(int) not (integer).
- Use
(bool) not (boolean).
- Use
(float) not (real).
But the WordPress.PHP.TypeCasts sniff also enforces the following rules:
- Use
(float) instead of (double).
(unset) is forbidden.
(binary) and b"string" prefix are discouraged.
When the sniff was introduced in 2018 via PR WordPress/WordPress-Coding-Standards#1483, I believe the intention was to mention (unset) and (binary) in the handbook (see WordPress/WordPress-Coding-Standards#1481 (comment) and WordPress/WordPress-Coding-Standards#1481 (comment)), but it seems that never happened or at least I was not able to find it searching the history of https://github.com/WordPress/wpcs-docs/blame/master/wordpress-coding-standards/php.md.
(double) is not mentioned in the issue discussion, but to me, since 4361cec added a explicit mention to (real), I think (double) should be mentioned as well.
Should the handbook be updated or is there a reason that I'm missing not to update it? Also, please let me know if this is not the correct repository to ask this question.
While reviewing PR #2591 which adds documentation for the
WordPress.PHP.TypeCastssniff, I noticed that https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#space-usage doesn't fully document all the rules that theWordPress.PHP.TypeCastssniff enforces in the paragraph about type casts.The handbook currently documents:
(int)not(integer).(bool)not(boolean).(float)not(real).But the
WordPress.PHP.TypeCastssniff also enforces the following rules:(float)instead of(double).(unset)is forbidden.(binary)andb"string"prefix are discouraged.When the sniff was introduced in 2018 via PR WordPress/WordPress-Coding-Standards#1483, I believe the intention was to mention
(unset)and(binary)in the handbook (see WordPress/WordPress-Coding-Standards#1481 (comment) and WordPress/WordPress-Coding-Standards#1481 (comment)), but it seems that never happened or at least I was not able to find it searching the history of https://github.com/WordPress/wpcs-docs/blame/master/wordpress-coding-standards/php.md.(double)is not mentioned in the issue discussion, but to me, since 4361cec added a explicit mention to(real), I think(double)should be mentioned as well.Should the handbook be updated or is there a reason that I'm missing not to update it? Also, please let me know if this is not the correct repository to ask this question.