instead of passing by reference, use return value and array_merge?
Also this should have doc blocks. Stuff is not commented at all in the build scripts and its pretty hard to understand sometimes.