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.

OrderController::renderBasketFirstStep()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 1
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2015 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8
class OrderController extends FController
9
{
10
  const CLASS_WRAPPER = 'js-wrapper-basket';
11
12
  public function actionFirstStep()
13
  {
14
    $this->breadcrumbs = array('Корзина');
15
16
    if( Yii::app()->request->isAjaxRequest )
17
    {
18
      $this->forward('basket/ajax', false);
19
    }
20
    else
21
    {
22
      $this->basket->ajaxUrl = Yii::app()->createUrl('order/firstStep');
23
      $this->basket->ajaxUpdate(self::CLASS_WRAPPER);
24
    }
25
26
    $this->renderBasketFirstStep(array());
27
  }
28
29
  public function actionSecondStep()
30
  {
31
    if( $this->basket->isEmpty() )
32
      Yii::app()->request->redirect($this->createUrl('order/firstStep'));
33
34
    $this->breadcrumbs = array('Корзина');
35
36
    $orderForm = new FOrderForm('OrderForm', new Order());
37
38
    $orderForm->ajaxValidation();
39
40
    if( $orderForm->save() )
41
    {
42
      $orderForm->sendNotificationBackend();
43
      $orderForm->sendNotification($orderForm->model->email);
44
45
      $this->basket->clear();
46
47
      echo CJSON::encode(array(
48
        'status' => 'ok',
49
        'redirect'  => $orderForm->getSuccessUrl(),
50
      ));
51
52
      Yii::app()->session['orderSuccess'] = true;
53
      Yii::app()->session['orderId'] = $orderForm->model->id;
54
      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...
55
    }
56
    else
57
    {
58
      $this->render('second_step', array('form' => $orderForm, 'model' => $orderForm->model));
59
    }
60
  }
61
62
  public function actionThirdStep()
63
  {
64
    if( $this->basket->isEmpty() && !Yii::app()->session->get('orderSuccess', false) )
65
      Yii::app()->request->redirect($this->createUrl('order/firstStep'));
66
67
    $orderId = Yii::app()->session['orderId'];
68
    Yii::app()->session->remove('orderId');
69
    Yii::app()->session->remove('orderSuccess');
70
71
    $this->breadcrumbs = array('Корзина');
72
    $this->render('third_step', array('orderId' => $orderId));
73
  }
74
75
  private function renderBasketFirstStep($data = array())
76
  {
77
    $view = $this->basket->isEmpty() ? 'empty' : 'first_step';
78
    $this->onBeforeRender(new CEvent($this, array('data' => $data, 'view' => $view)));
79
80
    $html = array(CHtml::openTag('div', array('id' => self::CLASS_WRAPPER)));
81
    $html[] = $this->renderPartial($view, $data, true);
82
    $html[] = CHtml::closeTag('div');
83
84
    $output = implode("\n\r", $html);
85
86
    if( !Yii::app()->request->isAjaxRequest )
87
    {
88
      $this->onBeforeRenderLayout(new CEvent($this, array('content' => $output)));
89
      $output = $this->renderFile($this->getLayoutFile($this->layout), array('content' => $output), true);
90
      $output = $this->processOutput($output);
91
    }
92
93
    echo $output;
94
  }
95
}