Completed
Push — master ( 68c045...6d06de )
by Michael
02:34
created

include/notification.inc.php (1 issue)

Upgrade to new PHP Analysis Engine

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
Coding Style Comprehensibility introduced by
$item was never initialized. Although not strictly required by PHP, it is generally a good practice to add $item = array(); before regardless.

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:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

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 the bar 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.

Loading history...
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