laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.

Home Page:https://laravel.com/docs/pint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support .stub files

svenbw opened this issue · comments

Template files in a package can have a .stub extension. When publishing these files the become regular php files, and are picked up by pint. This means that the .stub files should have the proper format to "deliver" clean source files from the package to the main repository.

This is possible by allowing the name function call in the ConfigurationJsonRepository class by adding it to the finder options $finderOptions.
Or create a new option e.g. include-stubs (in my opinion more preferabele because one keeps the regular expression to match the stub files from the pint.json file).

@nunomaduro I have both options tested and working locally. I can create a PR if you prefer, but I think the solution should fit the philosophy of the configuration of pint.

How does this work with the stub variables in place? Won't that cause PHP-CS-Fixer issues?

@jbrooksuk I'm not sure how PHP-CS-Fixer would behave, therefore I opted for a configurable option that can be switched on if it makes sense for you own package (a good example is stub files for migrations).

The default behavior is as before, it's an explicit choice. If you have a mix of template stubs and plain it should be possible to enable the fixing for stubs, and exclude the template stubs using the existing exclude config option.

I'm not sure if this is worth it to be honest.
Files with the .stub extension don't necessarily have to be PHP files.
Also, James has a very good point about the stub variables.

To exclude not php files only .php.stub files must be taken into account.
Changes are rather small 7 lines of code, I can create a PR (if preferred), with backwards compatibility.

Thank you. Right now we don't have plans for this sorry.