Skip to content

Commit 39cdf85

Browse files
committed
add sync to dead command
1 parent f03356e commit 39cdf85

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
"require-dev": {
3131
"laravel/pint": "^1.14",
3232
"nunomaduro/collision": "^8.1.1||^7.10.0",
33-
"larastan/larastan": "^2.9",
33+
"larastan/larastan": "^3.0",
3434
"orchestra/testbench": "^9.0.0||^8.22.0",
3535
"pestphp/pest": "^2.34",
3636
"pestphp/pest-plugin-arch": "^2.7",
3737
"pestphp/pest-plugin-laravel": "^2.3",
38-
"phpstan/extension-installer": "^1.3",
39-
"phpstan/phpstan-deprecation-rules": "^1.1",
40-
"phpstan/phpstan-phpunit": "^1.3"
38+
"phpstan/extension-installer": "^1.4",
39+
"phpstan/phpstan-deprecation-rules": "^2.0",
40+
"phpstan/phpstan-phpunit": "^2.0"
4141
},
4242
"autoload": {
4343
"psr-4": {

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ parameters:
1010
tmpDir: build/phpstan
1111
checkOctaneCompatibility: true
1212
checkModelProperties: true
13+
noEnvCallsOutsideOfConfig: false

src/Commands/DeadCommand.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
*/
1414
class DeadCommand extends TranslatorCommand implements PromptsForMissingInput
1515
{
16-
public $signature = 'translator:dead {locale} {--driver=}';
16+
public $signature = 'translator:dead {locale} {--sync : Delete the dead keys from your driver} {--driver=}';
1717

1818
public $description = 'Display all the translation keys not found in the codebase.';
1919

2020
public function handle(): int
2121
{
2222
$locale = $this->argument('locale');
23+
$sync = (bool) $this->option('sync');
2324

2425
$translator = $this->getTranslator();
2526

@@ -43,6 +44,17 @@ public function handle(): int
4344
->all()
4445
);
4546

47+
if ($sync) {
48+
49+
$translator->deleteTranslations(
50+
locale: $locale,
51+
keys: $dead->keys()->toArray()
52+
);
53+
54+
note(count($dead).' dead translations deleted from the driver.');
55+
56+
}
57+
4658
return self::SUCCESS;
4759
}
4860
}

src/Drivers/PhpDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getTranslations(string $locale): PhpTranslations
6363
})
6464
->dot()
6565
->map(function ($value) {
66-
if (is_array($value) && empty($value)) {
66+
if (empty($value)) {
6767
return null;
6868
}
6969

0 commit comments

Comments
 (0)