1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of template |
||
5 | * |
||
6 | * For the full copyright and license information, please view the LICENSE |
||
7 | * file that was distributed with this source code. |
||
8 | */ |
||
9 | |||
10 | declare(strict_types=1); |
||
11 | |||
12 | namespace Slick\Template\UserInterface; |
||
13 | |||
14 | use Psr\Http\Message\ResponseInterface; |
||
15 | use Slick\Di\Definition\Attributes\Autowire; |
||
16 | use Slick\Http\Message\Response; |
||
17 | use Slick\Template\TemplateEngineInterface; |
||
18 | |||
19 | /** |
||
20 | * TemplateMethods |
||
21 | * |
||
22 | * @package Slick\Template\UserInterface |
||
23 | */ |
||
24 | trait TemplateMethods |
||
25 | { |
||
26 | protected ?TemplateEngineInterface $templateEngine = null; |
||
27 | |||
28 | #[Autowire] |
||
29 | public function withTemplateEngine(TemplateEngineInterface $templateEngine): void |
||
30 | { |
||
31 | $this->templateEngine = $templateEngine; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Renders a template with the given data, headers, and status code. |
||
36 | * |
||
37 | * @param string $template The path to the template file. |
||
38 | * @param array<string, mixed> $data The data to be passed to the template. |
||
39 | * @param array<string, string> $headers The headers to be set in the response. |
||
40 | * @param int $statusCode The status code of the response. Defaults to 200. |
||
41 | * |
||
42 | * @return ResponseInterface The rendered template as a response. |
||
43 | */ |
||
44 | protected function render( |
||
45 | string $template, |
||
46 | array $data = [], |
||
47 | array $headers = ['Content-Type' => 'text/html'], |
||
48 | int $statusCode = 200 |
||
49 | ): ResponseInterface { |
||
50 | $content = $this->templateEngine->parse($template)->process($data); |
||
0 ignored issues
–
show
|
|||
51 | return new Response($statusCode, $content, $headers); |
||
52 | } |
||
53 | } |
||
54 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.