1717use PHPSemVerChecker \Operation \FunctionParameterTypingAdded ;
1818use PHPSemVerChecker \Operation \FunctionParameterTypingRemoved ;
1919use PHPSemVerChecker \Operation \FunctionRemoved ;
20+ use PHPSemVerChecker \Operation \FunctionRenamedCaseOnly ;
2021use PHPSemVerChecker \Registry \Registry ;
2122use PHPSemVerChecker \Report \Report ;
2223
@@ -35,28 +36,62 @@ public function analyze(Registry $registryBefore, Registry $registryAfter)
3536 {
3637 $ report = new Report ();
3738
38- $ keysBefore = array_keys ($ registryBefore ->data ['function ' ]);
39- $ keysAfter = array_keys ($ registryAfter ->data ['function ' ]);
40- $ added = array_diff ($ keysAfter , $ keysBefore );
41- $ removed = array_diff ($ keysBefore , $ keysAfter );
42- $ toVerify = array_intersect ($ keysBefore , $ keysAfter );
39+
40+ $ functionsBefore = $ registryBefore ->data ['function ' ];
41+ $ functionsAfter = $ registryAfter ->data ['function ' ];
42+
43+ $ functionsBeforeKeyed = [];
44+ $ filesBeforeKeyed = [];
45+ foreach ($ functionsBefore as $ key => $ functionBefore )
46+ {
47+ $ functionsBeforeKeyed [strtolower ($ functionBefore ->name )] = $ functionBefore ;
48+ $ filesBeforeKeyed [strtolower ($ functionBefore ->name )] = $ registryBefore ->mapping ['function ' ][$ key ];
49+ }
50+
51+ $ functionsAfterKeyed = [];
52+ $ filesAfterKeyed = [];
53+ foreach ($ functionsAfter as $ key => $ functionAfter )
54+ {
55+ $ functionsAfterKeyed [strtolower ($ functionAfter ->name )] = $ functionAfter ;
56+ $ filesAfterKeyed [strtolower ($ functionAfter ->name )] = $ registryAfter ->mapping ['function ' ][$ key ];
57+ }
58+
59+ $ functionNamesBefore = array_keys ($ functionsBeforeKeyed );
60+ $ functionNamesAfter = array_keys ($ functionsAfterKeyed );
61+ $ added = array_diff ($ functionNamesAfter , $ functionNamesBefore );
62+ $ removed = array_diff ($ functionNamesBefore , $ functionNamesAfter );
63+ $ toVerify = array_intersect ($ functionNamesBefore , $ functionNamesAfter );
4364
4465 foreach ($ removed as $ key ) {
45- $ fileBefore = $ registryBefore -> mapping [ ' function ' ] [$ key ];
46- $ functionBefore = $ registryBefore -> data [ ' function ' ] [$ key ];
66+ $ fileBefore = $ filesBeforeKeyed [$ key ];
67+ $ functionBefore = $ functionsBeforeKeyed [$ key ];
4768
4869 $ data = new FunctionRemoved ($ fileBefore , $ functionBefore );
4970 $ report ->addFunction ($ data );
5071 }
5172
5273 foreach ($ toVerify as $ key ) {
53- $ fileBefore = $ registryBefore -> mapping [ ' function ' ] [$ key ];
54- $ functionBefore = $ registryBefore -> data [ ' function ' ] [$ key ];
55- $ fileAfter = $ registryAfter -> mapping [ ' function ' ] [$ key ];
56- $ functionAfter = $ registryAfter -> data [ ' function ' ] [$ key ];
74+ $ fileBefore = $ filesBeforeKeyed [$ key ];
75+ $ functionBefore = $ functionsBeforeKeyed [$ key ];
76+ $ fileAfter = $ filesAfterKeyed [$ key ];
77+ $ functionAfter = $ functionsAfterKeyed [$ key ];
5778
5879 // Leave non-strict comparison here
5980 if ($ functionBefore != $ functionAfter ) {
81+
82+ // Check if the name of the interface has changed case.
83+ // If we entered this section then the normalized names (lowercase) were equal.
84+ if ($ functionBefore ->name !== $ functionAfter ->name ) {
85+ $ report ->addFunction (
86+ new FunctionRenamedCaseOnly (
87+ $ fileBefore ,
88+ $ functionBefore ,
89+ $ fileAfter ,
90+ $ functionAfter
91+ )
92+ );
93+ }
94+
6095 $ signatureResult = Signature::analyze ($ functionBefore ->getParams (), $ functionAfter ->getParams ());
6196
6297 $ changes = [
0 commit comments