File tree Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Expand file tree Collapse file tree 4 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ parameters:
1010 tmpDir: build/phpstan
1111 checkOctaneCompatibility: true
1212 checkModelProperties: true
13+ noEnvCallsOutsideOfConfig: false
Original file line number Diff line number Diff line change 1313 */
1414class 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}
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments