$foo = (string)$foo;

vs.

$foo = (string) $foo;

By my grep calculations, the former wins, 104:71.

Should we call it a standard and roll a patch to fix, or does someone want to make the case for the space? I couldn't find anything in the PEAR docs about this.

Comments

damien tournoud’s picture

I generally try to not argue too much about the color of the bike shed, but I really prefer the latter.

catch’s picture

I prefer it with a space too.

mecano’s picture

I second that

sun’s picture

Status: Active » Postponed

Let's discuss over at: http://groups.drupal.org/node/16598, not here.

jhodgdon’s picture

Component: documentation » other
Status: Postponed » Active

It looks like the discussion ended long ago, and casts should have a space between the (type) and the $variable.

I just added that to the coding standards page.

So it looks like the next step would be to make a patch.

aspilicious’s picture

StatusFileSize
new45.25 KB

Here is a patch.

I grepped with

\(.+\)\(.*\$.*\)

and

\(.+\)\$.+

aspilicious’s picture

Status: Active » Needs review
sun’s picture

Status: Needs review » Reviewed & tested by the community
beeradb’s picture

I'm late to the party, but I fully endorse having the space. Drupal tends to respect/like a lot of whitespace anyway, so it just makes sense.

beeradb’s picture

#6: casting_var.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, casting_var.patch, failed testing.

aspilicious’s picture

StatusFileSize
new45.17 KB

Let's get this in before I have to reroll again :(

RTBC by #8

aspilicious’s picture

Status: Needs work » Reviewed & tested by the community
dries’s picture

Personally, I like it better without the extra space.

sun’s picture

hah, I just learned that I was somehow opposed to the space some time ago. In the meantime, I love it. ;)

It's not only consistent with other Drupal coding standards, but also consistent with example code in PHP's documentation, as Morbus correctly states.

The grep statistics in the OD of this issue should have changed in the meantime, as we apply this standard to new and changed code for quite some time already.

jhodgdon’s picture

I agree with sun [for a change :) ].

realityloop’s picture

#12: casting_var_V2.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, casting_var_V2.patch, failed testing.

aspilicious’s picture

StatusFileSize
new44.93 KB

Reroll

aspilicious’s picture

Status: Needs work » Needs review

If this is green, please commit :( ...
I'll make followups if necessary...

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

This was RTBC before the reroll, setting back to that.

dries’s picture

Status: Reviewed & tested by the community » Needs work

Patch no longer applies. Needs to be re-rolled.

aspilicious’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new44.48 KB

Hopefully last reroll

webchick’s picture

Priority: Normal » Minor
Status: Reviewed & tested by the community » Fixed

From #22 sounds like Dries was in favour of this. Plus I'm tired, so I need something easy to commit. ;)

Committed to HEAD. Thanks!

Looks like this is already in the coding standards http://drupal.org/coding-standards#cast so we should be good to go here.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.