Skip to content

Commit

Permalink
Merge pull request #3 from diglabby/alies/laravel-10
Browse files Browse the repository at this point in the history
Update dependencies, add Psalm and PHP-CS-Fixer
  • Loading branch information
alies-dev committed Feb 27, 2024
2 parents 93b1538 + eaf1b8c commit 0073527
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 55 deletions.
32 changes: 32 additions & 0 deletions .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
42 changes: 16 additions & 26 deletions .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
22 changes: 8 additions & 14 deletions .github/workflows/test.yml
Expand Up @@ -10,28 +10,22 @@ 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: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
testbench: 4.*
- laravel: 5.8.*
testbench: 3.8.*
exclude:
- php: 8.0
laravel: 10.*
- php: 7.4
laravel: 10.*
- php: 7.4
laravel: 9.*
- php: 8.0
laravel: 5.8.*
- php: 8.3
laravel: 5.8.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }}

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,2 +1,5 @@
composer.lock
vendor

.phpunit.result.cache
.php-cs-fixer.cache
39 changes: 39 additions & 0 deletions .php-cs-fixer.php
@@ -0,0 +1,39 @@
<?php declare(strict_types=1);

$finder = PhpCsFixer\Finder::create()
->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);
6 changes: 3 additions & 3 deletions 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.

<p align="center"><img src="https://user-images.githubusercontent.com/5278175/83045008-a9ce0a80-a04d-11ea-89db-90e709ca7b0d.png" alt="Package logo" width="250"></p>

Expand All @@ -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 Laravels path to lang files:
```sh
php artisan translations:missing
```
Expand All @@ -39,4 +39,4 @@ composer test

## Thanks

Inspired by [VetonMuhaxhiri/Laravel-find-missing-translations](https://github.com/VetonMuhaxhiri/Laravel-find-missing-translations)
Inspired by [VetonMuhaxhiri/Laravel-find-missing-translations](https://github.com/VetonMuhaxhiri/Laravel-find-missing-translations)
15 changes: 10 additions & 5 deletions composer.json
Expand Up @@ -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,
Expand All @@ -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"
}
}
35 changes: 35 additions & 0 deletions psalm-baseline.xml
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
<file src="src/Commands/FindMissingTranslations.php">
<MissingPropertyType>
<code><![CDATA[$exitCode]]></code>
</MissingPropertyType>
<NonInvariantDocblockPropertyType>
<code><![CDATA[$description]]></code>
</NonInvariantDocblockPropertyType>
<PossiblyInvalidArgument>
<code><![CDATA[$pathToLocates]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidCast>
<code><![CDATA[$baseLocale]]></code>
<code><![CDATA[$pathToLocates]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
<code><![CDATA[$this->option('dir')]]></code>
</PossiblyInvalidCast>
<PropertyNotSetInConstructor>
<code><![CDATA[FindMissingTranslations]]></code>
<code><![CDATA[FindMissingTranslations]]></code>
<code><![CDATA[FindMissingTranslations]]></code>
<code><![CDATA[FindMissingTranslations]]></code>
<code><![CDATA[FindMissingTranslations]]></code>
</PropertyNotSetInConstructor>
<RiskyTruthyFalsyComparison>
<code><![CDATA[$this->option('base')]]></code>
</RiskyTruthyFalsyComparison>
</file>
</files>
24 changes: 24 additions & 0 deletions psalm.xml
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="2"
findUnusedBaselineEntry="true"
findUnusedCode="false"
findUnusedVariablesAndParams="true"
resolveFromConfigFile="true"
useDocblockPropertyTypes="true"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src"/>
<directory name="tests"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>

<issueHandlers>
</issueHandlers>
</psalm>
8 changes: 5 additions & 3 deletions src/Commands/FindMissingTranslations.php
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Diglabby\FindMissingTranslations\Commands;

Expand Down Expand Up @@ -73,9 +75,10 @@ private function compareLanguages(string $baseLanguagePath, array $baseLanguageF
foreach ($baseLanguageFiles as $languageFile) {
$baseLanguageFile = File::getRequire("{$baseLanguagePath}/{$languageFile}");

if (!in_array($languageFile, $languageFiles, true)) {
if (! in_array($languageFile, $languageFiles, true)) {
$this->comment("Comparing translations in {$languageFile}.", 'v');
$this->error("{$languageName}/{$languageFile} file is missing.", 'q');

continue;
}
$secondLanguageFile = File::getRequire("{$languagePath}/{$languageFile}");
Expand Down Expand Up @@ -127,7 +130,6 @@ private function getFilenames(string $directory): array
{
$fileNames = [];

/** @var \Symfony\Component\Finder\SplFileInfo[] $filesInFolder */
$filesInFolder = File::files($directory);

foreach ($filesInFolder as $fileInfo) {
Expand Down
4 changes: 3 additions & 1 deletion src/ServiceProvider.php
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Diglabby\FindMissingTranslations;

Expand Down
5 changes: 3 additions & 2 deletions tests/Commands/FindMissingTranslationsTest.php
@@ -1,8 +1,9 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Diglabby\FindMissingTranslations\Tests\Commands;

use Diglabby\FindMissingTranslations\Commands\FindMissingTranslations;
use Diglabby\FindMissingTranslations\Tests\TestCase;
use Illuminate\Support\Facades\Artisan;

Expand Down
4 changes: 3 additions & 1 deletion tests/TestCase.php
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace Diglabby\FindMissingTranslations\Tests;

Expand Down

0 comments on commit 0073527

Please sign in to comment.