Completed
Push — master ( b3978b...8d3a7c )
by
unknown
26:09 queued 12:30
created

LayoutSections/LayoutSectionsExtension.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace League\Plates\Extension\LayoutSections;
4
5
use League\Plates;
6
use League\Plates\Extension\RenderContext;
7
8
final class LayoutSectionsExtension implements Plates\Extension
9
{
10 16
    public function register(Plates\Engine $plates) {
11 16
        $c = $plates->getContainer();
12
13 16
        $c->wrap('renderTemplate.factories', function($factories, $c) {
14 16
            $default_layout_path = $c->get('config')['default_layout_path'];
15 16
            if ($default_layout_path) {
16 16
                $factories[] = DefaultLayoutRenderTemplate::factory($default_layout_path);
17 16
            }
18 16
            $factories[] = LayoutRenderTemplate::factory();
19 16
            return $factories;
20 8
        });
21
22 16
        $plates->defineConfig(['default_layout_path' => null]);
0 ignored issues
show
Documentation Bug introduced by
The method defineConfig does not exist on object<League\Plates\Engine>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
23 16
        $plates->pushComposers(function($c) {
24 16
            return ['layoutSections.sections' => sectionsCompose()];
25 16
        });
26 16
        $plates->addFuncs(function($c) {
27 16
            $template_args = RenderContext\assertTemplateArgsFunc();
28
            $one_arg = RenderContext\assertArgsFunc(1);
29
30 16
            return [
31 16
                'layout' => [layoutFunc(), $template_args],
32 16
                'section' => [sectionFunc(), RenderContext\assertArgsFunc(1, 1)],
33 16
                'start' => [startFunc(), $one_arg],
34 16
                'push' => [startFunc(START_APPEND), $one_arg],
35
                'unshift' => [startFunc(START_PREPEND), $one_arg],
36 16
            ];
37 16
        });
38
    }
39
}
40