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

AuthController::loginAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.8666
cc 1
nc 1
nop 0
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