1 | <?php |
||||
2 | |||||
3 | namespace Translation\Console\Commands; |
||||
4 | |||||
5 | use File; |
||||
6 | use Illuminate\Console\Command; |
||||
0 ignored issues
–
show
|
|||||
7 | use Illuminate\Filesystem\Filesystem; |
||||
8 | use Illuminate\View\Compilers\BladeCompiler; |
||||
0 ignored issues
–
show
The type
Illuminate\View\Compilers\BladeCompiler 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 ![]() |
|||||
9 | |||||
10 | class GettextCommand extends Command |
||||
11 | { |
||||
12 | /** |
||||
13 | * The console command name. |
||||
14 | * |
||||
15 | * @var string |
||||
16 | */ |
||||
17 | protected $name = 'translation:gettext'; |
||||
18 | |||||
19 | /** |
||||
20 | * The console command description. |
||||
21 | * |
||||
22 | * @var string |
||||
23 | */ |
||||
24 | protected $description = 'Compiles Blade templates into PHP for GNU gettext to be able to parse them'; |
||||
25 | |||||
26 | /** |
||||
27 | * Call fire function |
||||
28 | * |
||||
29 | * @return void |
||||
30 | */ |
||||
31 | public function handle() |
||||
32 | { |
||||
33 | $this->fire(); |
||||
34 | } |
||||
35 | |||||
36 | /** |
||||
37 | * Execute the console command. |
||||
38 | * |
||||
39 | * @return void |
||||
40 | */ |
||||
41 | public function fire() |
||||
42 | { |
||||
43 | // Set directories |
||||
44 | $inputPath = base_path('resources/views'); |
||||
0 ignored issues
–
show
The function
base_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
45 | $outputPath = storage_path('gettext'); |
||||
0 ignored issues
–
show
The function
storage_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | |||||
47 | // Create $outputPath or empty it if already exists |
||||
48 | if (File::isDirectory($outputPath)) { |
||||
49 | File::cleanDirectory($outputPath); |
||||
50 | } else { |
||||
51 | File::makeDirectory($outputPath); |
||||
52 | } |
||||
53 | |||||
54 | // Configure BladeCompiler to use our own custom storage subfolder |
||||
55 | $compiler = new BladeCompiler(new Filesystem, $outputPath); |
||||
56 | $compiled = 0; |
||||
57 | |||||
58 | // Get all view files |
||||
59 | $allFiles = File::allFiles($inputPath); |
||||
60 | foreach ($allFiles as $f) |
||||
61 | { |
||||
62 | // Skip not blade templates |
||||
63 | $file = $f->getPathName(); |
||||
64 | if ('.blade.php' !== substr($file, -10)) { |
||||
65 | continue; |
||||
66 | } |
||||
67 | |||||
68 | // Compile the view |
||||
69 | $compiler->compile($file); |
||||
70 | $compiled++; |
||||
71 | |||||
72 | // Rename to human friendly |
||||
73 | $human = str_replace(DIRECTORY_SEPARATOR, '-', ltrim($f->getRelativePathname(), DIRECTORY_SEPARATOR)); |
||||
74 | File::move($outputPath . DIRECTORY_SEPARATOR . md5($file), $outputPath . DIRECTORY_SEPARATOR . $human . '.php'); |
||||
75 | } |
||||
76 | |||||
77 | if ($compiled) { |
||||
78 | $this->info("$compiled files compiled."); |
||||
79 | } else { |
||||
80 | $this->error('No .blade.php files found in '.$inputPath); |
||||
81 | } |
||||
82 | } |
||||
83 | } |
||||
84 |
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