First you tell me what kind of dog you have?And how old is the dog?
when the dog stoped barking? did the dog stop bark to a stranger?
or stop barking to a dog? is it when it small or very old?
Did you punish your dog?(did you ever kick,hit,frighten the dog)
There are one reason because a stranger have kick,threw something at the dog.and the best thing to do is take it to the veterinarian.