Changed a line to make sure that PHPStorm can look ahead and know what type the result is. It's a little tedious, but it looks as nice as it gets.