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

Improve namespace and class replacer logic #5

Closed
coenjacobs opened this issue Mar 24, 2017 · 4 comments
Closed

Improve namespace and class replacer logic #5

coenjacobs opened this issue Mar 24, 2017 · 4 comments

Comments

@coenjacobs
Copy link
Owner

As per @schlessera's recommendations while I was working on the classmap logic, I'm going to list some scenarios where classes or namespaces aren't properly detected that I haven't been able to fix in #4 yet here, or weren't relevant to that logic.

Class in string: $class = 'MyClass'; $obj = new $class();

It will also probably break when using relative namespaces:

namespace Vendor;
throw new Exception\MyException(); // FQCN: \Vendor\Exception\MyException

I'm not really sure how you can add cases like these without getting false positives as well, though. I don't think this can properly be handled by regexes, you should look into using nikic/PHP-Parser perhaps.

I want to get basic classmap support out the way and use this issue to list all cases where we know the logic fails and work on continually improving the replacement logic.

@Seldaek
Copy link

Seldaek commented Jun 25, 2017

Hey, have you considered re-using/contributing to https://github.com/humbug/php-scoper? Seems like you're solving the same kind of problem, at least on the surface, I haven't looked in details.

@coenjacobs
Copy link
Owner Author

Thanks @Seldaek, I've come across that repository, but unfortunately it's not all dependency conflicts with namespaces that we're trying to solve here. The WordPress ecosystem heavily relies on global classes still (mind you, it's still PHP 5.2 compatible...) and even though there are perfectly fine solutions available to enforce a minimum PHP version for your own plugins, I want to offer a solution that works for everything right now.

@Seldaek
Copy link

Seldaek commented Jun 27, 2017

Ok I see, just thought you should be aware of it but if it doesn't fit the bill that's fine :)

@coenjacobs
Copy link
Owner Author

I believe this is now properly addressed by #39. Will use the 0.6.0 beta 1 to test this and if needed, raise separate more specific issues.

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

2 participants