$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.
$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...
123
'UTC',
124
0
125
);
126
127
$provider[] = array(
128
'Z',
129
0
130
);
131
132
$provider[] = array(
133
'Unknown',
134
false
135
);
136
137
$provider[] = array(
138
'Asia/Tokyo',
139
32400
140
);
141
142
// Maybe return PST or PDT during Daylight Savings Time
55% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have
checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that
someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.
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.