$provider was never initialized. Although not strictly required by PHP, it is generally a good practice to add $provider = array(); before regardless.
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:
foreach($collectionas$item){$myArray['foo']=$item->getFoo();if($item->hasBar()){$myArray['bar']=$item->getBar();}// do something with $myArray}
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 the
bar 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.
Loading history...
49
'Foo bar',
50
'Foo bar'
51
);
52
53
#1
54
$provider[] = array(
55
'Foo [42] bar',
56
'Foo [42] bar'
57
);
58
59
#2
60
$provider[] = array(
61
'Foo [42 1001] bar',
62
'Foo [42 1001] bar'
63
);
64
65
#3
66
$provider[] = array(
67
'Foo [[42]] bar',
68
'Foo [[abc:42|42]] bar'
69
);
70
71
#4
72
$provider[] = array(
73
'Foo [[42|1001]] bar',
74
'Foo [[abc:42|1001]] bar'
75
);
76
77
// We can't guess the type of a remote annotation therefore it is turned
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.