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.

BInfoController::actionIndex()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 2
1
<?php
2
/**
3
 * @author Sergey Glagolev <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2014 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 * @package backend.modules.info.controllers
8
 */
9
class BInfoController extends BController
10
{
11
  public $layout = '//layouts/column2';
12
13
  public $modelClass = 'BInfo';
14
15
  public $name = 'Информация';
16
17
  public function actionCreate()
18
  {
19
    $model = new BInfo;
20
21
    $model->parent = Yii::app()->request->getQuery('parent', BInfo::ROOT_ID);
22
23
    $this->saveModels(array($model));
24
25
    $this->render('tree', array(
26
      'model'   => $model,
27
      'path'    => $model->getStringPath($model->parent),
28
      'current' => $model->parent,
29
    ));
30
  }
31
32
  public function actionUpdate($id)
33
  {
34
    /**
35
     * @var BInfo $model
36
     */
37
    $model = $this->loadModel($id);
38
39
    $this->saveModels(array($model));
40
41
    $this->render('tree', array(
42
      'model'   => $model,
43
      'path'    => $model->getStringPath($model->id),
44
      'current' => $model->id,
45
    ));
46
  }
47
48
  public function actionIndex()
49
  {
50
    $this->actionCreate();
51
  }
52
53
  public function actionList()
54
  {
55
    $model = $this->createFilterModel();
56
57
    $this->render('list', array(
58
      'model' => $model,
59
      'dataProvider' => $model->search(),
60
    ));
61
  }
62
63
  public function actionDragAndDrop()
64
  {
65
    $request = Yii::app()->request;
66
67
    if( $request->isAjaxRequest )
68
    {
69
      if( $request->getPost('action') == 'move' )
70
      {
71
        $dragModel = BInfo::model()->findByPk($request->getPost('drag'));
72
        $dropModel = BInfo::model()->findByPk($request->getPost('drop'));
73
74
        if( $dragModel && $dropModel )
75
          $dragModel->moveAsLast($dropModel);
76
      }
77
78
      $this->renderPartial('_tree', array(
79
        'model' => BInfo::model(),
80
        'current' => $request->getPost('current', 0)
81
      ));
82
83
      Yii::app()->end();
0 ignored issues
show
Bug introduced by
The method end does only exist in BTestApplication and FTestApplication, but not in BApplication and FApplication.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
84
    }
85
  }
86
}