Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 down vote accepted

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

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


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.