Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm trying use the PSR conventions in all my projects, but today I view some code of my co-worker and I disagree.

if ($cond == 1 AND $cond == 2) {
    // to-do
}

For me, the correct is:

if (($cond == 1) AND ($cond == 2)) {
    // to-do
}

What is the correct use of the PSR?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Per the PHP Framework Interop Group's PSR definitions, this particular case is not addressed:

http://www.php-fig.org/psr/2/

I don't see any guidance on the usage of logical operators as "words", i.e. "and", "or", "not", etc versus symbols, i.e. "&&", "||", "!" within boolean expressions.

If I were to follow precedence and make my own extension of the above PSR reference, I could only conclude that the word "AND" should be written as "and" given the preference for lower case when using reserved words...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.