diff --git a/.editorconfig b/.editorconfig index 3969021..eb07890 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ trim_trailing_whitespace = false max_line_length = 120 [*.{yml, yaml}] -indent_size = 2 +indent_size = 4 [*.php] ij_php_align_key_value_pairs = false diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b3bb1b7..4e13c32 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,50 +1,81 @@ name: run-tests -on: [push, pull_request] +on: [ push, pull_request ] jobs: + psalm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + coverage: none + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --no-progress --no-ansi + + - name: Run Psalm + run: composer run-script psalm test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: [8.1, 8.0] - laravel: [9.*, 8.*] + php: [ 8.0, 8.1, 8.2 ] + laravel: [ 8.*, 9.*, 10.* ] include: - - laravel: 9.* - testbench: 7.* - laravel: 8.* testbench: 6.* + - laravel: 9.* + testbench: 7.* + - laravel: 10.* + testbench: 8.* + exclude: + - php: 8.0 + laravel: 10.* + + name: Laravel ${{ matrix.laravel }} with PHP ${{ matrix.php }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 - name: Laravel ${{ matrix.laravel }} with PHP ${{ matrix.php }} + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.composer/cache/files - key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - - - name: Setup PHP - uses: shivammathur/setup-php@2.9.0 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick - coverage: xdebug - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --prefer-dist --no-interaction --no-suggest - - - name: Execute psalm - run: composer psalm - - - name: Execute tests - run: composer test-coverage - - - name: Send coverage - run: bash <(curl -s https://codecov.io/bash) + - name: Setup PHP + uses: shivammathur/setup-php@2.9.0 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: xdebug + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: composer test-coverage + + - name: Send coverage + run: bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 0e93b9b..656349b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ![PHP](https://img.shields.io/badge/PHP-%E2%89%A5%208.0-blue) ![Laravel](https://img.shields.io/badge/Laravel-%E2%89%A5%208.0-orange) [![License](https://poser.pugx.org/lukasss93/laravel-larex/license)](https://packagist.org/packages/lukasss93/laravel-larex) -![Build](https://img.shields.io/github/workflow/status/Lukasss93/laravel-larex/run-tests) +![Build](https://img.shields.io/github/actions/workflow/status/Lukasss93/laravel-larex/run-tests.yml) [![Coverage](https://img.shields.io/codecov/c/github/lukasss93/laravel-larex?token=XcLU2ccFQ7)](https://codecov.io/gh/Lukasss93/laravel-larex) Laravel Larex lets you translate your whole Laravel application with a single CSV file. diff --git a/composer.json b/composer.json index 8c1630f..a7236af 100644 --- a/composer.json +++ b/composer.json @@ -24,12 +24,13 @@ "php": "^8.0", "ext-dom": "*", "ext-json": "*", - "illuminate/support": "^8.0|^9.0", + "illuminate/support": "^8.0|^9.0|^10.0", "loilo/fuse": "^6.4.6", - "spatie/laravel-collection-macros": "^7.12", - "spatie/simple-excel": "^1.13.1" + "spatie/simple-excel": "^3.0.1", + "spatie/laravel-collection-macros": "^7.12" }, "require-dev": { + "orchestra/testbench": "^6.0|^7.0|^8.0", "pestphp/pest": "^1.21", "psalm/plugin-laravel": "^2.0", "vimeo/psalm": "^4.24" diff --git a/psalm.xml b/psalm.xml index ac55d6c..c3026f0 100644 --- a/psalm.xml +++ b/psalm.xml @@ -17,8 +17,10 @@ + + + + + - - - diff --git a/src/Console/LarexRemoveCommand.php b/src/Console/LarexRemoveCommand.php index 5a4c3c4..dd5cb2f 100644 --- a/src/Console/LarexRemoveCommand.php +++ b/src/Console/LarexRemoveCommand.php @@ -64,7 +64,7 @@ public function handle(): int }); if ($force || $this->confirm("Are you sure you want to delete {$remove->count()} ".Str::plural('string', - $remove->count()).'?')) { + $remove->count()).'?')) { CsvWriter::create(csv_path())->addRows($keep->toArray()); $this->info('Removed successfully.'); diff --git a/src/Support/CsvParser.php b/src/Support/CsvParser.php index bfe36c9..a2aea0e 100644 --- a/src/Support/CsvParser.php +++ b/src/Support/CsvParser.php @@ -48,7 +48,6 @@ public function parse(bool $skipEmpty = true): array //loop rows foreach ($rows as $columns) { - //get first two columns values $group = trim($columns->get('group')); $key = trim($columns->get('key')); diff --git a/src/Support/CsvReader.php b/src/Support/CsvReader.php index c816b35..d976cb5 100644 --- a/src/Support/CsvReader.php +++ b/src/Support/CsvReader.php @@ -20,6 +20,9 @@ public static function create(string $path): self return new self($path); } + /** + * @return Collection + */ public function getHeader(): Collection { $header = $this->reader->getHeaders(); diff --git a/src/helpers.php b/src/helpers.php index 81a1f3f..1448845 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -1,5 +1,7 @@ new class() - { + 'larex.exporters.list.foo' => new class() { }, ]); diff --git a/tests/Console/LarexImportTest.php b/tests/Console/LarexImportTest.php index 9a431ae..c1418ea 100644 --- a/tests/Console/LarexImportTest.php +++ b/tests/Console/LarexImportTest.php @@ -20,8 +20,7 @@ it('does not import strings due to invalid importer', function () { config([ - 'larex.importers.list.foo' => new class() - { + 'larex.importers.list.foo' => new class() { }, ]);