phpspec / prophecy

Highly opinionated mocking framework for PHP 5.3+
MIT License
8.53k stars 241 forks source link

Introduce PHP-CS-Fixer #613

Closed Wirone closed 1 month ago

Wirone commented 10 months ago

I did not apply suggested changes because I want to get feedback if you like these changes or not. We can tweak configuration in order to keep more of current conventions (like class instantiation without parentheses).

stof commented 10 months ago

This breaks testing on PHP 7.2 because of incompatible dependencies. This cannot be accepted as is.

Also, it would be great to start with a php-cs-fixer that is a bit closer to our existing setup. For instance, I'm quite sure that the current codebase is mostly using concatenation without spaces (i.e. the @Symfony rule for them), and not having the explicit visibility in phpspec specs is following the official phpspec examples. This would make it easier to review the changes (we can have a dedicated migration after that if we decide to change the coding standards).

Wirone commented 10 months ago

Yeah, I'll try to figure out how to do it properly, keeping support for PHP 7.2+ 👍.

Wirone commented 10 months ago

@stof in terms of Fixer configuration, there are rules that cause diff regardless of the config, because the codebase is not consistent:

So basically each option have tradeoff and it needs to be decided what to do with each. I've now configured Fixer to use options that causes as little changes as possible (66 files changed instead of 118 as before). Let's see if it's acceptable 🙂.

Wirone commented 10 months ago

I was thinking about adding --no-scripts many times today and in the end I forgot 😆.

Wirone commented 10 months ago

@stof it should be OK now (not counting CS) 🙂. Waiting for workflow approval is a frustrating experience for first-time contributors 😅.

stof commented 10 months ago

@Wirone I understand that and I generally change that setting to require it only for new github accounts instead of the github default value. But I don't have admin rights on the repo /cc @ciaranmcnulty

Wirone commented 10 months ago

FYI: PHPStan errors are fixed in #612, so maybe we should finish that one first.

Wirone commented 10 months ago

@stof rebased and conflicts resolved, ready for review and deciding about the Fixer's ruleset 🙂.

Wirone commented 10 months ago

@stof I can't reach @ciaranmcnulty (no response for my messages), do you have enough power here so we can agree on final ruleset and just apply fixes, or we need to wait for Ciaran's decision? I would like to continue to contribute, but having sane QA automation 😉.

Wirone commented 9 months ago

@stof @ciaranmcnulty friendly reminder 😉.

ciaranmcnulty commented 6 months ago

@stof You now have repo admin rights

ciaranmcnulty commented 6 months ago

@Wirone can you add a commit accepting the changes so we can see if there's anything crazy, easily?

Wirone commented 6 months ago

@ciaranmcnulty Of course, here are the applied fixes 🙂.

Wirone commented 1 month ago

@stof I've rebased the branch, re-applied coding standards for new code (amended previous commit), and added simple change to the Fixer config (disabled trailing_comma_in_multiline as it tries to apply changes not compatible with PHP 7.x (info in the last commit).

stof commented 1 month ago

Instead of disabling trailing_comma_in_multiline entirely, you should keep the rule enabled by only for array.

Wirone commented 1 month ago

@stof I wanted to do it initially, but as I wrote in the commit's message, it's against current coding standard in the project. But sure, I can do it if you want - it will add 15 commas across the code base. Do you want me to do it?

stof commented 1 month ago

@Wirone I'm quite sure the current state of the code is a mixed state (due to not having tooling enforcing it) rather than a consistent state of not using trailing comma in multiline array.