Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: New sniff to examine type casts #1483

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 11, 2018

This sniff will check that PHP type casts are:

  • lowercase;
  • short form, i.e. (bool) not (boolean);
  • normalized, i.e. (float) not (real).

The sniff also discourages the use of the (unset) and the (binary) casts, including the b"$string" binary cast, though it is susceptible to bug squizlabs/PHP_CodeSniffer#1574.

The sniff has been added to the WordPress-Core ruleset.

Once the minimum PHPCS version has gone up to PHPCS 3.3.0+, the lowercase check part of the sniff can be removed in favour of adding the Generic.PHP.LowerCaseType sniff to the ruleset instead.

Fixes #1481

This sniff will check that PHP type casts are:
- lowercase;
- short form, i.e. (bool) not (boolean);
- normalized, i.e. (float) not (real).

The sniff also discourages the use of the `(unset)` and the `(binary)` casts, including the `b"$string"` binary cast, though it is susceptible to bug squizlabs/PHP_CodeSniffer 1574.

The sniff has been added to the `WordPress-Core` ruleset.

Once the minimum PHPCS version has gone up to PHPCS 3.3.0+, the lowercase check part of the sniff can be removed in favour of adding the `Generic.PHP.LowerCaseType` sniff  to the ruleset instead.

Fixes 1481
@JDGrimes JDGrimes merged commit c5515a7 into develop Sep 11, 2018
@JDGrimes JDGrimes deleted the feature/1481-new-typecast-sniff branch September 11, 2018 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants