1 | <?php |
||
21 | class FileUpload extends BaseUpload |
||
22 | { |
||
23 | /** |
||
24 | * @var bool whether to register the js files for the basic + |
||
25 | */ |
||
26 | public $plus = false; |
||
27 | |||
28 | /** |
||
29 | * @var bool whether to render the default button |
||
30 | */ |
||
31 | public $useDefaultButton = true; |
||
32 | |||
33 | /** |
||
34 | * @var string the upload view path to render the js upload template |
||
35 | */ |
||
36 | public $uploadButtonTemplateView = 'uploadButton'; |
||
37 | |||
38 | /** |
||
39 | * @inheritdoc |
||
40 | */ |
||
41 | 2 | public function init() |
|
48 | |||
49 | /** |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | 1 | public function run() |
|
64 | |||
65 | /** |
||
66 | * Registers required script for the plugin to work as jQuery File Uploader |
||
67 | */ |
||
68 | 1 | public function registerClientScript() |
|
89 | } |
||
90 |
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.