Fix issue where PHP 5.3 or earlier doesn't allow using $this inside closure