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 | 24 | public function register(Plates\Engine $plates) { |
|
11 | 24 | $c = $plates->getContainer(); |
|
12 | |||
13 | 24 | $c->wrap('renderTemplate.factories', function($factories, $c) { |
|
14 | 24 | $default_layout_path = $c->get('config')['default_layout_path']; |
|
15 | 24 | if ($default_layout_path) { |
|
16 | 12 | $factories[] = DefaultLayoutRenderTemplate::factory($default_layout_path); |
|
17 | } |
||
18 | 24 | $factories[] = LayoutRenderTemplate::factory(); |
|
19 | 24 | return $factories; |
|
20 | 24 | }); |
|
21 | |||
22 | 24 | $plates->defineConfig(['default_layout_path' => null]); |
|
0 ignored issues
–
show
|
|||
23 | 24 | $plates->pushComposers(function($c) { |
|
0 ignored issues
–
show
The method
pushComposers does not exist on object<League\Plates\Engine> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when 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...
|
|||
24 | 24 | return ['layoutSections.sections' => sectionsCompose()]; |
|
25 | 24 | }); |
|
26 | 24 | $plates->addFuncs(function($c) { |
|
0 ignored issues
–
show
The method
addFuncs does not exist on object<League\Plates\Engine> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when 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...
|
|||
27 | 24 | $template_args = RenderContext\assertTemplateArgsFunc(); |
|
28 | 24 | $one_arg = RenderContext\assertArgsFunc(1); |
|
29 | |||
30 | return [ |
||
31 | 24 | 'layout' => [layoutFunc(), $template_args], |
|
32 | 24 | 'section' => [sectionFunc(), RenderContext\assertArgsFunc(1, 1)], |
|
33 | 24 | 'start' => [startFunc(), $one_arg], |
|
34 | 24 | 'push' => [startFunc(START_APPEND), $one_arg], |
|
35 | 24 | 'unshift' => [startFunc(START_PREPEND), $one_arg], |
|
36 | ]; |
||
37 | 24 | }); |
|
38 | 24 | } |
|
39 | } |
||
40 |
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: