Str rewrite related modifications

Necessary changes required for [PR # 1118](https://github.com/laravel/framework/pull/1118) in laravel/framework.