Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Loyen
Copy link

@Loyen Loyen commented Nov 29, 2025

I noticed that composer install do not support --strict-psr, meaning that if you want to make use of it you would have to run install followed by dump-autoload with --strict-psr.

Since both commands support the optimize autoloader option (composer install --optimise-autoloader or composer dump-autoload --optimise) it feels reasonable that both also support --strict-psr.

Similarly to dump-autoload, have the option to fail if any PSR
violations are found.
@Loyen
Copy link
Author

Loyen commented Dec 3, 2025

I had a look regarding tests for this, they would look pretty similar to what currently exists for dump-autoload so I have not included any here for it yet as I am unsure if this is something that is wanted.

At least when it comes to failures as DumpAutoloadCommandTest::testFailsUsingStrictPsrIfClassMapViolationsAreFound() is pretty much the same with a different command.

Looking at the DumpAutoloadCommandTest ::testUsingOptimizeAndStrictPsr() we wouldn't be able to assert by the same things as composer install --optimize-autoloader do not output how many classes were part of the optimized autoload files. Perhaps that is fine to leave out as an assertion though and I should add these two tests to InstallCommandTest as well.

This can definitely be adjusted so that they are both expected to output similar results if we want that.

Copy link
Contributor

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is added in install, it should probably also be added in update for consistency.

@Loyen Loyen changed the title Add --strict-psr option to install command Add --strict-psr-autoloader option to install/update commands Dec 3, 2025
@Seldaek Seldaek added this to the 2.10 milestone Dec 8, 2025
@Seldaek
Copy link
Member

Seldaek commented Dec 8, 2025

Seems reasonable to me, and I'd concur in saying tests are not needed, it'll just not test much of value.

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

Successfully merging this pull request may close these issues.

3 participants