Question about addons/standards/Vanilla
YES! I've managed to get it working with PHP CodeSniffer in SublimeText and also with NetBeans. It's really fun see your editor/IDE telling you that you haven't commented enough, or have forgotten to delete a space and all that!
But I'm unsure if I should use it. Something like discussionController_beforeSave_handler
looks too unfamiliar and I cannot imagine to use $discussionID
(or $discussionId
?)
What would you recommend: waiting for 2.3 where - if I understood it right - that should be standard or use it right now?
Best Answer
-
Linc Admin
We are waiting for the develop branch to get merged, and then we are going to do a mass-update to fix spacing (3 to 4). If you're starting a new plugin, I'd save yourself a headache and just start it in the new coding style. Legacy code I'd leave alone until we start lurching everything into the new standard.
6
Answers
We are waiting for the develop branch to get merged, and then we are going to do a mass-update to fix spacing (3 to 4). If you're starting a new plugin, I'd save yourself a headache and just start it in the new coding style. Legacy code I'd leave alone until we start lurching everything into the new standard.
@Linc So... which standard is being used in Vanilla? PSR1?
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
We call it "PSR-2 + the Lord Brackos rule" (same-line opening braces).
The exact coding standards spec can be found here: http://docs.vanillaforums.com/developers/contributing/coding-standard/
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
I presume the short echo is for PHP > 5.4 only...
grep is your friend.
@x00 Yeah, we just wanted to leave the option open for view files. That's not something we'd use anywhere else.
//edit: Also, we are jumping to 5.4 minimum for the next version, as we've said.
I like open Bracket on the same line too. I noticed some of the php code beautifiers have several options with spacing and brackets.
http://phpbeautifier.com
I do not like how any of these functions and they do not resemble what vanilla code looks like.
K&R style
Allman Style
Whitesmiths style
GNU style
Pear Style
What would Vanilla be compared to as far as these styles go ? Is this a preference or are these standard?
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
We use "K&R style" for logic, which is part of PSR-2, but for some reason that style and most others then go on to say functions/methods/classes all need their opening brace on a separate line.
So now we have "Lord Brackos style". WordPress, Drupal, Facebook, Laravel, Wikimedia, CakePHP and PHP.net all use this style, albeit without naming it.
This is a standard, as it's been referred to already and is specified extremely technically in Kasper's link above. This is not a change from the way Vanilla code has always looked - it's a codification of current practice.