-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
method_chaining_indentation
rule doesn't apply correctly the first time when combined with no_space_around_double_colon
#234
Comments
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
It seems like it is something linked with the I tried the same test with this
And the behavior is as expected.
|
Hi all, we'd appreciate a PR here. If nothing can be done then this is something that should go into the docs. |
@driesvints I'll look into it. |
I'm afraid I don't know enough about the internals of Pint to be very helpful here. Apart from the One naive approach here might be to compare the rules of the Rules
|
I copy pasted all the rules from laravel preset and added them in my
|
Can repro what you pasted successfully. I tried comparing
This should be functionally the same as the |
Triple-checked my last comment. Here's my work:
Two things to potentially try next:
|
Manually building a combined file that should be equivalent to your previous comment that formatted everything correctly still yields the original problematic results. I'm missing something...
|
Adding Unless I messed up manually merging the |
I had a doubt regarding the sequence of the two specific rules, the order in which The issue should come from the rule order in the Laravel preset, where they are arranged alphabetically. However, when I tried with a modified @driesvints What's next ? A Pull Request with one rule not in the correct alphabetical order ? Or a Pull Request to add priority in the rules in PHP_CS_FIXER ? |
Interesting. So you're saying setting a base preset of That said — all of PHP CS Fixer's rules are listed alphabetically, suggesting that they intended them to all work together and might instead be their issue? |
@shengslogar I believe that if PHP-CS-FIXER included a preset with both rules, they might face a similar issue to what we've encountered. However, it appears that |
@mho22 Agreed. Will wait to hear Dries' opinion on whether he'd like this resolved here or there. Thanks for spearheading a resolution! 🙏 |
@shengslogar The issue you described appears to be related to PHPCSFixer. To confirm, try reproducing the issue using PHPCSFixer alone. If you succeed in reproducing the issue, please report it to the PHPCSFixer repository; if not, feel free to re-open this issue. |
@shengslogar I tried to reproduce the issue using PHPCSFixer alone and it succeeded reproducing it. The files here to reproduce it quickly :
run |
@mho22 Appreciate you taking the time to make a repro! You seem to have a much better handle on this than I do. Would you mind opening a ticket in the PHP CS Fixer repo or would you rather I do? This is the only issue I spotted that looks similar, but was closed due to being reported for an older version. Thanks for all your help on this! |
@shengslogar Ok, I will open a ticket and tag you on it when I have time later today or tomorrow. |
@mho22 🙏 |
@shengslogar @nunomaduro The pull request #7723 addressing this issue has been merged into the PHP CS Fixer master branch. Now awaiting the next release. 👍 |
@shengslogar It is now released ! |
Yes the next release will have the new versions defined in |
Pint Version
1.13.6
PHP Version
8.2.12
Description
Running into an interesting corner case where Pint incorrectly formats a file and subsequently passes future Pint
--test
checks in the same environment.The two rules at play here, per Pint, are
method_chaining_indentation
andno_space_around_double_colon
.Without looking under the hood of Pint, seems like it might be caching results, as renaming the affected file and running Pint again corrects the formatting issue.
Steps To Reproduce
1. Create
Test.php
:2. Run
./vendor/bin/pint
:(Note the 186 other files are part of an existing project where this issue surfaced.)
3. Inspect the contents of
Test.php
:Note the
$formattedIncorrectly
block has extra spacing behind->where
and->firstOrFail
.4.
./vendor/bin/pint --test -vvv
doesn't pick up on any issues:5. Rename
Test.php
toAnotherTest.php
Issues are now detected by
./vendor/bin/pint --test -vvv
, and running./vendor/bin/pint
formats the file as expected.The final corrected file looks like:
The text was updated successfully, but these errors were encountered: