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.
Completed
Push — master ( 764334...261594 )
by Alexey
33:15
created

ErrorController   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 82
rs 10
c 0
b 0
f 0
wmc 13
lcom 1
cbo 2

6 Methods

Rating   Name   Duplication   Size   Complexity  
B actionError() 0 30 6
A getErrorCode() 0 4 1
A getErrorMessage() 0 4 1
A error404() 0 4 1
A error401() 0 6 2
A initError() 0 9 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 frontend.controllers
8
 *
9
 * @property string $errorCode
10
 * @property string $errorMessage
11
 */
12
class ErrorController extends FController
13
{
14
  public $layout = '404';
15
16
  /**
17
   * @var int
18
   */
19
  protected $errorCode;
20
21
  /**
22
   * @var string
23
   */
24
  protected $errorMessage;
25
26
  /**
27
   * @var array
28
   */
29
  protected $error;
30
31
  public function actionError()
32
  {
33
    $this->initError();
34
35
    if( $this->error['type'] == 'ErrorSessionException' && !YII_DEBUG )
36
    {
37
      $returnUrl = Yii::app()->user->returnUrl;
38
      Yii::app()->session->clear();
39
      Yii::app()->session->closeSession();
40
      Yii::app()->request->redirect($returnUrl);
41
    }
42
43
    if( Yii::app()->request->isAjaxRequest )
44
    {
45
      echo $this->errorMessage;
46
      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...
47
    }
48
49
    if( YII_DEBUG )
50
      $this->render('errorDebug', $this->error);
51
    else
52
    {
53
      $methodName = 'error'.$this->errorCode;
54
55
      if( method_exists($this, $methodName) )
56
        $this->$methodName();
57
      else
58
        $this->error404();
59
    }
60
  }
61
62
  public function getErrorCode()
63
  {
64
    return $this->errorCode;
65
  }
66
67
  public function getErrorMessage()
68
  {
69
    return $this->errorMessage;
70
  }
71
72
  protected function error404()
73
  {
74
    $this->render('error404');
75
  }
76
77
  protected function error401()
78
  {
79
    $this->render('error401', array(
80
      'loginForm' => method_exists($this, 'getLoginForm') ? $this->getLoginForm() : null,
81
    ));
82
  }
83
84
  protected function initError()
85
  {
86
    if( !empty(Yii::app()->errorHandler->error) )
87
    {
88
      $this->error        = Yii::app()->errorHandler->error;
89
      $this->errorCode    = Yii::app()->errorHandler->error['code'];
90
      $this->errorMessage = Yii::app()->errorHandler->error['message'];
91
    }
92
  }
93
}