The Prophet ﷺ said, "Fasting is a shield. When any of you is fasting, let him not speak indecently or behave foolishly. If someone tries to fight him or insult him, let him say, 'I am fasting, I am fasting.'"
أن النبي ﷺ قال: الصيام جنة، فإذا كان أحدكم صائما فلا يرفث ولا يجهل. فإن امرؤ قاتله أو شاتمه فليقل: إني صائم، إني صائم.
Malik narrated it in his chapter on fasting (59) from Abu Zinad, from Araj, from Abu Hurairah, as mentioned. Bukhari narrated it in his chapter on fasting (1891) through Malik, and Muslim (1151) through another route from Sufyan bin Uyayna, from Abu Zinad, with the same wording.His saying, "let him say, I am fasting," means to say it out loud and openly, and not to engage with the other person, so that the reward of his fast is not nullified. There is no need for the interpretation mentioned by Khattabi and others, that he should say it to himself, meaning so that he himself knows he is fasting.Among the benefits of this statement is that it reminds him of his own fasting, and it also reminds his opponent that he is fasting.