pingpong-labs/widget

PHP 5.3 compatibility

Closed this issue · 4 comments

The composer.json shows that the minimum required version is 5.3.0 but in Widget::registerBlade() it is accessing $this inside a closure which does not work in PHP 5.3

Here is what I changed it to. Note, I also took advantage of the createMatcher() method

    protected function registerBlade($name)
    {
        $this->blade->extend(function($view, $compiler) use ($name)
        {
            $pattern = $compiler->createMatcher($name);
            $replace = '$1<?php echo Widget::' . $name . '$2; ?>';

            return preg_replace($pattern, $replace, $view);
        });
    }

Can you incorporate this change so that it works on PHP 5.3?

Hi, few days ago I was also thinking the same thing. However, I have not had time to update my package. Thank you for your advice. I will update this package immediately.

Note, all laravel components version 4.2. * Now at least have to use php 5.4+. I also plan to implement it in my package.

Thanks for getting that in so quickly! Will a new tagged version be released soon? In the meantime I can use dev-master but a tagged version would be nice to have.

Done. New version 1.0.3. Have fun!