@@ -389,7 +389,7 @@ private function configureAliases(array $aliases)
389
389
return ;
390
390
}
391
391
392
- if ($ this ->mergeIntoArray ( $ this -> aliases , $ aliases )) {
392
+ if ($ this ->mergeNewAliasesIntoOriginalOnes ( $ aliases )) {
393
393
$ this ->resolveAliases ($ this ->aliases );
394
394
395
395
return ;
@@ -400,31 +400,28 @@ private function configureAliases(array $aliases)
400
400
}
401
401
402
402
/**
403
- * Merge source into destination.
404
- * This method has good performance:
405
- * - at empty destination
406
- * - at adding few elements into array
407
- * - at checking arrays keys intersection
408
- *
409
- * Provide only present intersect
410
- *
411
- * @param array $destination
412
403
* @param array $source
413
- * @return boolean
404
+ *
405
+ * @return bool whether any of the aliases got replaced
414
406
*/
415
- private function mergeIntoArray (array & $ destination , array & $ source )
407
+ private function mergeNewAliasesIntoOriginalOnes (array $ source )
416
408
{
417
- if (empty ($ destination )) {
418
- $ destination = $ source ;
409
+ if (empty ($ this ->aliases )) {
410
+ $ this ->aliases = $ source ;
411
+
419
412
return false ;
420
413
}
414
+
421
415
$ intersect = false ;
416
+
422
417
foreach ($ source as $ name => $ target ) {
423
- if (isset ($ destination [$ name ])) {
418
+ if (isset ($ this -> aliases [$ name ])) {
424
419
$ intersect = true ;
425
420
}
426
- $ destination [$ name ] = $ target ;
421
+
422
+ $ this ->aliases [$ name ] = $ target ;
427
423
}
424
+
428
425
return $ intersect ;
429
426
}
430
427
0 commit comments