PHP 5.3: New PHPCompatibility.Namespaces.ReservedNames sniff#1026
Merged
PHP 5.3: New PHPCompatibility.Namespaces.ReservedNames sniff#1026
PHPCompatibility.Namespaces.ReservedNames sniff#1026Conversation
Member
Author
|
Hmm... looks like something weird is going on as Travis doesn't seem to be reporting on the PR (though the build does pass: https://travis-ci.org/github/PHPCompatibility/PHPCompatibility/builds/681042349). |
0fa6c63 to
818b96b
Compare
PHPCompatibility.Namespaces.ReservedNames sniffPHPCompatibility.Namespaces.ReservedNames sniff
> The Namespace name PHP, and compound names starting with this name (like PHP\Classes) are reserved for internal language use and should not be used in the userspace code. Source: https://www.php.net/manual/en/language.namespaces.rationale.php This PR introduces a new `PHPCompatibility.Namespaces.ReservedNames` sniff to detect use of namespace names reserved by PHP, in userland code. The sniff will throw a `warning` when a reserved namespace name is detected. This sniff is along the same lines as the `PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames` sniff which does the same for reserved function names to prevent code being introduced in userland code which has a high risk of being incompatible with future PHP versions. Includes unit tests. Fixes 1025
818b96b to
c332efb
Compare
wimg
approved these changes
May 5, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source: https://www.php.net/manual/en/language.namespaces.rationale.php
This PR introduces a new
PHPCompatibility.Namespaces.ReservedNamessniff to detect use of namespace names reserved by PHP, in userland code.The sniff will throw a
warningwhen a reserved namespace name is detected.This sniff is along the same lines as the
PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNamessniff which does the same for reserved function names to prevent code being introduced in userland code which has a high risk of being incompatible with future PHP versions.Includes unit tests.
Fixes #1025