The law was challenged in response to raids in inner Johannesburg seemingly targeting illegal immigrants and the highest court has pronounced itself 10 days before an election in which then mayor Herman Mashaba has campaigned on an anti-foreigner ticket