This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity; |
||
4 | |||
5 | use Doctrine\Common\Collections\ArrayCollection; |
||
6 | use Doctrine\Common\Collections\Collection; |
||
7 | |||
8 | /** |
||
9 | * Tweet. |
||
10 | */ |
||
11 | class Tweet |
||
12 | { |
||
13 | /** |
||
14 | * @var int |
||
15 | */ |
||
16 | private $id; |
||
17 | |||
18 | /** |
||
19 | * @var \DateTime |
||
20 | */ |
||
21 | private $created_at; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $text; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $retweet_count = 0; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | private $favorite_count = 0; |
||
37 | |||
38 | /** |
||
39 | * @var User |
||
40 | */ |
||
41 | private $user; |
||
42 | |||
43 | /** |
||
44 | * In timeline: false for retweeted Tweets. |
||
45 | * |
||
46 | * @var bool |
||
47 | */ |
||
48 | private $in_timeline = false; |
||
49 | |||
50 | /** |
||
51 | * @var Tweet |
||
52 | */ |
||
53 | private $retweeted_status = null; |
||
54 | |||
55 | /** |
||
56 | * @var Collection<int, Tweet> |
||
57 | */ |
||
58 | private $retweeting_statuses; |
||
59 | |||
60 | /** |
||
61 | * @var Collection<int, Media> |
||
62 | */ |
||
63 | private $medias; |
||
64 | |||
65 | 14 | public function __construct() |
|
66 | { |
||
67 | 14 | $this->medias = new ArrayCollection(); |
|
68 | 14 | $this->retweeting_statuses = new ArrayCollection(); |
|
69 | 14 | } |
|
70 | |||
71 | /** |
||
72 | * Set id. |
||
73 | * |
||
74 | * @return Tweet |
||
75 | */ |
||
76 | 14 | public function setId(int $id): self |
|
77 | { |
||
78 | 14 | $this->id = $id; |
|
79 | |||
80 | 14 | return $this; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * Get id. |
||
85 | */ |
||
86 | 9 | public function getId(): int |
|
87 | { |
||
88 | 9 | return $this->id; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * Set created_at. |
||
93 | */ |
||
94 | 14 | public function setCreatedAt(\DateTime $createdAt): self |
|
95 | { |
||
96 | 14 | $this->created_at = $createdAt; |
|
97 | |||
98 | 14 | return $this; |
|
99 | } |
||
100 | |||
101 | /** |
||
102 | * Get created_at. |
||
103 | */ |
||
104 | 10 | public function getCreatedAt(): \DateTime |
|
105 | { |
||
106 | 10 | return $this->created_at; |
|
107 | } |
||
108 | |||
109 | /** |
||
110 | * Set text. |
||
111 | */ |
||
112 | 14 | public function setText(string $text): self |
|
113 | { |
||
114 | 14 | $this->text = $text; |
|
115 | |||
116 | 14 | return $this; |
|
117 | } |
||
118 | |||
119 | /** |
||
120 | * Get text. |
||
121 | */ |
||
122 | 11 | public function getText(): string |
|
123 | { |
||
124 | 11 | return $this->text; |
|
125 | } |
||
126 | |||
127 | 6 | public function getTextLinkified(): ?string |
|
128 | { |
||
129 | /* @see http://stackoverflow.com/questions/507436/how-do-i-linkify-urls-in-a-string-with-php/507459#507459 */ |
||
130 | 6 | return preg_replace( |
|
131 | 6 | '~[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]~', |
|
132 | 6 | '<a href="\\0">\\0</a>', |
|
133 | 6 | $this->getText() |
|
134 | ); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * Set retweet_count. |
||
139 | */ |
||
140 | 14 | public function setRetweetCount(int $retweetCount): self |
|
141 | { |
||
142 | 14 | $this->retweet_count = $retweetCount; |
|
143 | |||
144 | 14 | return $this; |
|
145 | } |
||
146 | |||
147 | /** |
||
148 | * Get retweet_count. |
||
149 | */ |
||
150 | 8 | public function getRetweetCount(): int |
|
151 | { |
||
152 | 8 | return $this->retweet_count; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * Set favorite_count. |
||
157 | */ |
||
158 | 14 | public function setFavoriteCount(int $favoriteCount): self |
|
159 | { |
||
160 | 14 | $this->favorite_count = $favoriteCount; |
|
161 | |||
162 | 14 | return $this; |
|
163 | } |
||
164 | |||
165 | /** |
||
166 | * Get favorite_count. |
||
167 | */ |
||
168 | 8 | public function getFavoriteCount(): int |
|
169 | { |
||
170 | 8 | return $this->favorite_count; |
|
171 | } |
||
172 | |||
173 | /** |
||
174 | * Set user. |
||
175 | */ |
||
176 | 14 | public function setUser(User $user): self |
|
177 | { |
||
178 | 14 | $this->user = $user; |
|
179 | 14 | $this->user->addTweet($this); |
|
180 | |||
181 | 14 | return $this; |
|
182 | } |
||
183 | |||
184 | /** |
||
185 | * Get User. |
||
186 | */ |
||
187 | 9 | public function getUser(): User |
|
188 | { |
||
189 | 9 | return $this->user; |
|
190 | } |
||
191 | |||
192 | /** |
||
193 | * Set in timeline. |
||
194 | */ |
||
195 | 14 | public function setInTimeline(bool $inTimeline): self |
|
196 | { |
||
197 | 14 | $this->in_timeline = $inTimeline; |
|
198 | |||
199 | 14 | return $this; |
|
200 | } |
||
201 | |||
202 | /** |
||
203 | * Get in timeline. |
||
204 | */ |
||
205 | 3 | public function isInTimeline(): bool |
|
206 | { |
||
207 | 3 | return $this->in_timeline; |
|
208 | } |
||
209 | |||
210 | /** |
||
211 | * Set retweeted |
||
212 | * "This attribute contains a representation of the original Tweet |
||
213 | * that was retweeted.". |
||
214 | */ |
||
215 | 13 | public function setRetweetedStatus(self $retweetedStatus): self |
|
216 | { |
||
217 | 13 | $this->retweeted_status = $retweetedStatus; |
|
0 ignored issues
–
show
|
|||
218 | |||
219 | 13 | return $this; |
|
220 | } |
||
221 | |||
222 | /** |
||
223 | * Get retweeted status. |
||
224 | */ |
||
225 | 7 | public function getRetweetedStatus(): ?self |
|
226 | { |
||
227 | 7 | return $this->retweeted_status; |
|
228 | } |
||
229 | |||
230 | /** |
||
231 | * Get medias. |
||
232 | * |
||
233 | * @return Collection<int, Media> |
||
234 | */ |
||
235 | 6 | public function getMedias(): Collection |
|
236 | { |
||
237 | 6 | return $this->medias; |
|
238 | } |
||
239 | |||
240 | 13 | public function addMedia(Media $media): self |
|
241 | { |
||
242 | 13 | $this->medias->add($media); |
|
243 | 13 | $media->addTweet($this); |
|
244 | |||
245 | 13 | return $this; |
|
246 | } |
||
247 | |||
248 | 1 | public function removeMedia(Media $media): self |
|
249 | { |
||
250 | 1 | $this->medias->removeElement($media); |
|
251 | 1 | $media->removeTweet($this); |
|
252 | |||
253 | 1 | return $this; |
|
254 | } |
||
255 | |||
256 | /** |
||
257 | * Get retweeting status. |
||
258 | * |
||
259 | * @return Collection<int, Tweet> |
||
260 | */ |
||
261 | 2 | public function getRetweetingStatuses(): Collection |
|
262 | { |
||
263 | 2 | return $this->retweeting_statuses; |
|
264 | } |
||
265 | |||
266 | /** |
||
267 | * Call setter functions. |
||
268 | */ |
||
269 | 3 | public function setValues(\stdClass $tweetTmp): self |
|
270 | { |
||
271 | $this |
||
272 | 3 | ->setCreatedAt(new \DateTime($tweetTmp->created_at)) |
|
273 | 3 | ->setText($tweetTmp->text) |
|
274 | 3 | ->setRetweetCount($tweetTmp->retweet_count) |
|
275 | 3 | ->setFavoriteCount($tweetTmp->favorite_count); |
|
276 | |||
277 | 3 | return $this; |
|
278 | } |
||
279 | |||
280 | /** |
||
281 | * Check that tweet can be deleted. |
||
282 | */ |
||
283 | 2 | public function mustBeKept(int $tweetId): bool |
|
284 | { |
||
285 | 2 | if (count($this->getRetweetingStatuses()) == 0) { |
|
286 | // This tweet has not been retweeted |
||
287 | 2 | return false; |
|
288 | } |
||
289 | |||
290 | // Check that this tweet has not been retweeted after $tweetId |
||
291 | 1 | foreach ($this->getRetweetingStatuses() as $retweeting_status) { |
|
292 | // This tweet is retweeted in the timeline, keep it |
||
293 | 1 | if ($retweeting_status->getId() >= $tweetId) { |
|
294 | 1 | return true; |
|
295 | } |
||
296 | } |
||
297 | |||
298 | 1 | return false; |
|
299 | } |
||
300 | } |
||
301 |
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..