fix typecast so that all $str return a string.

No, we cannot typehint (string) because this would force a string to be passed - something the user may not directly be able to control.

So we typecast it for use throughout.