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

Does functionName only support functions with namespaces? #1412

Open
ngmy opened this issue Apr 25, 2024 · 2 comments
Open

Does functionName only support functions with namespaces? #1412

ngmy opened this issue Apr 25, 2024 · 2 comments

Comments

@ngmy
Copy link

ngmy commented Apr 25, 2024

Thanks for a good tool.

Does functionName only support functions with namespaces?

I want to detect Laravel request helper defined in the global namespace with the following configuration:

- type: functionName
  value: request

However, no request() is detected.
When I write \request() it is detected.

I am using 2.0.0.beta.

@developerstudservis
Copy link

developerstudservis commented Jul 10, 2024

I'm reproduce this issue today (
+1

With

deptrac -V
deptrac 1.0.2-211-g72caeb5

PS: only if calling context (e.g. class) has namespace. In global namespace class function call detected at both cases.
PPS: oops, my problem with function_call analyser, but looks like related bug.

@patrickkusebauch
Copy link
Collaborator

This is a current limitation of PHP. From a currently discussed RFC for PHP: https://wiki.php.net/rfc/global_function_parser_directive:

When calling functions from within a namespace, the parser does not know at compile time if the function is defined in the current namespace or if the global function will be used.

Since deptrac does not run your code, only parses it (similar to "compile"), it has the same limitation. Therefore the only option is to use FQN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants