Skip to content

Commit 6375d29

Browse files
authored
Merge pull request #41 from indy2kro/deprecate-laravel10-support
Deprecate Laravel 10 support
2 parents fd7a139 + 9a4a2b3 commit 6375d29

File tree

10 files changed

+262
-62
lines changed

10 files changed

+262
-62
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ permissions:
1919
contents: read
2020

2121
jobs:
22-
laravel10-tests:
22+
laravel11-tests:
2323
runs-on: ubuntu-latest
2424

2525
strategy:
2626
fail-fast: false
2727
matrix:
2828
operating-system: [ ubuntu-latest ]
29-
php: [ '8.1', '8.2' ]
29+
php: [ '8.2', '8.3', '8.4' ]
3030
dependency-stability: [ 'prefer-stable' ]
3131

32-
laravel: [ '10.*' ]
32+
laravel: [ '11.*' ]
3333
include:
34-
- laravel: 10.*
35-
testbench: 8.*
34+
- laravel: 11.*
35+
testbench: 9.*
3636

3737
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
3838

@@ -71,16 +71,16 @@ jobs:
7171
id: actions-cache
7272
with:
7373
path: ${{ steps.composer-cache.outputs.dir }}
74-
key: ${{ runner.os }}-composer-laravel-10-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
74+
key: ${{ runner.os }}-composer-laravel-11-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
7575
restore-keys: |
76-
${{ runner.os }}-composer-laravel-10-${{ matrix.php }}-
76+
${{ runner.os }}-composer-laravel-11-${{ matrix.php }}-
7777
7878
- name: Cache PHP dependencies (vendor)
7979
uses: actions/cache@v4
8080
id: vendor-cache
8181
with:
8282
path: vendor
83-
key: ${{ runner.os }}-build-laravel-10-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
83+
key: ${{ runner.os }}-build-laravel-11-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
8484

8585
- name: Install Laravel Dependencies
8686
if: steps.vendor-cache.outputs.cache-hit != 'true'
@@ -123,7 +123,7 @@ jobs:
123123
- name: Execute PHP Insights
124124
run: vendor/bin/phpinsights --disable-security-check --no-interaction
125125

126-
laravel11-tests:
126+
laravel12-tests:
127127
runs-on: ubuntu-latest
128128

129129
strategy:
@@ -133,9 +133,9 @@ jobs:
133133
php: [ '8.2', '8.3', '8.4' ]
134134
dependency-stability: [ 'prefer-stable' ]
135135

136-
laravel: [ '11.*' ]
136+
laravel: [ '12.*' ]
137137
include:
138-
- laravel: 11.*
138+
- laravel: 12.*
139139
testbench: 9.*
140140

141141
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
build:
22
environment:
33
php:
4-
version: 8.1
4+
version: 8.2
55
node: "v16.20.0"
66
nodes:
77
analysis:

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ To use the already created pre-commit hooks of this package, you can simply edit
6060
'pre-commit' => [
6161
\Igorsgm\GitHooks\Console\Commands\Hooks\PintPreCommitHook::class, // Laravel Pint
6262
\Igorsgm\GitHooks\Console\Commands\Hooks\PHPCodeSnifferPreCommitHook::class, // PHPCS (with PHPCBF autofixer)
63+
\Igorsgm\GitHooks\Console\Commands\Hooks\PHPCSFixerPreCommitHook::class, // PHP CS Fixer
6364
\Igorsgm\GitHooks\Console\Commands\Hooks\LarastanPreCommitHook::class, // Larastan
6465
\Igorsgm\GitHooks\Console\Commands\Hooks\EnlightnPreCommitHook::class, // Enlightn
6566
\Igorsgm\GitHooks\Console\Commands\Hooks\ESLintPreCommitHook::class, // ESLint
@@ -376,6 +377,10 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
376377
377378
## Credits
378379
380+
- [Cristian Radu](https://github.com/indy2kro)
381+
382+
Original authors:
383+
379384
- [Igor Moraes](https://github.com/igorsgm)
380385
- [Pavel Buchnev](https://github.com/butschster)
381386

composer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^8.1",
24-
"illuminate/config": "^10 || ^11 || ^12",
25-
"illuminate/console": "^10 || ^11 || ^12",
26-
"illuminate/container": "^10 || ^11 || ^12",
27-
"illuminate/contracts": "^10 || ^11 || ^12",
28-
"illuminate/pipeline": "^10 || ^11 || ^12",
29-
"illuminate/support": "^10 || ^11 || ^12"
23+
"php": "^8.2",
24+
"illuminate/config": "^11 || ^12",
25+
"illuminate/console": "^11 || ^12",
26+
"illuminate/container": "^11 || ^12",
27+
"illuminate/contracts": "^11 || ^12",
28+
"illuminate/pipeline": "^11 || ^12",
29+
"illuminate/support": "^11 || ^12"
3030
},
3131
"require-dev": {
3232
"enlightn/enlightn": "^2",
33+
"friendsofphp/php-cs-fixer": "^3",
3334
"larastan/larastan": "^2 || ^3",
3435
"laravel/pint": "^1",
3536
"mockery/mockery": "^1",

config/git-hooks.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,23 @@
184184
'phpcbf_path' => env('PHPCBF_PATH', 'vendor/bin/phpcbf'),
185185
'config' => env('PHPCS_STANDARD_CONFIG', 'phpcs.xml'),
186186
'file_extensions' => env('PHPCS_FILE_EXTENSIONS', '/\.php$/'),
187-
'run_in_docker' => env('LARAVEL_PHPCS_RUN_IN_DOCKER', false),
188-
'docker_container' => env('LARAVEL_PHPCS_DOCKER_CONTAINER', ''),
187+
'run_in_docker' => env('PHPCS_RUN_IN_DOCKER', false),
188+
'docker_container' => env('PHPCS_DOCKER_CONTAINER', ''),
189+
],
190+
'php_cs_fixer' => [
191+
'path' => env('PHPCSFIXER_PATH', 'vendor/bin/php-cs-fixer'),
192+
'config' => env('PHPCSFIXER_STANDARD_CONFIG', '.php-cs-fixer.php'),
193+
'file_extensions' => env('PHPCSFIXER_FILE_EXTENSIONS', '/\.php$/'),
194+
'run_in_docker' => env('PHPCSFIXER_RUN_IN_DOCKER', false),
195+
'docker_container' => env('PHPCSFIXER_DOCKER_CONTAINER', ''),
189196
],
190197
'larastan' => [
191198
'path' => env('LARASTAN_PATH', 'vendor/bin/phpstan'),
192199
'config' => env('LARASTAN_CONFIG', 'phpstan.neon'),
193200
'additional_params' => env('LARASTAN_ADDITIONAL_PARAMS', '--xdebug'),
194201
'file_extensions' => env('LARASTAN_FILE_EXTENSIONS', '/\.php$/'),
195-
'run_in_docker' => env('LARAVEL_LARASTAN_RUN_IN_DOCKER', false),
196-
'docker_container' => env('LARAVEL_LARASTAN_DOCKER_CONTAINER', ''),
202+
'run_in_docker' => env('LARASTAN_RUN_IN_DOCKER', false),
203+
'docker_container' => env('LARASTAN_DOCKER_CONTAINER', ''),
197204
],
198205
'blade_formatter' => [
199206
'path' => env('BLADE_FORMATTER_PATH', 'node_modules/.bin/blade-formatter'),

package-lock.json

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Igorsgm\GitHooks\Console\Commands\Hooks;
6+
7+
use Closure;
8+
use Igorsgm\GitHooks\Contracts\CodeAnalyzerPreCommitHook;
9+
use Igorsgm\GitHooks\Git\ChangedFiles;
10+
11+
class PHPCSFixerPreCommitHook extends BaseCodeAnalyzerPreCommitHook implements CodeAnalyzerPreCommitHook
12+
{
13+
protected string $configParam;
14+
15+
/**
16+
* Name of the hook
17+
*/
18+
protected string $name = 'PHP_CS_Fixer';
19+
20+
/**
21+
* Analyze and fix committed PHP files using PHP CS Fixer.
22+
*
23+
* @param ChangedFiles $files The files that have been changed in the current commit.
24+
* @param Closure $next A closure that represents the next middleware in the pipeline.
25+
*/
26+
public function handle(ChangedFiles $files, Closure $next): mixed
27+
{
28+
$this->configParam = $this->configParam();
29+
30+
return $this->setFileExtensions(config('git-hooks.code_analyzers.php_cs_fixer.file_extensions'))
31+
->setAnalyzerExecutable(config('git-hooks.code_analyzers.php_cs_fixer.path'))
32+
->setRunInDocker(config('git-hooks.code_analyzers.php_cs_fixer.run_in_docker'))
33+
->setDockerContainer(config('git-hooks.code_analyzers.php_cs_fixer.docker_container'))
34+
->handleCommittedFiles($files, $next);
35+
}
36+
37+
/**
38+
* Returns the command to run PHPCS
39+
*/
40+
public function analyzerCommand(): string
41+
{
42+
return trim(sprintf('%s check %s', $this->getAnalyzerExecutable(), $this->configParam));
43+
}
44+
45+
/**
46+
* Returns the command to run PHPCS
47+
*/
48+
public function fixerCommand(): string
49+
{
50+
return trim(sprintf('%s fix %s', $this->getAnalyzerExecutable(), $this->configParam));
51+
}
52+
53+
/**
54+
* Gets the command-line parameter for specifying the configuration file for PHP CS Fixer.
55+
*
56+
* @return string The configuration parameter for the analyzer.
57+
*/
58+
public function configParam(): string
59+
{
60+
$configFile = (string) config('git-hooks.code_analyzers.php_cs_fixer.config');
61+
62+
if (! empty($configFile)) {
63+
$this->validateConfigPath($configFile);
64+
65+
return '--config='.$configFile;
66+
}
67+
68+
return '';
69+
}
70+
}

0 commit comments

Comments
 (0)