When we perpend $ in any variable then it become Variable variable (Variable vars) like $$name
Check this reference for Variable variable.
https://www.php.net/manual/en/language.variables.variable.php
Here $this->$key
will become Variable var because it is about public/private/protected variable of class.
So {} in $this->{$key}
will set $key vars variable of class