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

Wildcard definition for class in global namespace matches any namespace #861

Closed
Micr0mega opened this issue Aug 29, 2023 · 4 comments · Fixed by #862
Closed

Wildcard definition for class in global namespace matches any namespace #861

Micr0mega opened this issue Aug 29, 2023 · 4 comments · Fixed by #862
Labels

Comments

@Micr0mega
Copy link

The project I am working on has quite some classes defined in the global namespace.
When adding a wildcard definition for these classes, not only those classes are matched, but also matching class names in any namespace.
This is quite unexpected, since the documentation states:

the wildcard does not match across namespaces

For example:

return [
    'Job*' => DI\autowire()->method('foo', 'bar'),
];

will call foo('bar') on class JobDoSomething, but also on class SomeNamespace\JobScheduler, which is not in the global namespace.

I am unfortunately on version 6.3.5, because PHP 7.2 ... But the code for matching the wildcard (regex) looks to be equal in both 6.4 and master.

@mnapoli mnapoli added the bug label Aug 29, 2023
@mnapoli
Copy link
Member

mnapoli commented Aug 29, 2023

That's an interesting bug indeed, happy to merge a PR with a test that reproduces it + a fix!

@Micr0mega
Copy link
Author

I'd be happy to, but would you be willing to release 6.3.6 to allow this fix to work on PHP 7.2? And then probably 6.4.1 as well for PHP 7.4.

If so, should I branch from master and target my PR there, so you can backport the fix to 6.x? Or would you suggest another approach?

@mnapoli
Copy link
Member

mnapoli commented Aug 29, 2023

Oh unfortunately I can't allocate time to support PHP 7.2, even PHP-DI 6, I'd rather avoid new releases for older versions unless there's a security issue or serious regression.

Micr0mega pushed a commit to 050media/PHP-DI that referenced this issue Aug 31, 2023
Micr0mega pushed a commit to 050media/PHP-DI that referenced this issue Aug 31, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…nition string
Micr0mega pushed a commit to 050media/PHP-DI that referenced this issue Aug 31, 2023
Micr0mega pushed a commit to 050media/PHP-DI that referenced this issue Aug 31, 2023
@Micr0mega
Copy link
Author

Understandable, I have gone ahead and created the fix anyway, as it was quite simple and I hope to benefit from it in the future. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants