Issue #3240961 by Xiaohua Guan, yas: Fix overridden local variable $entity which is introduced as a method parameter
Closes #3240961