| 1 | <?php |
||
| 3 | class Jetpack_JSON_API_Maybe_Auto_Update_Endpoint extends Jetpack_JSON_API_Endpoint { |
||
| 4 | // POST /sites/%s/maybe_auto_update |
||
| 5 | protected $needed_capabilities = array( 'update_core', 'update_plugins', 'update_themes' ); |
||
| 6 | |||
| 7 | protected $update_results = array(); |
||
| 8 | |||
| 9 | protected function result() { |
||
| 27 | |||
| 28 | public function get_update_results( $results ) { |
||
| 31 | |||
| 32 | } |
||
|
1 ignored issue
–
show
|
|||
| 33 |
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
$myArrayis initialized the first time when the foreach loop is entered. You can also see that the value of thebarkey 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.