It seems like $file can also be of type false; however, parameter $handle of feof() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
17
while (!feof(/** @scrutinizer ignore-type */ $file)) {
It seems like $file can also be of type false; however, parameter $handle of fgets() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
It seems like $file can also be of type false; however, parameter $handle of fclose() does only seem to accept resource, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
20
fclose(/** @scrutinizer ignore-type */ $file);
Loading history...
21
}
22
23
public function solve()
24
{
25
$result = $this->calculateFrequency();
26
27
printf('The resulting frequency is: %s', $result);
28
}
29
30
public function setChanges(array $changes): void
31
{
32
$this->changes = $changes;
33
}
34
35
public function getChanges(): array
36
{
37
return $this->changes;
38
}
39
40
/**
41
* @param int $frequency -> The starting frequency
42
* @return int
43
*/
44
public function calculateFrequency(int $frequency = 0): int
45
{
46
foreach ($this->changes as $change) {
47
$frequency += $change;
48
}
49
50
return $frequency;
51
}
52
53
/**
54
* @param int $frequency -> The starting frequency
55
* @return int
56
*/
57
public function getFrequencyReachedTwice(int $frequency = 0): int