Skip to content

sitePassByRefFunctions Doesn't support functions with namespaces #349

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

Closed
mikeybinns opened this issue Mar 7, 2025 · 6 comments · Fixed by #351
Closed

sitePassByRefFunctions Doesn't support functions with namespaces #349

mikeybinns opened this issue Mar 7, 2025 · 6 comments · Fixed by #351

Comments

@mikeybinns
Copy link

Currently the sniff customisation property for sitePassByRefFunctions only supports standard functions, not namespaced functions.

It will work if the namespace is omitted, but if two namespaces contain the same function name, it will apply to both.

This works:

<property name="sitePassByRefFunctions" value="function_name:1"/>

but applies to all of these:

\Some\Namespace\function_name($test);
function_name($test);
\Some\Other\Namespace\function_name($test);

This doesn't work:

<property name="sitePassByRefFunctions" value="\Some\Namespace\function_name:1"/>

It would be great if namespaces were supported so we could be more specific about the functions :)

function_name($test); // Undefined var $test
\Some\Other\Namespace\function_name($test); // Undefined var $test
\Some\Namespace\function_name($test); // No error
function_name($test); // No error (defined in `\Some\Namespace\function_name()`)
\Some\Other\Namespace\function_name($test); // No error (defined in `\Some\Namespace\function_name()`)
@sirbrillig
Copy link
Owner

oh, that's a good point.

@sirbrillig
Copy link
Owner

\Some\Other\Namespace\function_name($test); // No error (defined in \Some\Namespace\function_name())
function_name($test); // No error (defined in \Some\Namespace\function_name())

🤔 Tell me more about these cases.

I can understand this one since it's explicitly part of the option, but I don't grok the other two.

\Some\Namespace\function_name($test); // No error

@mikeybinns
Copy link
Author

Sorry for the confusion, I think that's more something that implicitly happened with my function, but on further reflection it's not guaranteed that a variable passed by ref will always be set, so ignore those :)

@sirbrillig
Copy link
Owner

Nice! Then I think #351 will fix this issue.

@mikeybinns
Copy link
Author

Awesome, thanks for the speedy fix! :)

@sirbrillig
Copy link
Owner

One thing to note: even with this change, if you list function_name:1 (without a namespace), it will still match \My\Namespace\function_name(). Changing this behavior would be a breaking change and I'm not sure it's even a good idea since the function may be aliased (eg; use \My\Namespace\function_name).

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

Successfully merging a pull request may close this issue.

2 participants