I have a colleague who constantly assigns a variable and forces them to type. For example, it will declare something like this:
$this->id = (int)$this->getId();
or when returning, it will always return values ββas such:
return (int)$id;
I understand that php is a freely typed language, so I don't ask what casting does. I am really curious what benefits do this - if any - or if he just spends time and energy on it?
source
share