1 | <?php |
||
27 | final class TranslationExtension extends AbstractExtension |
||
28 | { |
||
29 | /** |
||
30 | * @var TranslatorInterface|TranslatorBagInterface |
||
31 | */ |
||
32 | private $translator; |
||
33 | |||
34 | /** |
||
35 | * @var bool |
||
36 | */ |
||
37 | private $debug; |
||
38 | |||
39 | 3 | public function __construct($translator, bool $debug = false) |
|
40 | { |
||
41 | // The TranslatorInterface has been deprecated in favor of Symfony\Contracts\Translation\TranslatorInterface in sf4.2. |
||
42 | // Use this class to type hint event & remove the following condition once sf ^4.2 become the minimum supported version. |
||
43 | // @see https://github.com/symfony/symfony/blob/master/UPGRADE-4.2.md#translation |
||
44 | 3 | if (!$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) { |
|
|
|||
45 | throw new \InvalidArgumentException('Cannot deal with given translator.'); |
||
46 | } |
||
47 | |||
48 | 3 | $this->translator = $translator; |
|
49 | 3 | $this->debug = $debug; |
|
50 | 3 | } |
|
51 | |||
52 | 3 | public function getFilters(): array |
|
53 | { |
||
54 | return [ |
||
55 | 3 | new TwigFilter('desc', [$this, 'desc']), |
|
56 | 3 | new TwigFilter('meaning', [$this, 'meaning']), |
|
57 | ]; |
||
58 | } |
||
59 | |||
60 | 3 | public function getNodeVisitors(): array |
|
73 | |||
74 | public function transchoiceWithDefault(string $message, string $defaultMessage, int $count, array $arguments = [], ?string $domain = null, ?string $locale = null): string |
||
75 | { |
||
86 | |||
87 | /** |
||
88 | * @param mixed $v |
||
89 | * |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function desc($v) |
||
96 | |||
97 | /** |
||
98 | * @param mixed $v |
||
99 | * |
||
100 | * @return mixed |
||
101 | */ |
||
102 | public function meaning($v) |
||
106 | |||
107 | public function getName(): string |
||
111 | } |
||
112 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.