Seen in core:
<?php if ($left): ?>
<?php if ($source_url) : ?>
The first form, without the space after the closing ), is far more common, and is also seen at http://php.net/manual/en/control-structures.alternative-syntax.php
(Is this right component, btw? Can't find anything else that looks likely.)
Comments
Comment #1
jhodgdonWe usually discuss coding standards in the Drupal Core issue queue, I think.
Comment #2
sunThe colon should directly follow the closing parenthesis.
In general, Drupal does not use nor follow the white-space-everywhere-for-visual-clarity that can be seen in a minority of projects, such as Joomla.
In this case, the lonely separated colon could be easily misunderstood as a colon belonging to a ternary operator.
Comment #3
xjmSo we need to hunt down all the places in our templates where this happens. A grep for
') :'
in template files would be a good start. Tagging.Comment #4
xjmComment #5
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedHere is a patch against 8.x, but it seams to apply cleanly for 7.x too.
I also found that usually elements are indented between if and endif.
Comment #7
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedIeek, what's that? The patch came out of git-format-patch, git version 1.7.4.4.
Let's see if git diff works.
Comment #9
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedNext random try. Maybe no a/ b/ prefixes anymore?
Comment #11
xjmHi Niklas,
Maybe try rolling the patch with
git diff origin/8.x
rather thangit format-patch
? Maybe it is failing on the php example in your commit message or something.Comment #12
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedI thought that too, so I next (http://drupal.org/node/999040#comment-4957014 ) tried a git diff that has no commit message.
Edit: I just asked what to do in #drupal-gitsupport.
Comment #13
jhodgdonThe patch in #7 looks like the right formatting. Maybe you can try making a clean git repository for Drupal 8 and seeing if that patch will apply with:
patch -p1 < (filename)
from the Drupal root.
Looking at the error log (choose View Details next to the patch file line in #7), it looks like the patch failed to apply here:
Output: [error: modules/profile/profile-block.tpl.php: No such file or directory
error: modules/profile/profile-listing.tpl.php: No such file or directory].
So maybe these have been removed from Drupal 8? Did you patch against an up-to-date Drupal 8 git repository?
Comment #14
xjmYeah you need to do a
git pull
. Profile has been removed so no need to patch it. :)Comment #15
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedOk, thank you all. The repo was up to date, but it looks like I accedantely commited profile to 8.x some time ago ;)
Wow ... it says
but I didn't think it would say that for all failing patches. I would have never figured that out.
Rerolled patch attached.
Comment #16
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedComment #17
jhodgdonThat text about it maybe being a -p0 patch is just something the test bot always says when it fails to apply a patch. Always look at "view details" to see what actually happened. :)
Anyway, I've reviewed this patch, and if the testbot is happy this time, I think it's good to go for 8.x. We will need a different patch for 7.x, since it has the Profile module still.
Setting to RTBC, pending test bot results.
Comment #18
Niklas Fiekas CreditAttribution: Niklas Fiekas commentedHere is a D7 patch. Not sure if you should do anything with the issue tags, but I guess I shouldn't set it to 7.x-dev and needs review for the testbots until this is in 8.x.
Comment #19
jhodgdonCorrect. After this is committed to 8.x, we will probably need to re-upload the patch too, because the test bot ignores patches with -d7 suffixes on the name.
Comment #20
Dries CreditAttribution: Dries commentedCommitted to 7.x and 8.x. Thanks.
Comment #22
jhodgdonNote follow-up issue to update the coding standards doc:
#1492646: Coding Standard: Document standard for control structures within template files