Option arrays versus settes in CakePHP

How does everyone feel about the use of option arrays in CakePHP? I personally prefer using OOP for setting options. In particular I can rely on my IDE to provide documentation as I code rather than having to search through documentation or vendor source code.

Here is an example of what I am talking about:

$service->loadAuthenticator('Authentication.Token', [
    'queryParam' => 'token',
    'header' => 'Authorization',
    'tokenPrefix' => 'Token'
]);

versus

$service->loadAuthenticator(
    (new AuthenicationToken())
        ->setQueryParam('token')
        ->setHeader('Authorization')
        ->setTokenPrefix('Token');
);

Same, i do convert all the baked models to use chained relations setters

2 Likes

I usually make mistakes with the first option, so in my very personal opinion, I like a lot more the second one.

1 Like

I prefer the OOP for its structure, but most of my code uses array as I find it faster and easier (with the thought that the keys do not change).

Sounds greedy, but I would like to have both.

$this->Users->find('all', [...]);
$this->Users->find()->where([...])...
1 Like