Replace toArray method on magic method __invoke