Completed
Push — master ( 00e474...9d3fbd )
by Michael
04:26
created

blocks/oledrion_my_lists.php (2 issues)

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
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link http://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
/**
21
 * Affiche les listes de l'utilisateur
22
 *
23
 * @param  array $options [0] = Nombre maximum de listes à voir
24
 * @return array
25
 */
26
function b_oledrion_my_lists_show($options)
27
{
28
    require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
29
    Oledrion_utils::loadLanguageFile('modinfo.php');
30
    $start = 0;
31
    $limit = (int)$options[0];
32
    $uid   = Oledrion_utils::getCurrentUserID();
33
    if ($uid == 0) {
34
        return null;
35
    }
36
    $listType = OLEDRION_LISTS_ALL;
37
    $block    = array();
38
    $handlers = OledrionHandler::getInstance();
39
    $items    = array();
0 ignored issues
show
$items is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
    $items    = $handlers->h_oledrion_lists->getRecentLists(new Oledrion_parameters(array(
0 ignored issues
show
The property h_oledrion_lists does not exist on object<OledrionHandler>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
41
                                                                                        'start'    => $start,
42
                                                                                        'limit'    => $limit,
43
                                                                                        'sort'     => 'list_date',
44
                                                                                        'order'    => 'DESC',
45
                                                                                        'idAsKey'  => true,
46
                                                                                        'listType' => $listType,
47
                                                                                        'list_uid' => $uid
48
                                                                                    )));
49
    if (count($items) > 0) {
50
        foreach ($items as $item) {
51
            $block['my_lists'][] = $item->toArray();
52
        }
53
    }
54
55
    return $block;
56
}
57
58
/**
59
 * Edition des paramètres du bloc
60
 *
61
 * @param  array $options [0] = Nombre maximum de listes à voir
62
 * @return array
63
 */
64
function b_oledrion_my_lists_edit($options)
65
{
66
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
67
    $form = '';
68
    $form .= "<table border='0'>";
69
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . (int)$options[0] . "' /></td></tr>";
70
    $form .= '</table>';
71
72
    return $form;
73
}
74
75
/**
76
 * Bloc à la volée
77
 * @param $options
78
 */
79 View Code Duplication
function b_oledrion_my_lists_duplicatable($options)
80
{
81
    $options = explode('|', $options);
82
    $block   = b_oledrion_my_lists_show($options);
83
84
    $tpl = new XoopsTpl();
85
    $tpl->assign('block', $block);
86
    $tpl->display('db:oledrion_block_my_lists.tpl');
87
}
88