GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Cardwall_RendererPresenter::__construct()   B
last analyzed

Complexity

Conditions 5
Paths 16

Size

Total Lines 13
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 13
rs 8.8571
cc 5
eloc 12
nc 16
nop 4
1
<?php
2
/**
3
 * Copyright (c) Enalean, 2012-2015. All Rights Reserved.
4
 *
5
 * This file is a part of Tuleap.
6
 *
7
 * Tuleap is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * Tuleap is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
22
/**
23
 * The content of the renderer
24
 */
25
class Cardwall_RendererPresenter extends Cardwall_BoardPresenter {
26
27
    /**
28
     * @var Tracker_FormElement_Field_Selectbox
29
     */
30
    public $field;
31
32
    /**
33
     * @var bool
34
     */
35
    public $has_columns;
36
37
    /**
38
     * @var string
39
     */
40
    public $warn_please_choose;
41
42
    /**
43
     * @var string
44
     */
45
    public $warn_no_values;
46
47
    public $is_display_avatar_selected = "";
48
49
    /**
50
     * @param Cardwall_Board $board The board
51
     * @param string $redirect_parameter the redirect paramter to add to various url
52
     * @param Tracker_FormElement_Field_Selectbox $field form to choose the column. false if no form (in widget) (thus no typehinting)
53
     * @param $form
54
     */
55
    public function __construct(Cardwall_Board $board, $redirect_parameter, $field, $form) {
56
        parent::__construct($board, $redirect_parameter);
57
        $hp                        = Codendi_HTMLPurifier::instance();
58
        $this->nifty               = Toggler::getClassname('cardwall_board-nifty') == 'toggler' ? 'nifty' : false;
0 ignored issues
show
Documentation Bug introduced by
It seems like \Toggler::getClassname('...gler' ? 'nifty' : false can also be of type false. However, the property $nifty is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
59
        $this->swimline_title      = '';
60
        $this->has_swimline_header = false;
61
        $this->field               = $field ? $field : false;
0 ignored issues
show
Documentation Bug introduced by
It seems like $field ? $field : false can also be of type false. However, the property $field is declared as type object<Tracker_FormElement_Field_Selectbox>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
62
        $this->form                = $form  ? $form  : false;
63
        $this->has_columns         = count($this->board->columns) > 0;
64
        $this->warn_please_choose  = $GLOBALS['Language']->getText('plugin_cardwall', 'warn_please_choose');
65
        $field_label               = $field ? $hp->purify($this->field->getLabel()) : '###';
66
        $this->warn_no_values      = $GLOBALS['Language']->getText('plugin_cardwall', 'warn_no_values', $field_label);
67
    }
68
}
69