Test Setup Failed
Push — master ( 26e42b...c0b3e2 )
by Tobias
12:19
created

m150917_193929_rbac::down()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 9
nc 2
nop 0
1
<?php
2
3
use yii\db\Migration;
4
5
class m150917_193929_rbac extends Migration
6
{
7
    public function up()
8
    {
9
        $auth = Yii::$app->authManager;
10
11
        if ($auth instanceof \yii\rbac\DbManager) {
0 ignored issues
show
Bug introduced by
The class yii\rbac\DbManager does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
12
            $guest = $auth->createRole('Public');
13
            $guest->description = 'Unauthenticated User';
14
            $auth->add($guest);
15
16
            $editor = $auth->createRole('Editor');
17
            $editor->description = 'prototype editor';
18
            $auth->add($editor);
19
20
            $permission = $auth->createPermission('backend_default');
21
            $permission->description = 'Backend Dashboard';
22
            $auth->add($permission);
23
24
            $permission = $auth->createPermission('app_site');
25
            $permission->description = 'Main Site Controller';
26
            $auth->add($permission);
27
28
            $auth->addChild($editor, $auth->getPermission('backend_default'));
29
            $auth->addChild($editor, $auth->getPermission('app_site'));
30
31
            $auth->addChild($editor, $auth->getPermission('pages'));
32
        } else {
33
            throw new \yii\base\Exception('Application authManager must be an instance of \yii\rbac\DbManager');
34
        }
35
    }
36
37
    public function down()
38
    {
39
        $auth = Yii::$app->authManager;
40
41
        if ($auth instanceof \yii\rbac\DbManager) {
0 ignored issues
show
Bug introduced by
The class yii\rbac\DbManager does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
42
            $auth->remove($auth->getPermission('backend_default'));
43
            $auth->remove($auth->getPermission('app_site'));
44
            $auth->remove($auth->getRole('Editor'));
45
            $auth->remove($auth->getRole('Public'));
46
        } else {
47
            throw new \yii\base\Exception('Application authManager must be an instance of \yii\rbac\DbManager');
48
        }
49
    }
50
}
51