Anas bin Malik reported,

A funeral procession passed by the Prophet ﷺ, and the deceased was spoken of favorably. He said, "It is confirmed."Then another funeral procession passed by him, and the deceased was spoken of unfavorably. He said, "It is confirmed."Someone asked, "Messenger of Allah, you said about this one 'It is confirmed,' and about that one 'It is confirmed.'"He replied, "It is the testimony of the people. The believers are Allah's witnesses on earth."

Ibn Majah 1491

Sahih

حدثنا أحمد بن عبدة حدثنا حماد بن زيد عن ثابت

عن أنس بن مالك قال

مر على النبي ﷺ بجنازة فأثني عليها خيرا فقال وجبت ثم مر عليه بجنازة فأثني عليها شرا فقال وجبت فقيل يا رسول الله قلت لهذه وجبت ولهذه وجبت فقال شهادة القوم والمؤمنون شهود الله في الأرض

ابن ماجه 1491صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Funerals
Chapter
Praising the deceased
Numbering
Darussalam 1491
Ibn Majah 1491