Original (closed) core issue 31122
This is a generic question I want to address.
What is the correct respectively preferred way in writing arrays in config.sample.php Based on this result, I would like to harmonize all arrays in config.sample.php to the same layout and file a documentation PR in the development guide with the definition made.
The documentation gives no statement about this and from phpcs I cant read it out.
I am clearly focussing on config.sample.php not in how arrays should be written in the code. As you see in the examples of this file, we have many variants of valid php array styles present. My attempt is finding / define a preferred way, harmonize the array in the file to this definition and document the way how an array should be used for this file in the developer guide.
The freedom of beeing able to use all array styles available in php in config.sample.php - even all work - doesn´t not look good nor looks professional but confusing. I am absolutely convinced that a guideline and its usage/expression in config.sample.php is necessary and a good thing.
I am fine with any definition made, but there has to be one.
I would like have a statement for:
- single array:
[ ]
vsarray ( )
- array in array
- do we need to write array keys
0 =>
vs'list of items'
- are there php version dependencies (just to be sure)
Currently we have following variants present:
- Square bracket
=> [ ]
- The term array with round brackets
array (
'demo.example.org',
'otherdomain.example.org',
),
- The term array in term array with round brackets, sub array key is defined
=> array(
array(
'class' => 'OC_User_IMAP',
'arguments' => array('{imap.gmail.com:993/imap/ssl}INBOX')
)
- Array in array with square brackets, sub key is defined, sub array value is in square brackets
[
[
'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9',
'users' => ['user1'],
'apps' => ['files_texteditor'],
'logfile' => '/tmp/test.log'
],
[
- The term array in term array with round brackets, array key is a counting number
=>
array (
0 =>
array (
'path' => OC::$SERVERROOT.'/apps',
'url' => '/apps',
'writable' => 'false',
),
1 =>
array (
- Array in array with square brackets, sub key is defined, one sub array has more values without brackets, comma seperated
=> [
'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required
'localhost:7000',
'localhost:7001'
],
'timeout' => 0.0,
'read_timeout' => 0.0,
'failover_mode' => \RedisCluster::FAILOVER_DISTRIBUTE