mambax7 /
extcal
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | // defined('XOOPS_ROOT_PATH') || exit('Restricted access.'); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * @param $category |
||
| 7 | * @param $itemId |
||
| 8 | * |
||
| 9 | * @return mixed |
||
| 10 | */ |
||
| 11 | function extcal_notify_iteminfo($category, $itemId) |
||
| 12 | { |
||
| 13 | if ('global' === $category || 'cat' === $category) { |
||
| 14 | $item['name'] = ''; |
||
|
0 ignored issues
–
show
|
|||
| 15 | $item['url'] = ''; |
||
| 16 | |||
| 17 | return $item; |
||
| 18 | } |
||
| 19 | |||
| 20 | if ('event' === $category) { |
||
| 21 | $eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE); |
||
| 22 | $event = $eventHandler->getEvent($itemId, 0, true); |
||
| 23 | $item['name'] = $event->getVar('event_title'); |
||
| 24 | $item['url'] = XOOPS_URL . '/modules/extcal/event.php?event=' . $event->getVar('event_id'); |
||
| 25 | |||
| 26 | return $item; |
||
| 27 | } |
||
| 28 | |||
| 29 | return ''; |
||
| 30 | } |
||
| 31 |
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.