5
5
use PHPStan \Analyser \ResultCache \ResultCacheMetaExtension ;
6
6
use function array_map ;
7
7
use function hash ;
8
+ use function ksort ;
8
9
use function serialize ;
9
10
use function sort ;
10
11
@@ -28,37 +29,34 @@ public function getKey(): string
28
29
29
30
public function getHash (): string
30
31
{
31
- return hash ('sha256 ' , serialize ([
32
- 'parameters ' => array_map (
33
- static fn (ParameterDefinition $ parameter ): array => [
34
- 'name ' => $ parameter ->getKey (),
35
- 'value ' => $ parameter ->getValue (),
32
+ $ services = $ parameters = [];
33
+
34
+ foreach ($ this ->parameterMap ->getParameters () as $ parameter ) {
35
+ $ parameters [$ parameter ->getKey ()] = $ parameter ->getValue ();
36
+ }
37
+ ksort ($ parameters );
38
+
39
+ foreach ($ this ->serviceMap ->getServices () as $ service ) {
40
+ $ serviceTags = array_map (
41
+ static fn (ServiceTag $ tag ) => [
42
+ 'name ' => $ tag ->getName (),
43
+ 'attributes ' => $ tag ->getAttributes (),
36
44
],
37
- $ this ->parameterMap ->getParameters (),
38
- ),
39
- 'services ' => array_map (
40
- static function (ServiceDefinition $ service ): array {
41
- $ serviceTags = array_map (
42
- static fn (ServiceTag $ tag ) => [
43
- 'name ' => $ tag ->getName (),
44
- 'attributes ' => $ tag ->getAttributes (),
45
- ],
46
- $ service ->getTags (),
47
- );
48
- sort ($ serviceTags );
49
-
50
- return [
51
- 'id ' => $ service ->getId (),
52
- 'class ' => $ service ->getClass (),
53
- 'public ' => $ service ->isPublic () ? 'yes ' : 'no ' ,
54
- 'synthetic ' => $ service ->isSynthetic () ? 'yes ' : 'no ' ,
55
- 'alias ' => $ service ->getAlias (),
56
- 'tags ' => $ serviceTags ,
57
- ];
58
- },
59
- $ this ->serviceMap ->getServices (),
60
- ),
61
- ]));
45
+ $ service ->getTags (),
46
+ );
47
+ sort ($ serviceTags );
48
+
49
+ $ services [$ service ->getId ()] = [
50
+ 'class ' => $ service ->getClass (),
51
+ 'public ' => $ service ->isPublic () ? 'yes ' : 'no ' ,
52
+ 'synthetic ' => $ service ->isSynthetic () ? 'yes ' : 'no ' ,
53
+ 'alias ' => $ service ->getAlias (),
54
+ 'tags ' => $ serviceTags ,
55
+ ];
56
+ }
57
+ ksort ($ services );
58
+
59
+ return hash ('sha256 ' , serialize (['parameters ' => $ parameters , 'services ' => $ services ]));
62
60
}
63
61
64
62
}
0 commit comments