forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-7469.php
More file actions
48 lines (39 loc) · 1.56 KB
/
bug-7469.php
File metadata and controls
48 lines (39 loc) · 1.56 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
<?php declare(strict_types = 1);
namespace Bug7469;
use function PHPStan\Testing\assertType;
function doFoo() {
$line = file_get_contents('php://input');
$keys = [
'lastName',
'firstName',
'languages',
'phone',
'email',
'voiceExample',
'videoOnline',
'videoTvc',
'radio',
'birthDate',
'address',
'bankAccount',
'ic',
'invoicingAddress',
'invoicing', // to bool
'note',
];
$data = array_combine($keys, $line);
$data['languages'] = explode(',', $data['languages']);
array_walk($data['languages'], static function (&$item) {
$item = strtolower(trim($item));
});
assertType("non-empty-array<'address'|'bankAccount'|'birthDate'|'email'|'firstName'|'ic'|'invoicing'|'invoicingAddress'|'languages'|'lastName'|'note'|'phone'|'radio'|'videoOnline'|'videoTvc'|'voiceExample', mixed>&hasOffsetValue('languages', non-empty-list<lowercase-string>)", $data);
$data['videoOnline'] = normalizePrice($data['videoOnline']);
$data['videoTvc'] = normalizePrice($data['videoTvc']);
$data['radio'] = normalizePrice($data['radio']);
$data['invoicing'] = $data['invoicing'] === 'ANO';
assertType("non-empty-array<'address'|'bankAccount'|'birthDate'|'email'|'firstName'|'ic'|'invoicing'|'invoicingAddress'|'languages'|'lastName'|'note'|'phone'|'radio'|'videoOnline'|'videoTvc'|'voiceExample', mixed>&hasOffsetValue('invoicing', bool)&hasOffsetValue('languages', non-empty-list<lowercase-string>)&hasOffsetValue('radio', mixed)&hasOffsetValue('videoOnline', mixed)&hasOffsetValue('videoTvc', mixed)", $data);
}
function normalizePrice($value)
{
return $value;
}