1 | <?php declare(strict_types=1); |
||
2 | /** |
||
3 | * This source file is subject to the license that is bundled with this package in the file LICENSE. |
||
4 | */ |
||
5 | |||
6 | namespace PhUml\Templates; |
||
7 | |||
8 | use Twig\Environment as Twig; |
||
0 ignored issues
–
show
|
|||
9 | use Twig\Error\LoaderError; |
||
0 ignored issues
–
show
The type
Twig\Error\LoaderError was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
10 | use Twig\Error\RuntimeError; |
||
0 ignored issues
–
show
The type
Twig\Error\RuntimeError was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
11 | use Twig\Error\SyntaxError; |
||
0 ignored issues
–
show
The type
Twig\Error\SyntaxError was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
12 | use Twig\Loader\FilesystemLoader; |
||
0 ignored issues
–
show
The type
Twig\Loader\FilesystemLoader was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
13 | use Twig\TwigFilter as Filter; |
||
0 ignored issues
–
show
The type
Twig\TwigFilter was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
14 | |||
15 | /** @noRector \Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector */ |
||
16 | class TemplateEngine |
||
17 | { |
||
18 | private readonly Twig $twig; |
||
19 | |||
20 | 41 | public function __construct(Twig $twig = null) |
|
21 | { |
||
22 | 41 | $this->twig = $twig ?? new Twig( |
|
0 ignored issues
–
show
|
|||
23 | 39 | new FilesystemLoader(__DIR__ . '/../resources/templates'), |
|
24 | 39 | ['strict_variables' => true] |
|
25 | ); |
||
26 | 41 | $this->twig->addFilter(new Filter( |
|
27 | 'whitespace', |
||
28 | 41 | static fn (string $html): ?string => preg_replace('/\s\s+/', '', $html) |
|
29 | )); |
||
30 | } |
||
31 | |||
32 | /** @param mixed[] $values */ |
||
33 | 32 | public function render(string $template, array $values): string |
|
34 | { |
||
35 | try { |
||
36 | 32 | return $this->twig->render($template, $values); |
|
37 | 1 | } catch (LoaderError | RuntimeError | SyntaxError $e) { |
|
38 | 1 | throw new TemplateFailure($e); |
|
39 | } |
||
40 | } |
||
41 | } |
||
42 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths