| 1 | <?php |
||
| 14 | class SendE2E implements CommandInterface { |
||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | private $nonce; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $box; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | private $threemaId; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $threemaId |
||
| 32 | * @param string $nonce |
||
| 33 | * @param string $box |
||
| 34 | */ |
||
| 35 | public function __construct($threemaId, $nonce, $box) { |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | public function getNonce() { |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function getBox() { |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return array |
||
| 57 | */ |
||
| 58 | public function getParams() { |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @return string |
||
| 69 | */ |
||
| 70 | public function getPath() { |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @param int $httpCode |
||
| 76 | * @param object $res |
||
| 77 | * @return SendE2EResult |
||
| 78 | */ |
||
| 79 | public function parseResult($httpCode, $res){ |
||
| 82 | } |
||
| 83 |
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.