@@ -65,6 +65,7 @@ public function evaluate($other, $description = '', $returnResult = false)
65
65
$ this ->subset = $ this ->toArray ($ this ->subset );
66
66
67
67
$ intersect = $ this ->arrayIntersectRecursive ($ other , $ this ->subset );
68
+
68
69
$ this ->deepSort ($ intersect );
69
70
$ this ->deepSort ($ this ->subset );
70
71
@@ -131,9 +132,13 @@ private function toArray(iterable $other): array
131
132
132
133
private function isAssociative (array $ array ): bool
133
134
{
134
- return \array_reduce (\array_keys ($ array ), function (bool $ carry , $ key ): bool {
135
- return $ carry || \is_string ($ key );
136
- }, false );
135
+ return \array_reduce (
136
+ \array_keys ($ array ),
137
+ function (bool $ carry , $ key ): bool {
138
+ return $ carry || \is_string ($ key );
139
+ },
140
+ false
141
+ );
137
142
}
138
143
139
144
private function compare ($ first , $ second ): bool
@@ -149,6 +154,8 @@ private function deepSort(array &$array): void
149
154
}
150
155
}
151
156
157
+ unset($ value );
158
+
152
159
if ($ this ->isAssociative ($ array )) {
153
160
\ksort ($ array );
154
161
} else {
@@ -192,10 +199,7 @@ private function arrayIntersectRecursive(array $array, array $subset): array
192
199
}
193
200
} else {
194
201
foreach ($ subset as $ key => $ subset_value ) {
195
- if (!\is_array ($ subset_value ) && $ this ->compare (
196
- $ subset_value ,
197
- $ array_value
198
- )) {
202
+ if (!\is_array ($ subset_value ) && $ this ->compare ($ subset_value , $ array_value )) {
199
203
$ intersect [$ key ] = $ array_value ;
200
204
201
205
break ;
0 commit comments