Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

修改targetPath为Laravel 9目录结构 && 代码格式调整 #87

Merged
merged 1 commit into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Commands/Publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
/**
* Execute the console command.
*
* @return mixed
* @return void
*/
public function handle()
{
Expand All @@ -39,10 +39,11 @@ public function handle()

$sourcePath = base_path('vendor/laravel-lang/lang/locales');
$sourceJsonPath = base_path('vendor/laravel-lang/lang/locales');
$targetPath = base_path('resources/lang/');
$targetPath = base_path('lang');

if (!is_dir($targetPath) && !mkdir($targetPath)) {
return $this->error('The lang path "resources/lang/" does not exist or not writable.');
$this->error('The lang path "lang" does not exist or not writable.');
return;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->error 的return type为void

}

$files = [];
Expand Down Expand Up @@ -100,11 +101,11 @@ public function handle()
$files = implode(' ', $files);
$targetPath = escapeshellarg($targetPath);
$command = "cp -r{$force} {$files} {$targetPath}";
$process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process($command);
$process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process([$command]);

$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
return $this->error(trim($buffer));
$this->error(trim($buffer));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'return' is unnecessary as the last statement in a function

}
});

Expand Down
8 changes: 4 additions & 4 deletions src/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class FileLoader extends LaravelTranslationFileLoader
* Create a new file loader instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param array $path
* @param array $paths
* @param string $path
* @param array $paths
*/
public function __construct(Filesystem $files, $path, $paths = [])
public function __construct(Filesystem $files, string $path, array $paths = [])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent的$path参数类型为string

{
$this->paths = $paths;

Expand Down Expand Up @@ -64,7 +64,7 @@ public function load($locale, $group, $namespace = null)
*
* @return array
*/
protected function loadPath($path, $locale, $group)
protected function loadPath($path, $locale, $group): array
{
$result = parent::loadPath($path, $locale, $group);

Expand Down
4 changes: 2 additions & 2 deletions src/TranslationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function registerLoader()

if ($this->inLumen) {
$this->app['path.lang'] = base_path('vendor/laravel/lumen-framework/resources/lang');
array_push($paths, base_path('resources/lang/'));
$paths[] = base_path('lang');
}

$loader = new FileLoader($app['files'], $app['path.lang'], $paths);
Expand All @@ -77,7 +77,7 @@ protected function registerCommands()
*
* @return array
*/
public function provides()
public function provides(): array
{
return array_merge(parent::provides(), [PublishCommand::class]);
}
Expand Down