Passing objects to Custom Control Structures in Laravel Blade-Collection of common programming errors

I can’t call member functions on objects that I pass to custom control structures in Laravel 4.1.23.

My custom control structure:

Blade::extend(function($view, $compiler){
    $pattern = $compiler->createMatcher('paginatePretty');
    $code = 
        '$1';
    return preg_replace($pattern, $code, $view);
});

My blade view code that instantiates paginatePretty:

// $articles = Articles::orderBy('created_at', 'desc')->paginate($per_page);
@paginatePretty($articles)

At compile time, I get this error:

syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';'

And the custom control structure was compiled like this:

echo ($articles)->getCurrentPage();

How can I pass an object to the custom control structure?