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

PHP 5.6: New sniff to detect constant scalar expressions #617

Merged
merged 1 commit into from Apr 24, 2018

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Mar 16, 2018

… where previously only static values were allowed.

It is now possible to provide a scalar expression involving numeric and string literals and/or constants in contexts where PHP previously expected a static value, such as constant and property declarations and default function arguments.

Refs:

Includes extensive unit tests.

Notes:

  • The sniff has been set up in a way that the HeredocInitialize sniff will be able to extend it in the near future as that sniff ought to use the same base logic as is contained in the process() method of this sniff (The HeredocInitialize sniff currently doesn't examine all possible cases to which the heredoc change applies).
  • I've ran the sniff over some 200.000 files in the WP plugin & theme directory to test against false positives and I've fixed all false positives which I found, so I'm reasonably confident that it covers all exceptions.

Fixes #399

…usly only static values were allowed.

> It is now possible to provide a scalar expression involving numeric and string literals and/or constants in contexts where PHP previously expected a static value, such as constant and property declarations and default function arguments.

Ref: http://php.net/manual/en/migration56.new-features.php#migration56.new-features.const-scalar-exprs

Includes extensive unit tests.

Notes:
* The sniff has been set up in a way that the `HeredocInitialize` sniff will be able to extend it in the near future as that sniff ought to use the same base logic as is contained in the `process()` method (it currently doesn't examine all possible cases to which the heredoc change applies).
* I've ran the sniff over some 200.000 files in the WP plugin & theme directory to test against false positives and I've fixed all false positives which I found.
@jrfnl jrfnl force-pushed the php5.6/399-scalar-expressions branch from ddf2a0e to 9565679 Compare April 8, 2018 14:04
@wimg wimg merged commit f13e1c3 into master Apr 24, 2018
@wimg wimg deleted the php5.6/399-scalar-expressions branch April 24, 2018 22:19
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.

PHP 5.6: Sniff for scalar expressions used in const/property/static variable declarations
2 participants