From d5a86bfa4c5cdc1c6e2c49441fe0da887094d705 Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Wed, 28 Feb 2024 00:06:19 +0530 Subject: [PATCH 1/7] Update dependencies, add Psalm and PHP-CS-Fixer --- .github/workflows/psalm.yml | 32 ++++++++++++++++++ .github/workflows/style.yml | 42 +++++++++--------------- .github/workflows/test.yml | 21 ++---------- .gitignore | 2 ++ .php-cs-fixer.php | 39 ++++++++++++++++++++++ README.md | 6 ++-- composer.json | 15 ++++++--- psalm-baseline.xml | 35 ++++++++++++++++++++ psalm.xml | 24 ++++++++++++++ src/Commands/FindMissingTranslations.php | 1 - 10 files changed, 164 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/psalm.yml create mode 100644 .php-cs-fixer.php create mode 100644 psalm-baseline.xml create mode 100644 psalm.xml diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..2d832ed --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,32 @@ +name: Psalm + +on: + push: + paths: + - '**.php' + - 'psalm*' + +jobs: + psalm: + name: psalm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + coverage: none + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + + - name: Run composer install + run: composer install -n --prefer-dist + + - name: Run Psalm + run: composer psalm:ci diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index ecb80e0..f247c56 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -1,37 +1,27 @@ -name: Test +name: Check & fix styling -on: [push] +on: + push: + paths: + - '**.php' + - '.composer.lock' + - '.php_cs' + - '.github/workflows/php-cs-fixer.yml' jobs: - test: - + style: runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - php: [ 7.1 ] - dependency-version: [prefer-lowest, prefer-stable] - - name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v1 + - name: Fix style + uses: docker://oskarstark/php-cs-fixer-ga with: - php-version: ${{ matrix.php }} - coverage: none + args: --config=.php-cs-fixer.php --allow-risky=yes - - name: Cache dependencies - uses: actions/cache@v1 + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - - - name: Install dependencies - run: | - composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest - - name: Execute tests - run: composer test + commit_message: Fix styling diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db26acc..169b2a1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,28 +10,13 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - php: [8.3, 8.0, 7.4] - laravel: [9.*, 8.*, 7.*, 6.*, 5.8.*] + php: [8.3, 8.2, 8.1, 8.0, 7.4] + laravel: [10.*, 9.*] dependency-version: [prefer-lowest] os: [ubuntu-latest] - include: - - laravel: 9.* - testbench: 7.* - - laravel: 8.* - testbench: 6.* - - laravel: 7.* - testbench: 5.* - - laravel: 6.* - testbench: 4.* - - laravel: 5.8.* - testbench: 3.8.* exclude: - php: 7.4 - laravel: 9.* - - php: 8.0 - laravel: 5.8.* - - php: 8.3 - laravel: 5.8.* + laravel: 10.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index 987e2a2..71bf3a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ composer.lock vendor + +.phpunit.result.cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..276c398 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,39 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'method' => 'one', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); diff --git a/README.md b/README.md index abc2aad..c00af8d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Find missing Laravel Translations Artisan command to find missing translations. -It takes a basic locale and find missing keys/translations in other locales. +It takes a basic locale and finds missing keys/translations in other locales.

Package logo

@@ -15,7 +15,7 @@ composer require diglabby/laravel-find-missing-translations --dev ``` ## Usage -Use default locate as base and default Laravel's path to lang files: +Use default locate as base and default Laravel’s path to lang files: ```sh php artisan translations:missing ``` @@ -39,4 +39,4 @@ composer test ## Thanks -Inspired by [VetonMuhaxhiri/Laravel-find-missing-translations](https://github.com/VetonMuhaxhiri/Laravel-find-missing-translations) \ No newline at end of file +Inspired by [VetonMuhaxhiri/Laravel-find-missing-translations](https://github.com/VetonMuhaxhiri/Laravel-find-missing-translations) diff --git a/composer.json b/composer.json index 1c00217..2e854c0 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,15 @@ "translation" ], "require": { - "php": "^7.1.3 || ^8.0", - "illuminate/console": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0", - "illuminate/support": "^5.8 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "php": "^7.4 || ^8.0", + "illuminate/console": "^9.0 || ^10.0 || ^11.0", + "illuminate/support": "^9.0 || ^10.0 || ^11.0" }, "require-dev": { - "orchestra/testbench": "^3.8 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6" + "friendsofphp/php-cs-fixer": "^3.50", + "orchestra/testbench": "^7.0 || ^8.0 || ^9.0", + "phpunit/phpunit": "^9.6 || ^10.5 || ^11.0", + "vimeo/psalm": "^5.22" }, "minimum-stability": "dev", "prefer-stable": true, @@ -40,6 +42,9 @@ } }, "scripts": { + "cs": "vendor/bin/php-cs-fixer fix --allow-risky=yes", + "psalm": "vendor/bin/psalm", + "psalm:ci": "vendor/bin/psalm --shepherd", "test": "vendor/bin/phpunit" } } diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 0000000..59d83f5 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + option('dir')]]> + option('dir')]]> + option('dir')]]> + + + + + option('dir')]]> + option('dir')]]> + option('dir')]]> + option('dir')]]> + + + + + + + + + + option('base')]]> + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..b71cbbe --- /dev/null +++ b/psalm.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/src/Commands/FindMissingTranslations.php b/src/Commands/FindMissingTranslations.php index dbe2f5c..58b485b 100644 --- a/src/Commands/FindMissingTranslations.php +++ b/src/Commands/FindMissingTranslations.php @@ -127,7 +127,6 @@ private function getFilenames(string $directory): array { $fileNames = []; - /** @var \Symfony\Component\Finder\SplFileInfo[] $filesInFolder */ $filesInFolder = File::files($directory); foreach ($filesInFolder as $fileInfo) { From d9183cdb6598a794ada7c31c9183d8b58240b740 Mon Sep 17 00:00:00 2001 From: alies-dev Date: Tue, 27 Feb 2024 18:36:54 +0000 Subject: [PATCH 2/7] Fix styling --- .php-cs-fixer.cache | 1 + src/Commands/FindMissingTranslations.php | 7 +++++-- src/ServiceProvider.php | 4 +++- tests/Commands/FindMissingTranslationsTest.php | 5 +++-- tests/TestCase.php | 4 +++- 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 .php-cs-fixer.cache diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 0000000..9c40338 --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.3.3","version":"3.50.0","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":{"elements":["arrays"]},"phpdoc_scalar":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Commands\/FindMissingTranslations.php":"1688121ea0ea3276de50cbb252f3717c","src\/ServiceProvider.php":"bab87b2ee50fc729ed9a84efe9a50a1c","tests\/Commands\/unsync_lang_files\/be\/a.php":"811aeeebc61213942ff24a4a7f580c59","tests\/Commands\/unsync_lang_files\/en\/a.php":"2734fdc4aae29bc89257756aa17bd510","tests\/Commands\/FindMissingTranslationsTest.php":"8d631c1c6036779e61b9d199a3a71798","tests\/Commands\/sync_lang_files\/be\/a.php":"7d556c99706937d5e759d1ffd23241ee","tests\/Commands\/sync_lang_files\/en\/a.php":"0e8f4b28e5ee5db0177331a8890dbd74","tests\/TestCase.php":"3b71d4802096f81f56050e2ad22acc8d"}} \ No newline at end of file diff --git a/src/Commands/FindMissingTranslations.php b/src/Commands/FindMissingTranslations.php index 58b485b..7477dd5 100644 --- a/src/Commands/FindMissingTranslations.php +++ b/src/Commands/FindMissingTranslations.php @@ -1,4 +1,6 @@ -comment("Comparing translations in {$languageFile}.", 'v'); $this->error("{$languageName}/{$languageFile} file is missing.", 'q'); + continue; } $secondLanguageFile = File::getRequire("{$languagePath}/{$languageFile}"); diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index febb1ef..dc789cb 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -1,4 +1,6 @@ - Date: Wed, 28 Feb 2024 00:09:07 +0530 Subject: [PATCH 3/7] Add missing pairs for testing --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 169b2a1..bcd40dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,11 @@ jobs: laravel: [10.*, 9.*] dependency-version: [prefer-lowest] os: [ubuntu-latest] + include: + - laravel: 10.* + testbench: 8.* + - laravel: 9.* + testbench: 7.* exclude: - php: 7.4 laravel: 10.* From d4b749322ba207e8a73811f61291ed5565b00d9b Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Wed, 28 Feb 2024 00:12:07 +0530 Subject: [PATCH 4/7] Remove PHP-CS-Fixer cache --- .php-cs-fixer.cache | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .php-cs-fixer.cache diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache deleted file mode 100644 index 9c40338..0000000 --- a/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.3.3","version":"3.50.0","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":{"elements":["arrays"]},"phpdoc_scalar":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Commands\/FindMissingTranslations.php":"1688121ea0ea3276de50cbb252f3717c","src\/ServiceProvider.php":"bab87b2ee50fc729ed9a84efe9a50a1c","tests\/Commands\/unsync_lang_files\/be\/a.php":"811aeeebc61213942ff24a4a7f580c59","tests\/Commands\/unsync_lang_files\/en\/a.php":"2734fdc4aae29bc89257756aa17bd510","tests\/Commands\/FindMissingTranslationsTest.php":"8d631c1c6036779e61b9d199a3a71798","tests\/Commands\/sync_lang_files\/be\/a.php":"7d556c99706937d5e759d1ffd23241ee","tests\/Commands\/sync_lang_files\/en\/a.php":"0e8f4b28e5ee5db0177331a8890dbd74","tests\/TestCase.php":"3b71d4802096f81f56050e2ad22acc8d"}} \ No newline at end of file From 0e0524a6f97ffbd7fec12bf4811bc2e76e8b64dc Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Wed, 28 Feb 2024 00:12:19 +0530 Subject: [PATCH 5/7] Ignore PHP-CS-Fixer cache --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 71bf3a9..a7a2b04 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock vendor .phpunit.result.cache +.php-cs-fixer.cache From d5bb02bb2f1541885a5a68b4c57e30386076ac0b Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Wed, 28 Feb 2024 00:14:32 +0530 Subject: [PATCH 6/7] Exclude PHP7 and L9 --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bcd40dd..9c8b5f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,8 @@ jobs: exclude: - php: 7.4 laravel: 10.* + - php: 7.4 + laravel: 9.* name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} From eaf1b8c86d1e8902a03eabf80064c06d8d7db6fb Mon Sep 17 00:00:00 2001 From: Alies Lapatsin Date: Wed, 28 Feb 2024 00:17:03 +0530 Subject: [PATCH 7/7] Exclude PHP8.0 and L10 --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9c8b5f2..3e3958f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,8 @@ jobs: - laravel: 9.* testbench: 7.* exclude: + - php: 8.0 + laravel: 10.* - php: 7.4 laravel: 10.* - php: 7.4