EXCLUSIVE"Modern Family" star Sarah Hyland -- fearing an attack from an ex-BF -- just got some protection from a judge ... who ordered the ex to steer clear of her and her pet Maltipoo -- or go to jail.
TMZ broke the story ... Hyland went to court seeking protection from Matthew Prokop ... claiming he brutalized her physically and verbally during the past 4 years ... and allegedly threatened to make her dog disappear.
A judge issued a permanent restraining order, Monday in court ... giving Hyland all of the protections she requested. According to the order, Prokop must:
-stay 100 yards away from Hyland and her house
-not go near her job or workplace
-not own or possess a gun or ammunition
-stay 100 yards away from Hyland's dog, Barkley Bixby
-not attack, threaten or harm the dog in any way
The judge's order is in force for 3 years.