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
Support strict (no ambiguous classes) mode for generating optimised autoloader #6221
Comments
I am not opposed to this, I am just not sure if it should be |
Yeah I wondered about |
That's because |
That's true, though arguably fair enough given the misleading "error stream" naming. But as an outsider when I looked at a php method called Very happy to look at suggestions for how I could implement a robust and future-proof generic --strict flag. Possibly still at the IO level but based on the |
Unfortunately I do not think it will be quite that simple. Cannot think of a proper solution of the top of my head either though. |
Just to confirm that definitely won't work - I just noticed abandoned packages are displayed as warnings with equal severity/formatting to ambiguous classes. It looks to me like adding a generic What other warnings does composer issue during install that might actually have an impact on (and particularly, platform-specific impact) production behaviour? I'm not really aware of anything else that it would be important for |
I also don't think it's worth having a --strict, given that the scope might change over time, it's best to have specific flags. Perhaps |
|
Just stumbled into this need... is this feature on hold? |
Development of nice-to-have features is very much up to opensource contributions. Feel free to submit a PR. |
It's somewhat related to #7421 |
I toyed with adding this config option yesterday, but couldn't see a direct way to access the setting at the two points where the |
|
I don't think so, this is about ambiguous classes (class names present more than once), not PSR validity. |
I'd love a
composer install --optimize-autoloader --prevent-ambiguous
(or similar named) option to make the install fail (rather than just print a warning) if it finds ambiguous class definitions.The resolution of ambiguous class names is platform-dependent (the order composer finds the files varies between filesystems) which can lead to composer autoloading a totally different implementation of a class between development / build / production instances. Similarly classes contained in files that don't match the PSR-0/4 definition won't cause issues locally but may be found and used when the classmap is generated. For example this can happen if working / backup files are accidentally committed, or if a (badly-configured) dependency with a loose psr-0 definition comes with test / example files.
It can be very hard to debug and trace the problems this causes. They can arise at any time (even if the composer dependencies don't actually change), so a developer might not always notice them. Often the "Ambiguous class resolution" warnings will only arise within a remote build / deployment process and not be noticed - particularly if the composer command output doesn't appear in deployment logs.
So I'd like to be able to opt-in to have composer fail with an error if ambiguous classes are found, to force the end-user to fix that rather than hope the resolution is always going to be correct now and in future.
I'm happy to work on a PR if you agree this is a good idea?
The text was updated successfully, but these errors were encountered: