ICWNAFWD   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
1
<?php
2
3
namespace TestNamespace;
4
5
use ExtendClass;
6
use NamespaceDep\ClassDep;
7
use NS\IClass;
8
9
/**
10
 * Generated Class
11
 */
12
class ICWNAFWD extends ExtendClass implements IClass
13
{
14
    /**
15
     * session unique identifier
16
     *
17
     * @var int
18
     */
19
    private $prova;
20
21
    /**
22
     * comment ClassDep
23
     *
24
     * @var NamespaceDep\ClassDep
25
     */
26
    private $dependency;
27
28
    /**
29
     * costruttore
30
     */
31
    final public function __construct($prova, ClassDep $dependency = null)
32
    {
33
        $this->prova = $prova;
34
        $this->dependency = $dependency;
0 ignored issues
show
Documentation Bug introduced by
It seems like $dependency can also be of type object<NamespaceDep\ClassDep>. However, the property $dependency is declared as type object<TestNamespace\NamespaceDep\ClassDep>. 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
}
37