Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony coding standards - arguments and parameters

In the Symfony coding standards it says: >

Use camelCase, not underscores, for variable, function and method names, arguments;

Use underscores for option names and parameter names;

In this context, what is the difference between parameters and arguments?

I think I understand the option names part (i.e. when you have an $options array, like in the code example on that page) but what qualifies as a 'parameter'?

like image 909
caponica Avatar asked Nov 29 '25 12:11

caponica


1 Answers

I think that when array values are used as options (have the meaning of), in general.

For example in forms:

public function getDefaultOptions(array $options)
{
    return array(
        'validation_groups' => array('registration')
    );
}

In your bundle configuration:

class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('acme_hello');

        $rootNode
            ->children()
            ->scalarNode('my_type')->defaultValue('bar')->end()
            ->end();

        return $treeBuilder;
    }
}

In container parameters:

# app/config/config.yml
parameters:
    my_mailer.class:      Acme\HelloBundle\Mailer
    my_mailer.transport:  sendmail

services:
    my_mailer:
        class:        "%my_mailer.class%"
        arguments:    ["%my_mailer.transport%"]
like image 90
gremo Avatar answered Dec 01 '25 09:12

gremo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!