China’s President Xi Jinping has signed into law a controversial national security legislation for Hong Kong that Beijing says is necessary to deal with separatism and foreign interference but critics say will outlaw dissent and destroy the autonomy promised when the territory was returned to China in 1997.