-
Feature requestIs there any way I can opt out of fixing my method declaration indents? I know this was a recent addition, but I really like to indent my methods that are extracted for the sake of readability under the method they are extracted from. I find that really useful (it was suggested by Robert C. Martin in his series "Clean Code"). Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @BladeMF, are you referring to #6978? If so, then this was a bug fix, because method indentation is a part of every PHP coding standard (PSR, PER) and it was not working as it should for some cases. There's no opt-out only for methods, you would need to disable Can you please link to some references regarding to this approach or share code snippet that shows how you organise your code? I am curious, because personally I can't think find about mixed indentation of methods as a readability improvement 🙂. |
Beta Was this translation helpful? Give feedback.
-
Hi @Wirone , I am really sorry I missed your message somehow. I took a look at the PR and it could be the reason, yes, but I cannot be certain. What I am doing with my code is as follows: <?php
class MyClass
{
public function myPublicMethod(): void
{
$this->implementationPart1();
$this->implementationPart2();
$this->implementationPart3();
}
private function implementationPart1(): void
{
$this->implementationPart11();
$this->implementationPart12();
}
private function implementationPart11(): void
{
// some code
}
private function implementationPart12(): void
{
// some code
}
private function implementationPart2(): void
{
// some code
}
private function implementationPart3(): void
{
// some code
}
} This way, if I have indent-based folding in VS Code I can look at the structure of the code when I collapse everything. The only methods that are not indented are the public methods. Every other method is there because it serves some public method. It doesn't matter if a private method is called in just one place. It's purpose is to a) define what that piece of code does (using its name) and b) define what parts constitute that task. I am happy to discuss further. |
Beta Was this translation helpful? Give feedback.
Your rule can't prevent other rules from applying their logic, instead it should apply its own logic. The priorities matters, your rule should be executed after
statement_indentation
so it can make indentation as you expect it to be. You can also disablestatement_indentation
completely and register custom fixer in its place.