Skip to content

Manually exclude Blade files from calls to PHPCS#199

Merged
tonysm merged 3 commits into
3.xfrom
mes/exclude-blade-phpcs
Mar 27, 2026
Merged

Manually exclude Blade files from calls to PHPCS#199
tonysm merged 3 commits into
3.xfrom
mes/exclude-blade-phpcs

Conversation

@mattstauffer
Copy link
Copy Markdown
Member

Fixes #198

Issue introduced because of changes to how PHPCS handles the situation of all files being excluded (in PHPCS 3 it was silent, in PHPCS 4 it throws a DeepExitException).

This PR exits before calling PHPCS if the paths provided, once Blade files are filtered out, are empty.

mattstauffer and others added 3 commits March 20, 2026 12:29
…o PHPCS

The --dirty option will pass individual files, and since Blade files are
filtered out, PHPCS v4 would fail with no file. We're essentially
returning early with a success exit code in that case.
Copy link
Copy Markdown
Contributor

@tonysm tonysm left a comment

Choose a reason for hiding this comment

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

Looks good to me! We're essentially handling the case where individual files are passed via the --dirty flag, right? Since PHPCS would filter out Blade files, if all the changed files are Blade files, that would result in an empty path list, and V4 would fail when we run on empty paths... if I got it right.

@mattstauffer
Copy link
Copy Markdown
Member Author

mattstauffer commented Mar 20, 2026

@tonysm in the origina lissue, they were passing duster lint resources/views/filename.blade.php to trigger the error. This definitely fixes that. But yah, I believe the actual case is that --dirty is the most likely circumstance that would get us here.

I can't actually figure out how to trigger the original issue using --dirty tbh. If I change just a view, and run lint --dirty, I get No dirty files found.

If i change a view and a PHP file, I get the linting on the PHP file, but it skips the view with no errors.

So the only way I could trigger the error they were dealing with was by specifically passing blade files/folders.

./vendor/bin/duster lint resources/views
# or
./vendor/bin/duster lint resources/views/filename.blade.php

@mattstauffer
Copy link
Copy Markdown
Member Author

I suspect this might also fix #200 but haven't heard back from OP. I can't figure out a scenario in which those issues are being triggered, but if you're ok with it @tonysm I'm inclined for us to just release it and see.

@mattstauffer mattstauffer marked this pull request as ready for review March 26, 2026 19:04
@tonysm
Copy link
Copy Markdown
Contributor

tonysm commented Mar 27, 2026

@mattstauffer let's give it a shot. Merging it.

@tonysm tonysm merged commit 5570f81 into 3.x Mar 27, 2026
8 checks passed
@tonysm tonysm deleted the mes/exclude-blade-phpcs branch March 27, 2026 00:41
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.

Running duster lint on the views results in failed exit code

2 participants