1 | <?php |
||
2 | /** |
||
3 | * PHP Billing Library |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/php-billing |
||
6 | * @package php-billing |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hiqdev\php\billing\plan; |
||
12 | |||
13 | use hiqdev\php\billing\customer\CustomerInterface; |
||
14 | use hiqdev\php\billing\Exception\CannotReassignException; |
||
15 | use hiqdev\php\billing\price\PriceInterface; |
||
16 | use hiqdev\php\billing\type\TypeInterface; |
||
0 ignored issues
–
show
|
|||
17 | |||
18 | /** |
||
19 | * Tariff Plan. |
||
20 | * |
||
21 | * @author Andrii Vasyliev <[email protected]> |
||
22 | */ |
||
23 | class Plan implements PlanInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $name; |
||
34 | |||
35 | protected ?int $parent_id = null; |
||
36 | |||
37 | /** |
||
38 | * @var CustomerInterface |
||
39 | */ |
||
40 | protected $seller; |
||
41 | |||
42 | /** |
||
43 | * @var PriceInterface[] |
||
44 | */ |
||
45 | protected $prices = []; |
||
46 | |||
47 | /** |
||
48 | * @var ?TypeInterface |
||
49 | */ |
||
50 | protected $type; |
||
51 | |||
52 | /** |
||
53 | * @param int|string|null $id |
||
54 | * @param string $name |
||
55 | 14 | * @param PriceInterface[] $prices |
|
56 | */ |
||
57 | public function __construct( |
||
58 | $id, |
||
59 | $name, |
||
60 | CustomerInterface $seller = null, |
||
61 | 14 | $prices = [], |
|
62 | 14 | TypeInterface $type = null, |
|
63 | 14 | $parent_id = null |
|
64 | 14 | ) { |
|
65 | 14 | $this->id = $id; |
|
0 ignored issues
–
show
It seems like
$id can also be of type string . However, the property $id is declared as type integer . 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 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;
}
![]() |
|||
66 | $this->name = $name; |
||
67 | $this->seller = $seller; |
||
68 | $this->prices = $prices; |
||
69 | $this->type = $type; |
||
70 | $this->parent_id = $parent_id; |
||
71 | } |
||
72 | |||
73 | public function getUniqueId() |
||
74 | { |
||
75 | 4 | return $this->getId(); |
|
76 | } |
||
77 | 4 | ||
78 | /** |
||
79 | * @return int|string |
||
80 | */ |
||
81 | public function getId() |
||
82 | { |
||
83 | 5 | return $this->id; |
|
84 | } |
||
85 | 5 | ||
86 | /** |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getName(): string |
||
90 | { |
||
91 | 5 | return $this->name; |
|
92 | } |
||
93 | 5 | ||
94 | public function setName(string $name): void |
||
95 | { |
||
96 | $this->name = $name; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @return CustomerInterface |
||
101 | */ |
||
102 | public function getSeller(): ?CustomerInterface |
||
103 | { |
||
104 | 2 | return $this->seller; |
|
105 | } |
||
106 | 2 | ||
107 | public function getParentId(): ?int |
||
108 | { |
||
109 | return $this->parent_id; |
||
110 | } |
||
111 | |||
112 | 4 | public function setParentId(int $parentId): void |
|
113 | { |
||
114 | 4 | $this->parent_id = $parentId; |
|
115 | } |
||
116 | |||
117 | public function hasPrices(): bool |
||
118 | { |
||
119 | return $this->prices !== []; |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @return PriceInterface[] |
||
124 | */ |
||
125 | public function getPrices(): array |
||
126 | { |
||
127 | return $this->prices; |
||
128 | } |
||
129 | |||
130 | public function setPrices(array $prices): void |
||
131 | { |
||
132 | if ($this->hasPrices()) { |
||
133 | throw new CannotReassignException('plan prices'); |
||
134 | } |
||
135 | $this->prices = $prices; |
||
136 | } |
||
137 | |||
138 | public function getType(): ?TypeInterface |
||
139 | { |
||
140 | return $this->type ?? null; |
||
141 | } |
||
142 | |||
143 | public function jsonSerialize(): array |
||
144 | { |
||
145 | return array_filter(get_object_vars($this)); |
||
146 | } |
||
147 | } |
||
148 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths