Skip to content
This repository has been archived by the owner on Jul 3, 2018. It is now read-only.

Add braces to conditional statements? #2

Open
JacobOlitsky opened this issue Apr 7, 2014 · 0 comments
Open

Add braces to conditional statements? #2

JacobOlitsky opened this issue Apr 7, 2014 · 0 comments

Comments

@JacobOlitsky
Copy link

This is a very minor, mostly stylistic issue, but using braces for all conditional statements- even if they only contain one statement- is in my opinion more consistent and readable. It is not necessary to use braces in PHP, but many style guides call for it, and some IDEs consider not using braces an error (e.g. NetBeans). It's also a bit easier to debug, as the code blocks are clearly delimited.

What I mean is replace

if (foo == true)
    do_something();
else
    do_something_else();

with

if (foo == true) {
    do_something();
} else {
    do_something_else();
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant