55use PHPStan \Analyser \ResultCache \ResultCacheMetaExtension ;
66use function array_map ;
77use function hash ;
8+ use function ksort ;
89use function serialize ;
910use function sort ;
1011
@@ -28,37 +29,34 @@ public function getKey(): string
2829
2930 public function getHash (): string
3031 {
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 (),
3644 ],
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 ]));
6260 }
6361
6462}
0 commit comments