Completed
Push — master ( 9ed240...526dfe )
by Razon
02:55
created

app/Http/Api/Backend/Form/LogoutForm.php (2 issues)

Labels
Severity
1
<?php
2
namespace App\Http\Api\Backend\Form;
3
4
use App\Form\Form;
5
use App\Htpp\User\LogoutInterface;
0 ignored issues
show
The type App\Htpp\User\LogoutInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Yii;
7
use yii\web\IdentityInterface;
8
9
class LogoutForm extends Form
10
{
11
    protected function handleInternal()
12
    {
13
        $user = $this->getUser();
14
        if (!$user) {
15
            return;
16
        }
17
18
        if ($user instanceof LogoutInterface) {
19
            $user->logout();
0 ignored issues
show
The method logout() does not exist on yii\web\IdentityInterface. It seems like you code against a sub-type of yii\web\IdentityInterface such as App\Model\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
            $user->/** @scrutinizer ignore-call */ 
20
                   logout();
Loading history...
20
            return;
21
        }
22
23
        Yii::$app->getUser()->logout();
24
    }
25
26
    private $user;
27
28
    /**
29
     * @return null|IdentityInterface
30
     */
31
    public function getUser()
32
    {
33
        if ($this->user === null) {
34
            $this->user = Yii::$app->getUser()->getIdentity();
35
        }
36
37
        return $this->user;
38
    }
39
}
40