These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Sylius package. |
||
5 | * |
||
6 | * (c) Paweł Jędrzejewski |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace Sylius\Component\Core\Model; |
||
15 | |||
16 | use Doctrine\Common\Collections\ArrayCollection; |
||
17 | use Doctrine\Common\Collections\Collection; |
||
18 | use Sylius\Component\Customer\Model\Customer as BaseCustomer; |
||
19 | use Sylius\Component\User\Model\UserInterface as BaseUserInterface; |
||
20 | use Webmozart\Assert\Assert; |
||
21 | |||
22 | class Customer extends BaseCustomer implements CustomerInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var Collection|OrderInterface[] |
||
26 | */ |
||
27 | protected $orders; |
||
28 | |||
29 | /** |
||
30 | * @var AddressInterface |
||
31 | */ |
||
32 | protected $defaultAddress; |
||
33 | |||
34 | /** |
||
35 | * @var Collection|AddressInterface[] |
||
36 | */ |
||
37 | protected $addresses; |
||
38 | |||
39 | /** |
||
40 | * @var ShopUserInterface |
||
41 | */ |
||
42 | protected $user; |
||
43 | |||
44 | public function __construct() |
||
45 | { |
||
46 | parent::__construct(); |
||
47 | |||
48 | $this->orders = new ArrayCollection(); |
||
0 ignored issues
–
show
|
|||
49 | $this->addresses = new ArrayCollection(); |
||
0 ignored issues
–
show
It seems like
new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<Doctrine\Common\C...odel\AddressInterface>> of property $addresses .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
Loading history...
|
|||
50 | } |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | public function getOrders(): Collection |
||
56 | { |
||
57 | return $this->orders; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | public function getDefaultAddress(): ?AddressInterface |
||
64 | { |
||
65 | return $this->defaultAddress; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function setDefaultAddress(?AddressInterface $defaultAddress): void |
||
72 | { |
||
73 | $this->defaultAddress = $defaultAddress; |
||
74 | |||
75 | if (null !== $defaultAddress) { |
||
76 | $this->addAddress($defaultAddress); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function addAddress(AddressInterface $address): void |
||
84 | { |
||
85 | if (!$this->hasAddress($address)) { |
||
86 | $this->addresses[] = $address; |
||
87 | $address->setCustomer($this); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function removeAddress(AddressInterface $address): void |
||
95 | { |
||
96 | $this->addresses->removeElement($address); |
||
97 | $address->setCustomer(null); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public function hasAddress(AddressInterface $address): bool |
||
104 | { |
||
105 | return $this->addresses->contains($address); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public function getAddresses(): Collection |
||
112 | { |
||
113 | return $this->addresses; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public function getUser(): ?BaseUserInterface |
||
120 | { |
||
121 | return $this->user; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | public function setUser(?BaseUserInterface $user): void |
||
128 | { |
||
129 | if ($this->user === $user) { |
||
130 | return; |
||
131 | } |
||
132 | |||
133 | /** @var ShopUserInterface|null $user */ |
||
134 | Assert::nullOrIsInstanceOf($user, ShopUserInterface::class); |
||
135 | |||
136 | $previousUser = $this->user; |
||
137 | $this->user = $user; |
||
138 | |||
139 | if ($previousUser instanceof ShopUserInterface) { |
||
140 | $previousUser->setCustomer(null); |
||
141 | } |
||
142 | |||
143 | if ($user instanceof ShopUserInterface) { |
||
144 | $user->setCustomer($this); |
||
145 | } |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * {@inheritdoc} |
||
150 | */ |
||
151 | public function hasUser(): bool |
||
152 | { |
||
153 | return null !== $this->user; |
||
154 | } |
||
155 | } |
||
156 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..