Bulugh al-Maram 226
عَنْ أَبِي جُهَيْمِ بْنِ الْحَارِثِ - رضي الله عنه - قَالَ: قَالَ رَسُولُ اللَّهِ - صلى الله عليه وسلم: «لَوْ يَعْلَمُ الْمَارُّ بَيْنَ يَدَيِ الْمُصَلِّي مَاذَا عَلَيْهِ مِنَ الْإِثْمِ لَكَانَ أَنْ يَقِفَ أَرْبَعِينَ خَيْرًا لَهُ مِنْ أَنْ يَمُرَّ بَيْنَ يَدَيْهِ». مُتَّفَقٌ عَلَيْهِ, وَاللَّفْظُ لِلْبُخَارِيِّ. ⦗٦٨⦘ وَوَقَعَ فِي «الْبَزَّارِ» مِنْ وَجْهٍ آخَرَ: «أَرْبَعِينَ خَرِيفًا».
From Abu Juhaym ibn al-Harith, may Allah be pleased with him, who said: The Messenger of Allah ﷺ said: "If the one who passes in front of a praying person knew what sin is upon him, it would be better for him to stand for forty than to pass in front of him." Agreed upon, and the wording is al-Bukhari's. And in al-Bazzar, by another route, it came as: "forty years."