Skip to content

Commit 9e751a1

Browse files
committed
(phpstan) refactor: cast floor results to int for better type safety in UpdateStats
1 parent e950851 commit 9e751a1

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: '#^Offset float on list in isset\(\) does not exist\.$#'
5-
identifier: isset.offset
6-
count: 1
7-
path: src/FeedIo/Reader/Result/UpdateStats.php
8-
93
-
104
message: '#^PHPDoc tag @var with type FeedIo\\Reader\\FixerAbstract is not subtype of native type FeedIo\\Reader\\Fixer\\HttpLastModified\|FeedIo\\Reader\\Fixer\\PublicId\.$#'
115
identifier: varTag.nativeType

src/FeedIo/Reader/Result/UpdateStats.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public function getAverageInterval(): int
142142

143143
// some feeds could have very old historic
144144
// articles so eliminate them with statistic
145-
$q1 = $this->intervals[floor($count * 0.25)];
146-
$q3 = $this->intervals[floor($count * 0.75)];
145+
$q1 = $this->intervals[(int) floor($count * 0.25)];
146+
$q3 = $this->intervals[(int) floor($count * 0.75)];
147147
$iqr = $q3 - $q1;
148148

149149
$lower_bound = $q1 - 1.5 * $iqr;
@@ -170,7 +170,7 @@ public function getMedianInterval(): int
170170
return 0;
171171
}
172172

173-
$num = floor($count / 2);
173+
$num = (int) floor($count / 2);
174174

175175
if ($count % 2 === 0) {
176176
return intval(floor(($this->intervals[$num - 1] + $this->intervals[$num]) / 2));

0 commit comments

Comments
 (0)