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.
Completed
Push — analysis-OM5eeJ ( 49ecbc )
by butschster
07:58
created

EditableReadonlyTrait::getReadonly()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace SleepingOwl\Admin\Traits;
4
5
trait EditableReadonlyTrait
6
{
7
    /**
8
     * @var bool
9
     */
10
    protected $readonlyEditable = false;
11
12
    /**
13
     * @return mixed
14
     */
15
    public function getReadonly()
16
    {
17
        return $this->getModelConfiguration()->isEditable($this->getModel()) && ! $this->readonlyEditable;
0 ignored issues
show
Bug introduced by
It seems like getModel() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

17
        return $this->getModelConfiguration()->isEditable($this->/** @scrutinizer ignore-call */ getModel()) && ! $this->readonlyEditable;
Loading history...
Bug introduced by
It seems like getModelConfiguration() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

17
        return $this->/** @scrutinizer ignore-call */ getModelConfiguration()->isEditable($this->getModel()) && ! $this->readonlyEditable;
Loading history...
18
    }
19
20
    /**
21
     * @param Closure|bool $readonlyEditable
0 ignored issues
show
Bug introduced by
The type SleepingOwl\Admin\Traits\Closure was not found. Did you mean Closure? If so, make sure to prefix the type with \.
Loading history...
22
     *
23
     * @return $this
24
     */
25
    public function setReadonly($readonlyEditable)
26
    {
27
        $this->readonlyEditable = $readonlyEditable;
0 ignored issues
show
Documentation Bug introduced by
It seems like $readonlyEditable can also be of type SleepingOwl\Admin\Traits\Closure. However, the property $readonlyEditable is declared as type boolean. 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...
28
29
        return $this;
30
    }
31
}
32