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

Sniff::get_declared_namespace_name(): improve code-style independence #1491

Merged
merged 1 commit into from
Oct 31, 2018

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 23, 2018

A namespace declaration can contain whitespace and comments and PHP will just ignore the whitespace and comments when reading the code. Also see: squizlabs/PHP_CodeSniffer#2150

While it is rare to encounter such code, this utility method should handle it correctly.

As for the $namespaceName to be returned by the method, this should not contain any whitespace or comments encountered. That way the namespace name will be "clean" for examination by sniffs.

Includes unit test via the GlobalVariablesOverride sniff.

Related to #763

A namespace declaration can contain whitespace and comments and PHP will just ignore the whitespace and comments when reading the code. Also see: squizlabs/PHP_CodeSniffer 2150

While it is rare to encounter such code, this utility method should handle it correctly.

As for the `$namespaceName` to be returned by the method, this should not contain any whitespace or comments encountered. That way the namespace name will be "clean" for examination by sniffs.

Includes unit test via the `GlobalVariablesOverride` sniff.
@jrfnl jrfnl merged commit 62c6cc7 into develop Oct 31, 2018
@jrfnl jrfnl deleted the feature/get-namespace-name-codestyle-independence branch October 31, 2018 16:44
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.

2 participants