Avoid `(string) View::make()`

Submitted by kwoodfriend - 10 years ago

Avoid casting views to strings. If your view contains an error, casting with `(string)` will cause a less-than-helpful exception to be thrown, pertaining to throwing an exception within the view's `__toString()` method. Use `View::make()->render()` instead.

// Potentially receive "Method __toString() must not throw and exception" exception,
// instead of the view's actual exception.
$html = (string) View::make('foo', ['bar' => 'baz']);


// Use render() method instead. Your exception will not be "hidden" by __toStrings()'s
// exception restriction.
$html = View::make('foo', ['bar' => 'baz'])->render();