Completed
Branch v2.0.0 (addc15)
by Alexander
03:27
created

AuthController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A loginAction() 0 12 1
1
<?php
2
3
/**
4
 * @author Alexander Torosh <[email protected]>
5
 */
6
7
namespace Dashboard\Controllers;
8
9
use Phalcon\Mvc\Controller;
10
use Phalcon\Tag;
11
12
class AuthController extends Controller
13
{
14
    /**
15
     * @Access('guest')
16
     */
17
    public function loginAction()
18
    {
19
        Tag::prependTitle('Dashboard Login');
20
21
        $redirect = $this->request->getQuery('redirect');
22
        $sanitizedRedirect = trim(strip_tags($redirect));
23
24
        $this->view->setVars([
1 ignored issue
show
Bug introduced by
The method setVars does only exist in Phalcon\Mvc\View, but not in Phalcon\Mvc\ViewInterface.

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...
25
            'hideDashboardRoot' => true,
26
            'redirect' => $sanitizedRedirect,
27
        ]);
28
    }
29
}
30