Three charged over shots at Vic police

Three men are due to face court, charged with spraying police cars with bullets outside a Melbourne fast food store.

Police allege officers took refuge at a 24-hour McDonald's restaurant after their car was peppered with bullets while on patrol in Sunbury about 3.15am on Tuesday.

It's further alleged while the officers were inside the McDonald's more shots were fired and a police patrol car was rammed.

A 26-year-old man and an 18-year-old man, both from Sunbury, have been charged with discharging a firearm, reckless conduct endangering serious injury and being a prohibited person in possession of a firearm.

The 18-year-old is also charged with armed robbery.

A 33-year-old man of no fixed address has been charged with discharging a firearm at a vehicle and reckless conduct endangering serious injury.

They remain in custody and are due to appear at the Melbourne Magistrates Court on Wednesday.