-
Notifications
You must be signed in to change notification settings - Fork 568
Expand file tree
/
Copy pathbug-9907.php
More file actions
34 lines (29 loc) · 831 Bytes
/
bug-9907.php
File metadata and controls
34 lines (29 loc) · 831 Bytes
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
<?php declare(strict_types = 1);
namespace Bug9907Rule;
class Demo
{
/**
* @phpstan-param array{street: string, city: string} $address1
* @phpstan-param array{street: string, city: string} $address2
*
* @phpstan-return array{
* street?: array{change_to: string},
* city?: array{change_to: string},
* variation_count?: int<1, max>
* }
*/
public function diffAddresses(array $address1, array $address2): array
{
$addressDifference = array_diff_assoc($address1, $address2);
$differenceDetails = [];
foreach ($addressDifference as $name => $differenceValue) {
$differenceDetails[$name] = [
'change_to' => $differenceValue,
];
}
if (!empty(count($differenceDetails))) {
$differenceDetails['variation_count'] = count($differenceDetails);
}
return $differenceDetails;
}
}