Government plans to cut subsidies for solar panels on homes have been ruled legally flawed by the High Court.