Skip to content

Add Linter command.#320

Merged
markstory merged 6 commits into6.xfrom
6.x-linter
Jun 19, 2025
Merged

Add Linter command.#320
markstory merged 6 commits into6.xfrom
6.x-linter

Conversation

@dereuromark
Copy link
Copy Markdown
Member

@dereuromark dereuromark commented Jun 18, 2025

When working with upgrading, and partially rector, regex or manual, files can easily break and you commit broken stuff.

Running a quick linter can help here, normal php -l doesnt work recursively, so this here aims to provide quick support:

$ bin/cake linter
Checking directory: src/
==========================================================================> 100%
Checking directory: config/
==========================================================================> 100%
Not exists: templates/ - skipping.
Checking directory: tests/
==========================================================================> 100%
All files are valid.

Had to copy the progress helper as the dependency is to only subsplit repo.

Co-authored-by: ADmad <ADmad@users.noreply.github.com>
@ADmad
Copy link
Copy Markdown
Member

ADmad commented Jun 18, 2025

Does rector report back the files that it has actually modified? If so I would auto run the linter for the modified files, thereby avoid having to run it for all files within a folder.

@dereuromark
Copy link
Copy Markdown
Member Author

This linter is separate from the rector, since rector isnt so much the issue as other regex based changes done, or IDE based replace.

This could be an additional thing for rector runs on top, but IMO a separate topic.

And yes, I think we could in general extract the files changed in rector output

1) ../../app/src/Controller/UsersController.php:8210

With --per-file this would be easier as we directly know the files that we touch.

@LordSimal
Copy link
Copy Markdown
Contributor

Does rector report back the files that it has actually modified? If so I would auto run the linter for the modified files, thereby avoid having to run it for all files within a folder.

its not also about rector creating broken files but rector will also break, if you pass it broken files.
So its good to execute this command BEFORE doing the rector to make sure everything can be parsed into an AST by rector.

@ADmad
Copy link
Copy Markdown
Member

ADmad commented Jun 18, 2025

Having this as a separate command command is totally fine. I just think that having it auto-run for modified files (by rector or regex) would save time, instead of having to run it again for a full directory/app.

@dereuromark
Copy link
Copy Markdown
Member Author

I like the additional idea of --lint on the rector command to have a (pre and) post run of it, especially before storing it.

@ADmad
Copy link
Copy Markdown
Member

ADmad commented Jun 18, 2025

Wouldn't using/wrapping something like https://github.com/php-parallel-lint/PHP-Parallel-Lint make more sense than having our own implementation?

@dereuromark
Copy link
Copy Markdown
Member Author

I am fine with a dependency, just thought maybe having an easy tool suffices here.

@markstory markstory merged commit 7869d4c into 6.x Jun 19, 2025
3 checks passed
@markstory markstory deleted the 6.x-linter branch June 19, 2025 18:56
LordSimal pushed a commit that referenced this pull request Jan 6, 2026
* Add Linter command.
* Add Linter command.
* Add test case.
* Refactor to symfony command.
* Update src/Command/LinterCommand.php

Co-authored-by: ADmad <ADmad@users.noreply.github.com>

* add false test.

---------

Co-authored-by: ADmad <ADmad@users.noreply.github.com>
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.

4 participants