forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-14452.php
More file actions
102 lines (82 loc) · 2.08 KB
/
bug-14452.php
File metadata and controls
102 lines (82 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php declare(strict_types = 1);
namespace Bug14452;
use function PHPStan\Testing\assertType;
class MyBag
{
public function getInt(string $key): int
{
return 0;
}
public function has(string $key): bool
{
return false;
}
/** @return bool|float|int|string|null */
public function get(string $key)
{
return null;
}
}
class Shared
{
public static function calculateThings(
?int $type,
float $hours,
float $minutes,
float $seconds,
?float $hourlyRate,
?float $flatFee,
?float $minimumCost,
): float
{
return 0.0;
}
}
/**
* Performance test: many possibly-impure method calls inside conditional branches
* should not cause exponential blowup in conditional expression creation.
*/
function test(MyBag $input): void
{
$prestatie = rand(0, 1) === 0;
$seconds = null;
$minimum_seconds = null;
$seconds_worked = null;
$minutes = null;
$minimum_minutes = null;
$minutes_worked = null;
$hours = null;
$minimum_hours = null;
$hours_worked = null;
$hourly_rate = null;
$flat_fee = round($input->getInt('flat_fee'), 2);
$minimum_cost = round($input->getInt('minimum_cost'), 2);
if ($prestatie) {
$seconds = $seconds_worked = $input->getInt('seconds_worked');
$minutes = $minutes_worked = $input->getInt('minutes_worked');
$hours = $hours_worked = $input->getInt('hours_worked');
$minimum_seconds = $input->getInt('minimum_seconds');
$minimum_minutes = $input->getInt('minimum_minutes');
$minimum_hours = $input->getInt('minimum_hours');
if ($input->has('different_billing_time')) {
$different_billing_time = 1;
$seconds = $input->getInt('seconds');
$minutes = $input->getInt('minutes');
$hours = $input->getInt('hours');
}
$hourly_rate = round($input->getInt('hourly_rate'), 2);
$subtotal = Shared::calculateThings(
$input->get('prestation_type'),
$hours,
$minutes,
$seconds,
$hourly_rate,
$flat_fee,
$minimum_cost,
);
}
$subtype = $prestatie ? $input->getInt('prestation_type') : $input->getInt('cost_type');
assertType('int', $subtype);
assertType('float', $flat_fee);
assertType('float', $minimum_cost);
}