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

DevelopmentCodeFragment does not catch fully qualified functions #846

Closed
6 tasks done
bkdotcom opened this issue Nov 16, 2020 · 3 comments · Fixed by #847
Closed
6 tasks done

DevelopmentCodeFragment does not catch fully qualified functions #846

bkdotcom opened this issue Nov 16, 2020 · 3 comments · Fixed by #847
Assignees
Labels
Bug Good first issue If you want to help, this may be a good start

Comments

@bkdotcom
Copy link

bkdotcom commented Nov 16, 2020

  • PHPMD version: 2.9.1
  • PHP Version:7.4.12
  • Installation type: composer
  • Operating System / Distribution & Version: OSX 10.14.6

Current Behavior

\print_r not caught

Expected Behavior

The method foo::bar() calls the typical debug function print_r() which is mostly only used during development.

Steps To Reproduce:

function bar($baz)
{
  \print_r($baz);    // not caught by DevelopmentCodeFragment rule
  print_r($baz);    // caught by DevelopmentCodeFragment rule
}

Checks before submitting

  • Be sure that there isn't already an issue about this. See: Issues list
  • Be sure that there isn't already a pull request about this. See: Pull requests
  • I have added every step to reproduce the bug.
  • If possible I added relevant code examples.
  • This issue is about 1 bug and nothing more.
  • The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
@kylekatarnls kylekatarnls added Good first issue If you want to help, this may be a good start Bug labels Nov 16, 2020
@kylekatarnls
Copy link
Member

Confirmed. Actually, this rule doesn't work when there is an active namespace so I actually never had it working in my projects. But allowing starting \ in function names would be a good start.

@samuelwang23
Copy link
Contributor

Could I please be assigned this issue?

samuelwang23 added a commit to samuelwang23/phpmd that referenced this issue Nov 22, 2020
Fixes issue phpmd#846 by adding functions like \print_r to the unwanted functions list.
@kylekatarnls
Copy link
Member

With pleasure :) 🥇

samuelwang23 added a commit to samuelwang23/phpmd that referenced this issue Nov 22, 2020
This reverts commit d81c9e6.
@ravage84 ravage84 added this to the 2.x (unspecific) milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Good first issue If you want to help, this may be a good start
Development

Successfully merging a pull request may close this issue.

4 participants