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

Add support for PSR-4/composer dump-autoload testing #1088

Open
TravisCarden opened this issue May 17, 2023 · 3 comments
Open

Add support for PSR-4/composer dump-autoload testing #1088

TravisCarden opened this issue May 17, 2023 · 3 comments

Comments

@TravisCarden
Copy link
Contributor

TravisCarden commented May 17, 2023

Q A
Version v1.16.0
Bug? no
New feature? yes
Question? no
Documentation? yes
Related tickets n/a

I just discovered that composer validate will pass even if there are PSR-4 problems. That's not the fault of GrumPHP, but it may be misleading.

Steps to reproduce/Result:
Given a Composer project with PSR-4 configured and GrumPHP installed, just put a class file in the wrong directory and...

# `composer validate` reports nothing and returns a success status code.
$ validate; echo $?
./composer.json is valid
0

# `composer dumpautoload` reports the error and returns a failure code given the `--strict-psr` option.
$ composer dumpautoload --strict-psr 1> /dev/null; echo $? # (Silence stdout for clarity.)
Class Example\Good located in ./src/Bad.php does not comply with psr-4 autoloading standard. Skipping.
1

Proposal:
Either add a new task (or an option to the existing composer task), to use composer dumpautoload to check PSR-4 violations.

@veewee
Copy link
Contributor

veewee commented May 18, 2023

Hmm interesting.
The dump autoload changes files, which might not be the wanted scenario here.
Maybe it could make sense for composer to add this check to the validation command somehow?

@TravisCarden
Copy link
Contributor Author

^ I've proposed a dumpautoload --dry-run option. 🙂

@TravisCarden
Copy link
Contributor Author

Update: The above-proposed dumpautoload --dry-run option has been committed upstream and is scheduled for release in Composer 2.6.

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

No branches or pull requests

2 participants