Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
coding standards and closures
  • I'm looking to adhere to the coding standards for any package development i'm working on, but I personally find it more intuitive to keep the opening brace on the same line as the function statement:
    $anonymous['function'] = function($e) {
       return "something here";
    };
    
    rather than
    $anonymous['function'] = function($e)
    {
        return "something here";
    }
    

    I didn't see anything in the docs regarding specifically regarding closures...i personally think the opening brace on a separate line makes more sense for method declarations, and keeping the brace on the same line is good to distinguish it as an anonymous function. It looks like in the few places they are used in the core, the opening brace on the same line as well. I know it's a very (very) minor thing but I've been making decent use of them in various packages i'm developing and it would be good to get in the habit/set a precedent in the docs either way.... Thanks.
  • @WanWizard then the core should probably reflect that, the only closure uses i see are without a new line fuel/core/classes/view.php - line 234
    fuel/core/classes/form.php - line 485
    fuel/core/classes/fieldset/field.php - line 291 also any uses inside something like an array_walk or array_filter fuel/core/classes/uri.php - line 129
    fuel/core/classes/upload.php - lines 164 and 187
    fuel/core/classes/agent.php - line 749 don't have the brace on new lines either...
  • Absolutely right. Which is now corrected.
  • The standard is to have the opening brace on a new line. Everywhere. Afaik there are no exceptions.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion