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.

AutoLoaderAwareTrait::newAutoLoader()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\AutoLoader;
4
5
/**
6
 * Class AutoLoaderAwareTrait
7
 * @package Nip\AutoLoader
8
 */
9
trait AutoLoaderAwareTrait
10
{
11
    /**
12
     * @var AutoLoader|null
13
     */
14
    protected $autoLoader = null;
15
16
    /**
17
     * @return AutoLoader
18
     */
19
    public function getAutoLoader()
20
    {
21
        if ($this->autoLoader === null) {
22
            $this->initAutoLoader();
23
        }
24
25
        return $this->autoLoader;
26
    }
27
28
    /**
29
     * @param bool|AutoLoader $autoLoader
30
     * @return $this
31
     */
32
    public function setAutoLoader($autoLoader = false)
33
    {
34
        $this->autoLoader = $autoLoader;
0 ignored issues
show
Documentation Bug introduced by
It seems like $autoLoader can also be of type boolean. However, the property $autoLoader is declared as type object<Nip\AutoLoader\AutoLoader>|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
35
36
        return $this;
37
    }
38
39
    protected function initAutoLoader()
40
    {
41
        $this->setAutoLoader($this->newAutoLoader());
42
    }
43
44
    /**
45
     * @return AutoLoader
46
     */
47
    protected function newAutoLoader()
48
    {
49
        return app()->get('autoloader');
50
    }
51
}
52