coding-standards icon indicating copy to clipboard operation
coding-standards copied to clipboard

Formatting inline array and closures

Open eddieajau opened this issue 11 years ago • 3 comments

There are a few formats that seem to be gaining popularity. See the following examples:

// Inline array.
$foo = bar($arg1, array(
    'one',
    'two',
    'three',
), $arg3);

// Inline closure.
$container->share('database', function(Container $c) {
    // Return a database driver.
}, true);

How do people feel about those cases?

eddieajau avatar Sep 01 '13 02:09 eddieajau

Yes, that's actually a clarification point on an upcoming PSR-2 Errata doc 

Sent from Mailbox for iPhone

On Sat, Aug 31, 2013 at 9:33 PM, Andrew Eddie [email protected] wrote:

There are a few formats that seem to be gaining popularity. See the following examples:

// Inline array.
$foo = bar($arg1, array(
    'one',
    'two',
    'three',
), $arg3);
// Inline closure.
$container->share('database', function(Container $c) {
    // Return a database driver.
}, true);

How do people feel about those cases?

Reply to this email directly or view it on GitHub: https://github.com/joomla/coding-standards/issues/30

dongilbert avatar Sep 01 '13 03:09 dongilbert

I prefer these over

$foo = bar(
    $arg1,
    array(
        'one',
        'two',
        'three',
    ),
    $arg3
);

piotr-cz avatar Sep 03 '13 11:09 piotr-cz

:+1:

okonomiyaki3000 avatar Mar 11 '15 02:03 okonomiyaki3000