Passed
Push — master ( 158267...cd0d6c )
by Michael
02:28
created

mydownloads.php ➔ b_waiting_mydownloads()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 37

Duplication

Lines 37
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 0
dl 37
loc 37
rs 9.328
c 0
b 0
f 0
1
<?php
2
/**
3
 * @return array
4
 */
5
function b_waiting_mydownloads()
6
{
7
        /** @var \XoopsMySQLDatabase $xoopsDB */
8
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
9
    $ret     = [];
10
11
    // mydownloads links
12
    $block  = [];
13
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_downloads') . ' WHERE status=0');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...') . ' WHERE status=0') targeting XoopsMySQLDatabase::query() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
14
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
15
        $block['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listNewDownloads';
16
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
17
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
18
    }
19
    $ret[] = $block;
20
21
    // mydownloads broken
22
    $block  = [];
23
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_broken'));
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...('mydownloads_broken')) targeting XoopsMySQLDatabase::query() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
24
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
25
        $block['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listBrokenDownloads';
26
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
27
        $block['lang_linkname'] = _PI_WAITING_BROKENS;
28
    }
29
    $ret[] = $block;
30
31
    // mydownloads modreq
32
    $block  = [];
33
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_mod'));
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...fix('mydownloads_mod')) targeting XoopsMySQLDatabase::query() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
34
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
35
        $block['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listModReq';
36
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
37
        $block['lang_linkname'] = _PI_WAITING_MODREQS;
38
    }
39
    $ret[] = $block;
40
41
    return $ret;
42
}
43