HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Question about addons/standards/Vanilla

R_JR_J Ex-FanboyMunich Admin

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

Answers

  • hgtonighthgtonight ∞ · New Moderator

    @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.

  • LincLinc Detroit Admin
    edited July 2014

    We call it "PSR-2 + the Lord Brackos rule" (same-line opening braces).

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    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

  • Files MUST use only <?php and <?= tags.

    I presume the short echo is for PHP > 5.4 only...

    grep is your friend.

  • LincLinc Detroit Admin
    edited July 2014

    @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.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    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?

  • LincLinc Detroit Admin
    edited July 2014

    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.

Sign In or Register to comment.