Closed peter279k closed 3 years ago
Good idea, I think.
I've looked at at least one of them before, but it's been a while now since I'd last looked at any of the code style tools available, checked what was available, how well they worked and so on (maybe a year ago or thereabouts), and I don't quite remember anymore which ones I was looking at, whether it was PHP_CodeSniffer
, PHP-CS-Fixer
, or something else, but I remember there were a few minor problems with at least one of them, like enforcing the incorrect spacing (incorrect per PSR-2 guidelines) for concatenation operators, causing some readability problems when certain particularly long if/condition statements were meant to be split across multiple lines, that it would reformat them in strange ways, etc. Probably about time to take another look at them though, to see how they go.
Hi @Maikuolan, thanks for your reply and concern.
I think we can do following step to accomplish this issue.
And the rule creating I think we can try to define/customize.
I'm thinking of switching everything here over to GitHub Actions, dumping existing external tools/suites/etc. I should be able to finish that pretty soon, I think; either later today, or if not today, then over the weekend, maybe.
@peter279k Any preferences/recommendations/ideas about good GHA-based code-style tools? :-)
@Maikuolan, thanks for your reply. I don't know about the GHA-based
coding style tool.
And I usually install the PHP-CS-Fixer
and PHP_CodeSniffer
manually during GitHub Action.
And maybe we can consider using third-party action YAML setting about above coding style tools during GitHub Actions.
They're as follows:
What do you think about that?
Experimenting with them a little bit locally at the moment. I'll see whether that could work here. So far, looks good. :-) :+1:
@Maikuolan, if possible, could you create a coding style setting file?
For example, the .php_cs.dist
for PHP-CS-Fixer
or the phpcs.xml
for PHP_CodeSniffer
.
I don't create above coding style setting files because I don't know this coding style on this repository currently.
And it seems that this repository is not for a common coding style (Such as PSR-2 or PSR-12) coding styles.
if possible, could you create a coding style setting file?
I can do that. :-)
And it seems that this repository is not for a common coding style (Such as PSR-2 or PSR-12) coding styles.
I've mentioned PSR-2 in CONTRIBUTING.md, so there's that. Possibly, I may include PSR-12 in there at some point in the future too, but PSR-12 is still kind of new to me, and I should still probably think on that one a bit more, I think.
@Maikuolan, thanks for your reply and bring me to the CONTRIBUTING.md
.
It can be easy to use ./vendor/bin/phpcs --standard=PSR2 src/ tests/
command to do check for PHP_CodeSniffer
tool.
Or using the php php-cs-fixer.phar fix /path/to/project --rules=@PSR2
command to do check for `PHP-CS-Fixer`` tool.
Closed due to implemented.
As title, according to the CONTRIBUTING guide, we should consider adding coding style tool to check
PSR-2
coding style automatically.There're two popular coding style tool on PHP.
One is
PHP_CodeSniffer
and another one isPHP-CS-Fixer
.@Maikuolan, do you have any suggestion or idea about this :)?