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

Add 'ignore-namespaces' option to DevelopmentCodeFragment #571

Merged
merged 7 commits into from Aug 13, 2019

Conversation

tariq86
Copy link
Contributor

@tariq86 tariq86 commented May 11, 2018

Fixes #532

What: Add new ignore-namespaces property to DevelopmentCodeFragment rule, from the Design ruleset.

How: Declare new property ignore-namespaces with a default value of false to avoid behavior changes. If it is enabled, then the namespace will be stripped from the function before

Why: As noted in #532, the current implementation is not detecting unwanted functions in namespaced classes. This is happening because $node->findChildrenOfType('FunctionPostfix') is returning the method names prefixed with the namespace. In other words, var_dump() is being returned as \App\Namespace::var_dump()). This is causing the in_array check for dev. functions to fail.

@MarkVaughn
Copy link
Collaborator

This looks promising, can you rebase or merge in the new code to see if the tests pass?

kylekatarnls
kylekatarnls previously approved these changes Jul 28, 2019
Copy link
Member

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for me to be merged. Still it can be improved as with PHP 7.1, such functions calls should not be considered as namespaced functions.

@ravage84 ravage84 added this to the 2.8.0 milestone Jul 28, 2019
…v-frag-ns-ignore

# Conflicts:
#	composer.lock
Copy link
Member

@kylekatarnls kylekatarnls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved conflict with master.

@tvbeek
Copy link
Member

tvbeek commented Aug 13, 2019

@tariq86 Thanks for the merge request.

@tvbeek tvbeek merged commit 9063b80 into phpmd:master Aug 13, 2019
kylekatarnls added a commit that referenced this pull request Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

DevelopmentCodeFragment does not work in Files with namespace
5 participants