How static PHP analyzer changed the way I look at code
Let me introduce you to the world of static PHP code analyzers. I'd like to show you which tools exists, how to use them and how they help you to improve your code quality.
Too many return statements Return early but only once Prevent superfluous return variables Prevent superfluous else branch Too many return type possibilities Stick to one return type
understand Each control structure increases the complexity Logical operators increase the count Ternary and null coalescing operator increase the count Merge nested if statements Refactor and use helper functions
in naming variables and methods I refractor conditions to own functions I prevent multiple return points I use exactly one return type I started to think about my code before I write it Benefits My classes and concepts are more structured My code is more readable My code is better testable