1 | <?php |
||
17 | class Scripts extends _Lib |
||
18 | { |
||
19 | public function __construct() |
||
23 | |||
24 | /** |
||
25 | * @param Event $event |
||
26 | * @throws ConfigNotFoundException |
||
27 | * @throws EnvironmentException |
||
28 | * @throws InvalidArgumentException |
||
29 | * @throws InvalidMigrationFile |
||
30 | * @throws KeyNotFoundException |
||
31 | * @throws ReflectionException |
||
32 | */ |
||
33 | public static function migrate(Event $event) |
||
38 | |||
39 | /** |
||
40 | * @param Event $event |
||
41 | * @throws ConfigNotFoundException |
||
42 | * @throws EnvironmentException |
||
43 | * @throws InvalidArgumentException |
||
44 | * @throws KeyNotFoundException |
||
45 | * @throws ReflectionException |
||
46 | */ |
||
47 | public static function genRestDocs(Event $event) |
||
52 | |||
53 | /** |
||
54 | * @param $arguments |
||
55 | * @throws ConfigNotFoundException |
||
56 | * @throws EnvironmentException |
||
57 | * @throws InvalidArgumentException |
||
58 | * @throws InvalidMigrationFile |
||
59 | * @throws KeyNotFoundException |
||
60 | * @throws ReflectionException |
||
61 | */ |
||
62 | public function runMigrate($arguments) |
||
98 | |||
99 | /** |
||
100 | * @param $arguments |
||
101 | * @param bool $hasCmd |
||
102 | * @return array |
||
103 | */ |
||
104 | protected function extractArguments($arguments, $hasCmd = true) { |
||
125 | |||
126 | /** |
||
127 | * @param $arguments |
||
128 | * @throws ConfigNotFoundException |
||
129 | * @throws EnvironmentException |
||
130 | * @throws InvalidArgumentException |
||
131 | * @throws KeyNotFoundException |
||
132 | * @throws ReflectionException |
||
133 | */ |
||
134 | public function runGenRestDocs($arguments) |
||
153 | } |
||
154 |
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.