1 | <?php |
||
13 | class LoadTranslationsFromFiles extends Command |
||
14 | { |
||
15 | /** |
||
16 | * The name and signature of the console command. |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $signature = 'trans-db:load {locale}'; |
||
21 | |||
22 | /** |
||
23 | * The console command description. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $description = 'Loads the translations from file into the DB for a given locale'; |
||
28 | |||
29 | /** |
||
30 | * The Laravel File Loader. |
||
31 | * |
||
32 | * @var FileLoader |
||
33 | */ |
||
34 | protected $laravelLoader; |
||
35 | |||
36 | /** |
||
37 | * Translation repository. |
||
38 | * |
||
39 | * @var TranslationRepository |
||
40 | */ |
||
41 | protected $translationRepository; |
||
42 | |||
43 | /** |
||
44 | * Laravel Filesystem. |
||
45 | * |
||
46 | * @var Filesystem |
||
47 | */ |
||
48 | protected $filesystem; |
||
49 | |||
50 | /** |
||
51 | * The locale. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $locale; |
||
56 | |||
57 | /** |
||
58 | * Create a new command instance. |
||
59 | * |
||
60 | * @param Filesystem $filesystem |
||
61 | * @param TranslationRepository $translationRepository |
||
62 | */ |
||
63 | public function __construct(Filesystem $filesystem, TranslationRepository $translationRepository) |
||
72 | |||
73 | /** |
||
74 | * Execute the console command. |
||
75 | * |
||
76 | * @return mixed |
||
77 | */ |
||
78 | public function handle() |
||
88 | |||
89 | protected function loadGroupLines() |
||
95 | |||
96 | protected function loadNameSpacedLines() |
||
103 | |||
104 | /** |
||
105 | * @param $files |
||
106 | * @param null|string $namespace |
||
107 | */ |
||
108 | protected function processFiles($files, $namespace = null) |
||
116 | |||
117 | /** |
||
118 | * Load the lines into the database. |
||
119 | * |
||
120 | * @param $lines |
||
121 | * @param $namespace |
||
122 | * @param $group |
||
123 | * @param $locale |
||
124 | */ |
||
125 | protected function loadLines($lines, $namespace, $group, $locale) |
||
144 | |||
145 | /** |
||
146 | * @param $file |
||
147 | * |
||
148 | * @return mixed |
||
149 | */ |
||
150 | protected function getGroup($file) |
||
156 | |||
157 | /** |
||
158 | * @param $file |
||
159 | * |
||
160 | * @return array |
||
161 | */ |
||
162 | protected function getLines($file) |
||
166 | |||
167 | /** |
||
168 | * @param $path |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | protected function getLangFiles($path) |
||
178 | |||
179 | /** |
||
180 | * @param $path |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | protected function getLocaleDirPath($path) |
||
188 | } |
||
189 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.