Parser::expandMagicVariable should be moved into a separate class dedicated to implementation of magic words, much like CoreParserFunctions is the implementation of parser functions.
This will allow use of these magic word implementations from Parsoid.