1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | namespace Nip\View\Extensions\Helpers; |
||||||
6 | |||||||
7 | use Nip\View\Helpers\DoctypeHelper; |
||||||
8 | |||||||
9 | /** |
||||||
10 | * Trait HasHelpersTrait. |
||||||
11 | * |
||||||
12 | * @method hasHelper($name) |
||||||
13 | * @method getHelper($name) |
||||||
14 | * @method DoctypeHelper Doctype() |
||||||
15 | * @method Helpers\View\Breadcrumbs Breadcrumbs() |
||||||
16 | * @method Helpers\View\Flash Flash() |
||||||
17 | * @method Helpers\View\FacebookMeta FacebookMeta() |
||||||
18 | * @method Helpers\View\GoogleAnalytics GoogleAnalytics() |
||||||
19 | * @method Helpers\View\HTML HTML() |
||||||
20 | * @method Helpers\View\Messages Messages() |
||||||
21 | * @method Helpers\View\Meta Meta() |
||||||
22 | * @method Helpers\View\Paginator Paginator() |
||||||
23 | * @method Helpers\View\Scripts Scripts() |
||||||
24 | * @method Helpers\View\Stylesheets Stylesheets() |
||||||
25 | * @method Helpers\View\TinyMCE TinyMCE() |
||||||
26 | * @method Helpers\View\Url Url() |
||||||
27 | * @method Helpers\View\GoogleDFP GoogleDFP() |
||||||
28 | */ |
||||||
29 | trait HasHelpersTrait |
||||||
30 | { |
||||||
31 | public function addHelpersExtension() |
||||||
32 | { |
||||||
33 | 11 | $this->loadExtension(new HelpersExtension()); |
|||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
34 | } |
||||||
35 | 11 | ||||||
36 | 11 | /** |
|||||
37 | * {@inheritDoc} |
||||||
38 | */ |
||||||
39 | public function getFunction($name) |
||||||
40 | { |
||||||
41 | $this->initFunctionHelper($name); |
||||||
42 | |||||||
43 | return parent::getFunction($name); |
||||||
44 | } |
||||||
45 | |||||||
46 | /** |
||||||
47 | * @return mixed |
||||||
48 | */ |
||||||
49 | protected function initFunctionHelper($name) |
||||||
50 | { |
||||||
51 | if ($this->doesFunctionExist($name)) { |
||||||
0 ignored issues
–
show
It seems like
doesFunctionExist() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
52 | return; |
||||||
53 | } |
||||||
54 | if (false === $this->hasHelper($name)) { |
||||||
55 | return; |
||||||
56 | } |
||||||
57 | $this->registerFunction($name, function () use ($name) { |
||||||
0 ignored issues
–
show
It seems like
registerFunction() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
58 | return $this->getHelper($name); |
||||||
59 | }); |
||||||
60 | } |
||||||
61 | } |
||||||
62 |