| 1 | <?php |
||
| 15 | class QueryBuilder extends \hiqdev\hiart\AbstractQueryBuilder |
||
| 16 | { |
||
| 17 | protected $authHeaders = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * This function is for you to provide your authentication. |
||
| 21 | * @param Query $query |
||
| 22 | */ |
||
| 23 | 2 | public function buildAuth(Query $query) |
|
| 33 | |||
| 34 | 2 | public function buildMethod(Query $query) |
|
| 49 | |||
| 50 | 2 | public function buildUri(Query $query) |
|
| 54 | |||
| 55 | 2 | public function buildHeaders(Query $query) |
|
| 59 | |||
| 60 | 2 | public function buildProtocolVersion(Query $query) |
|
| 64 | |||
| 65 | 2 | public function buildQueryParams(Query $query) |
|
| 69 | |||
| 70 | 2 | public function buildFormParams(Query $query) |
|
| 74 | |||
| 75 | 2 | public function buildBody(Query $query) |
|
| 79 | } |
||
| 80 |
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.