Coding standards proposals for final discussion on 7/12

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
tizzo's picture

The TWG coding standards committee is announcing two coding standards changes for final discussion. These appear to have reached a point close enough to consensus for final completion. The new process for proposing and ratifying changes is documented on the coding standards project page.

New issues for discussion:

Updates on existing issues:

These proposals will be re-evaluated during the next coding standards meeting currently scheduled for July 12. At that point the discussion will likely be extended, or if clear consensus has been reached one or more policies may be dismissed or ratified and moved to the next step in the process.

Comments

Hm, some items on this list

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!

The process for proposing

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.

Result type hinting

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 ?

PHP Standards Recommendations

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.

change spaces to tabs

yurii_2016's picture

change spaces to tabs

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

The process for proposing

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.

Less prescription

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!

The reason we should care

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.

remove dot at the comment end

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

The process for proposing

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.

Core

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week