Skip to content
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

Avoid incompatibility between Generic and PSR2 standards for function call indentation #3631

Closed
wants to merge 1 commit into from

Conversation

fredden
Copy link
Contributor

@fredden fredden commented Jul 13, 2022

Generic.WhiteSpace.ScopeIndent and PSR2.Methods.FunctionCallSignature both try to fix indentation differently. This results in files not being able to be fixed automatically with phpcbf.

See #2078 (comment) where @gsherwood says that Generic.WhiteSpace.ScopeIndent should win in these cases.

This pull request fixes #2078 by eliminating the incompatibility when both sniffs are being run. When Generic.WhiteSpace.ScopeIndent is not active, then PSR2.Methods.FunctionCallSignature will continue to work as normal. When Generic.WhiteSpace.ScopeIndent is active, then this particular code-path will be ignored/skipped.

@fredden

This comment was marked as outdated.

@fredden fredden marked this pull request as draft July 13, 2022 15:58
@jrfnl
Copy link
Contributor

jrfnl commented Jul 13, 2022

  1. Do you have a code sample demonstrating the conflict ?
  2. Could that code sample be added to the test file ?
  3. As for referencing another sniff via a hard-coded name to avoid conflicts: that's generally not the way to solve these type of issues.

@fredden
Copy link
Contributor Author

fredden commented Jul 19, 2022

  1. Do you have a code sample demonstrating the conflict ?

Yes, see #2078 (comment).

  1. Could that code sample be added to the test file ?

I've been working on this, and it's difficult. I expect to update the pull request with this soon.

  1. As for referencing another sniff via a hard-coded name to avoid conflicts: that's generally not the way to solve these type of issues.

I agree. Can you suggest a viable alternative in this case?

@fredden

This comment was marked as outdated.

@fredden fredden marked this pull request as ready for review October 23, 2022 11:03
@fredden fredden marked this pull request as draft June 7, 2023 10:06
@fredden

This comment was marked as outdated.

@fredden fredden changed the title Avoid incompatible sniffs running together Avoid incompatibility between Generic and PSR2 standards for function call indentation Jul 11, 2023
@fredden fredden marked this pull request as ready for review July 11, 2023 16:28
@fredden fredden force-pushed the whitespace-incompatibility branch from 635cd00 to 33a4d33 Compare July 11, 2023 16:36
@fredden
Copy link
Contributor Author

fredden commented Jul 11, 2023

@jrfnl I've revisited this and written something completely different to the first attempt. I don't seem to be able to request your review via the GitHub web interface. Please can you take a look at this and let me know what you think.

I'm not particularly happy with the use of strpos() to detect the standard name. Do you have any suggestions for fixing this?
Edit: I've fixed this in 58512dc.

@fredden
Copy link
Contributor Author

fredden commented Dec 4, 2023

Superseded by PHPCSStandards/PHP_CodeSniffer#38

@fredden fredden closed this Dec 4, 2023
@fredden fredden deleted the whitespace-incompatibility branch December 4, 2023 16:20
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.

Incorrect indent for closures as method argument.
2 participants