diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..f55d1fa --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,23 @@ +name: Check & fix styling + +on: [push] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php_cs.dist.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix styling diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..60988f5 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,38 @@ +name: run-tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [8.1] + laravel: [10.*] + dependency-version: [prefer-lowest, prefer-stable] + include: + - laravel: 10.* + testbench: 8.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 2f87cd7..0a06e95 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ /vendor composer.phar composer.lock + +.idea/ + +.phpunit.result.cache diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 0000000..2243970 --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.3.2","version":"3.48.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces_position":true,"class_definition":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_import_per_statement":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"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"}},"single_trait_insert_per_statement":true},"hashes":{"src\/Commands\/TransCommand.php":"f191d9809cd62711455870a7a5eba941","src\/Commands\/MissingCommand.php":"41b19031948fb4d35a9b914672795c32","src\/Commands\/RenameCommand.php":"2a861f52f926f5102d727a4fa899a190","src\/Commands\/ShowCommand.php":"a30aa8330a1f2129ed40f2ebd70b5ec3","src\/Commands\/FindCommand.php":"18b55503c0f8f7aadb52536dad53c716","src\/Commands\/SyncCommand.php":"1d6bde99dd25e746773a2ff4557286b2","src\/Commands\/RemoveCommand.php":"7fba053fee8b906bde17b296df34f2ff","src\/Manager.php":"d386a53b1219f38df326e2fb715bba4a","src\/LangmanServiceProvider.php":"addecf1c3978d49df3d57d8dfcabbf9a","tests\/ManagerTest.php":"80e6d703f929766c4cfe3aa29b946164","tests\/TestCase.php":"8e14293c7476b657d004956670a8dc0a","tests\/ShowCommandTest.php":"13cbe9ab443c441595fcf9d43c5f4ded","tests\/TransCommandTest.php":"1c4c20646cdf48f63cdd978aa56a594b","tests\/MissingCommandTest.php":"87a5ad2a51870949d56b74d64aaeaa6d","tests\/RemoveCommandTest.php":"695a9e3437fa3f823319b70dbea13b28","tests\/SyncCommandTest.php":"47fa049682d1652c0c8c675872a35379","tests\/Kernel.php":"05fed58b10f49d4ce757b78bf2e05288","tests\/FindCommandTest.php":"3c00233b198b6891b55b562c826a11c8","tests\/RenameCommandTest.php":"b695a36433c86ba0dfb3b2c681189414"}} \ No newline at end of file diff --git a/.php_cs.dist.php b/.php_cs.dist.php new file mode 100644 index 0000000..3de28fd --- /dev/null +++ b/.php_cs.dist.php @@ -0,0 +1,40 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline' => true, + '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/.travis.yml b/.travis.yml deleted file mode 100644 index a5142c0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: php - -php: - - 5.6 - - 7.0 - - 7.1 - -sudo: true - -install: - - travis_retry composer install --no-interaction --prefer-source diff --git a/src/Commands/FindCommand.php b/src/Commands/FindCommand.php index 73cad05..9c5577b 100644 --- a/src/Commands/FindCommand.php +++ b/src/Commands/FindCommand.php @@ -5,7 +5,6 @@ use Illuminate\Console\Command; use Illuminate\Support\Arr; use Themsaid\Langman\Manager; -use Illuminate\Support\Str; class FindCommand extends Command { diff --git a/src/Commands/MissingCommand.php b/src/Commands/MissingCommand.php index a1c9818..48fe779 100644 --- a/src/Commands/MissingCommand.php +++ b/src/Commands/MissingCommand.php @@ -96,7 +96,8 @@ private function collectValues(array $missing) foreach ($missing as $missingKey) { $values[$missingKey] = $this->ask( - "{$missingKey} translation", $this->getDefaultValue($missingKey) + "{$missingKey} translation", + $this->getDefaultValue($missingKey) ); } diff --git a/src/LangmanServiceProvider.php b/src/LangmanServiceProvider.php index 8f84e4f..bdfe320 100644 --- a/src/LangmanServiceProvider.php +++ b/src/LangmanServiceProvider.php @@ -2,8 +2,8 @@ namespace Themsaid\Langman; -use Illuminate\Support\ServiceProvider; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\ServiceProvider; class LangmanServiceProvider extends ServiceProvider { diff --git a/tests/MissingCommandTest.php b/tests/MissingCommandTest.php index 389d62f..af9c1f4 100644 --- a/tests/MissingCommandTest.php +++ b/tests/MissingCommandTest.php @@ -1,7 +1,7 @@