Coding standards proposals for final discussion on 7/12

klausi's picture

Hm, some items on this list appear twice, can you delete the outdated lines? (camelCase issue, PHP 5.4. array issue)

Jons's picture

I'm sure this has been argued over but I just think the format:

if (condition1 || condition2) {
action1;
}
elseif (...)

does not scan well to me, and is contrary to years of use in C, Java, PHP of
} elseif () { style

Also seems a waste of good screen real-estate!

tizzo's picture

The process for proposing coding standards standards changes is documented on the coding standards project page. As per that description, please create an issue there and build support if you have suggestions for changes.

fgm's picture

I added a note about result type hinting on the param type hinting because it is pretty much the same issue. Can't we have it mentioned for code requiring PHP7, just like for scalar param hints ?

greg.1.anderson's picture

This should be obvious enough, but on any issue addressed by PSR-1 or PSR-2, the Drupal conventions should either:

a) Stay as they are
or
b) Adopt the PSR standards (preferred)

For example, the indentation change recommended above for else / elseif is in alignment with PSR-2, and therefore should be adopted.

yurii_2016's picture

change spaces to tabs

in what age are we now? in stone or iron?

tizzo's picture

The process for proposing coding standards standards changes is documented on the coding standards project page. As per that description, please create an issue there and build support if you have suggestions for changes.

Jons's picture

The more picky we are the less people are likely to contribute to Open Source.
Why are we even discussing use of '!=' or '<>' !!

For one thing it means we're focussing on the wrong things, which machines (our compilers) don't care about, so why should we? The general drive of IT is to make machines work the way we like - i.e. make them even more flexible to accommodate different human (creative) approaches, so we don’t want to work in the opposite direction.

The only real need for code standards is in the area or source code control - where we want to see just the changes. So the perspective must be to respect the layout of the author (as we do with written language) within some simple guidelines, rather than insist it's all converted into our way of doing things, in minute detail, before we accept it.

So!

tizzo's picture

The reason we should care about coding standards is that we want humans to be able to effectively parse the code. When we share a set of standards the consistency makes the code easier to read at a glance than when it is varied.

The general Drupal approach has been to push in the direction of consistency to the point where it's as if all Drupal code were written by one hand.

yurii_2016's picture

really, remove this stuff, it is useless and doesn't make sense, it doesnt add and meaning etc

the best way is, you don't force me to add that dot. i want to be able decide - do i need that dot or not

tizzo's picture

The process for proposing coding standards standards changes is documented on the coding standards project page. As per that description, please create an issue there and build support if you have suggestions for changes.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web