Conditions | 1 |
Paths | 1 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
9 | function qa_drush_command() { |
||
10 | $items['como-table'] = [ |
||
|
|||
11 | 'aliases' => ['cmt'], |
||
12 | 'description' => 'Show the content moderation as a table.', |
||
13 | ]; |
||
14 | |||
15 | $items['como-graphviz'] = [ |
||
16 | 'aliases' => ['cmg'], |
||
17 | 'description' => 'Show the content moderation as a Graphviz DOT file.', |
||
18 | 'arguments' => [ |
||
19 | 'workflow' => 'The machine name of a workflow', |
||
20 | ] |
||
21 | ]; |
||
22 | |||
23 | $items['qa-workflows-list'] = [ |
||
24 | 'aliases' => ['qawl'], |
||
25 | 'description' => 'Show a summary of available workflows', |
||
26 | ]; |
||
27 | |||
28 | return $items; |
||
29 | } |
||
30 | |||
52 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.