1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Facile\MongoDbBundle\Twig; |
||
6 | |||
7 | use Facile\MongoDbBundle\Services\Explain\ExplainQueryService; |
||
8 | use Twig\Extension\AbstractExtension; |
||
9 | use Twig\TwigFunction; |
||
10 | |||
11 | if (! class_exists('\Twig\Extension\AbstractExtension')) { |
||
12 | class_alias(\Twig_Extension::class, '\Twig\Extension\AbstractExtension'); |
||
0 ignored issues
–
show
|
|||
13 | } |
||
14 | |||
15 | if (! class_exists('\Twig\TwigFunction')) { |
||
16 | class_alias(\Twig_Function::class, '\Twig\TwigFunction'); |
||
0 ignored issues
–
show
The type
Twig_Function 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 ![]() |
|||
17 | } |
||
18 | |||
19 | class FacileMongoDbBundleExtension extends AbstractExtension |
||
20 | { |
||
21 | private const METHOD_DATA_TRANSATION_MAP = [ |
||
22 | 'aggregate' => 'Pipeline', |
||
23 | 'insertOne' => 'Document', |
||
24 | 'updateOne' => 'Update', |
||
25 | 'findOneAndUpdate' => 'Update', |
||
26 | 'replaceOne' => 'Replacement', |
||
27 | ]; |
||
28 | |||
29 | /** |
||
30 | * @return \Twig_SimpleFunction[] |
||
31 | */ |
||
32 | public function getFunctions() |
||
33 | { |
||
34 | return [ |
||
0 ignored issues
–
show
|
|||
35 | 1 | new TwigFunction('dataLabelTranslate', [$this, 'queryDataTranslate']), |
|
36 | new TwigFunction('isQueryExplainable', [$this, 'isQueryExplainable']), |
||
37 | 1 | ]; |
|
38 | } |
||
39 | |||
40 | public function queryDataTranslate(string $label, string $methodName): string |
||
41 | { |
||
42 | return self::METHOD_DATA_TRANSATION_MAP[$methodName] ?? $label; |
||
43 | } |
||
44 | |||
45 | public function isQueryExplainable(string $methodName): bool |
||
46 | 6 | { |
|
47 | return \in_array($methodName, ExplainQueryService::ACCEPTED_METHODS, true); |
||
48 | 6 | } |
|
49 | |||
50 | public function getName(): string |
||
51 | 12 | { |
|
52 | return 'facile_mongo_db_extesion'; |
||
53 | 12 | } |
|
54 | } |
||
55 |
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