If we want to allow adding to this thing directly in LocalSettings, then the array does need to be defined before. So the settings file would need to contain $smwgNamespacesWithSemanticLinks = array();

Else people doing "$smwgNamespacesWithSemanticLinks[foo] = bar" will be implicitly creating an array.

In this case you can also skip the if else below and just always do the merge.