Skip to content

Commit

Permalink
Update dependencies, add Psalm and PHP-CS-Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
alies-dev committed Feb 27, 2024
1 parent 93b1538 commit d5a86bf
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 53 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
21 changes: 3 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
composer.lock
vendor

.phpunit.result.cache
39 changes: 39 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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>
1 change: 0 additions & 1 deletion src/Commands/FindMissingTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d5a86bf

Please sign in to comment.