Skip to content

Commit 80962dd

Browse files
author
cradu
committed
Updated phpstan standard, added rector and php insights support
1 parent 8d4f057 commit 80962dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+828
-311
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ jobs:
112112
run: vendor/bin/phpstan
113113

114114
- name: Execute Rector
115-
run: vendor/bin/rector
115+
run: vendor/bin/rector --dry-run
116+
117+
- name: Execute PHP Insights
118+
run: vendor/bin/phpinsights --no-interaction
116119

117120
laravel10-tests:
118121
runs-on: ubuntu-latest
@@ -212,7 +215,10 @@ jobs:
212215
run: vendor/bin/phpstan
213216

214217
- name: Execute Rector
215-
run: vendor/bin/rector
218+
run: vendor/bin/rector --dry-run
219+
220+
- name: Execute PHP Insights
221+
run: vendor/bin/phpinsights --no-interaction
216222

217223
laravel11-tests:
218224
runs-on: ubuntu-latest
@@ -312,5 +318,8 @@ jobs:
312318
run: vendor/bin/phpstan
313319

314320
- name: Execute Rector
315-
run: vendor/bin/rector
321+
run: vendor/bin/rector --dry-run
322+
323+
- name: Execute PHP Insights
324+
run: vendor/bin/phpinsights --no-interaction
316325

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
## ✨ Features
2626

27-
- **Pre-configured Hooks:** Laravel Git Hooks comes with pre-configured pre-commit hooks for popular tools, such as Laravel Pint, PHPCS, ESLint, Prettier, Larastan, Enlightn, and Blade Formatter, making it easy to enforce coding standards and style guidelines right away.
27+
- **Pre-configured Hooks:** Laravel Git Hooks comes with pre-configured pre-commit hooks for popular tools, such as Laravel Pint, PHPCS, ESLint, Prettier, Larastan, Enlightn, Rector, PHP Insights and Blade Formatter, making it easy to enforce coding standards and style guidelines right away.
2828
- **Manage Git Hooks:** Easily manage your Git hooks in your Laravel projects with a streamlined and organized approach.
2929
- **Edit Commit Messages:** Gain control over your commit messages by customizing them to meet your project requirements and maintain a clean Git history.
3030
- **Create Custom Hooks:** Add and integrate custom hooks tailored to your specific project needs, ensuring better code quality and adherence to guidelines.
@@ -62,6 +62,8 @@ To use the already created pre-commit hooks of this package, you can simply edit
6262
\Igorsgm\GitHooks\Console\Commands\Hooks\EnlightnPreCommitHook::class, // Enlightn
6363
\Igorsgm\GitHooks\Console\Commands\Hooks\ESLintPreCommitHook::class, // ESLint
6464
\Igorsgm\GitHooks\Console\Commands\Hooks\PrettierPreCommitHook::class, // Prettier
65+
\Igorsgm\GitHooks\Console\Commands\Hooks\PhpInsightsPreCommitHook::class, // PhpInsights
66+
\Igorsgm\GitHooks\Console\Commands\Hooks\RectorPreCommitHook::class, // Rector
6567
],
6668
```
6769

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"larastan/larastan": "^2.9",
3535
"laravel/pint": "^1.2",
3636
"mockery/mockery": "^1.5.1",
37+
"nunomaduro/phpinsights": "^2.11",
3738
"orchestra/testbench": "^v8.0.0|^v9.0.0",
3839
"pestphp/pest": "^2.0",
3940
"pestphp/pest-plugin-laravel": "^2.3",
@@ -57,7 +58,8 @@
5758
"config": {
5859
"sort-packages": true,
5960
"allow-plugins": {
60-
"pestphp/pest-plugin": true
61+
"pestphp/pest-plugin": true,
62+
"dealerdirect/phpcodesniffer-composer-installer": true
6163
}
6264
},
6365
"extra": {

config/git-hooks.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
return [
46

57
/*
@@ -200,6 +202,22 @@
200202
'run_in_docker' => env('BLADE_FORMATTER_RUN_IN_DOCKER', false),
201203
'docker_container' => env('BLADE_FORMATTER_DOCKER_CONTAINER', ''),
202204
],
205+
'rector' => [
206+
'path' => env('RECTOR_PATH', 'vendor/bin/rector'),
207+
'config' => env('RECTOR_CONFIG', 'rector.php'),
208+
'file_extensions' => env('RECTOR_FILE_EXTENSIONS', '/\.php$/'),
209+
'additional_params' => env('RECTOR_ADDITIONAL_PARAMS', ''),
210+
'run_in_docker' => env('RECTOR_RUN_IN_DOCKER', false),
211+
'docker_container' => env('RECTOR_DOCKER_CONTAINER', ''),
212+
],
213+
'phpinsights' => [
214+
'path' => env('PHPINSIGHTS_PATH', 'vendor/bin/phpinsights'),
215+
'config' => env('PHPINSIGHTS_CONFIG', 'phpinsights.php'),
216+
'file_extensions' => env('PHPINSIGHTS_FILE_EXTENSIONS', '/\.php$/'),
217+
'additional_params' => env('PHPINSIGHTS_ADDITIONAL_PARAMS', ''),
218+
'run_in_docker' => env('PHPINSIGHTS_RUN_IN_DOCKER', false),
219+
'docker_container' => env('PHPINSIGHTS_DOCKER_CONTAINER', ''),
220+
],
203221
'prettier' => [
204222
'path' => env('PRETTIER_PATH', 'node_modules/.bin/prettier'),
205223
'config' => env('PRETTIER_CONFIG', '.prettierrc.json'),

phpinsights.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
'preset' => 'laravel',
7+
'exclude' => [
8+
'src/Console/Commands/',
9+
'src/HooksPipeline.php',
10+
'src/Git/Log.php',
11+
],
12+
'add' => [
13+
// ExampleMetric::class => [
14+
// ExampleInsight::class,
15+
// ]
16+
],
17+
'remove' => [
18+
SlevomatCodingStandard\Sniffs\Classes\ForbiddenPublicPropertySniff::class,
19+
SlevomatCodingStandard\Sniffs\ControlStructures\DisallowEmptySniff::class,
20+
SlevomatCodingStandard\Sniffs\TypeHints\DisallowMixedTypeHintSniff::class,
21+
SlevomatCodingStandard\Sniffs\Classes\SuperfluousExceptionNamingSniff::class,
22+
SlevomatCodingStandard\Sniffs\Functions\FunctionLengthSniff::class,
23+
SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff::class,
24+
NunoMaduro\PhpInsights\Domain\Sniffs\ForbiddenSetterSniff::class,
25+
NunoMaduro\PhpInsights\Domain\Insights\CyclomaticComplexityIsHigh::class,
26+
NunoMaduro\PhpInsights\Domain\Insights\ForbiddenNormalClasses::class,
27+
NunoMaduro\PhpInsights\Domain\Insights\ForbiddenTraits::class,
28+
PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff::class,
29+
PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff::class,
30+
PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer::class,
31+
],
32+
'config' => [
33+
// ExampleInsight::class => [
34+
// 'key' => 'value',
35+
// ],
36+
],
37+
'requirements' => [
38+
'min-quality' => 100,
39+
'min-complexity' => 0,
40+
'min-architecture' => 100,
41+
'min-style' => 100,
42+
],
43+
];

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ parameters:
22
paths:
33
- ./src
44
# The level 9 is the highest level (with check for mixed type)
5-
level: 6
5+
level: 8

rector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
return RectorConfig::configure()
99
->withPaths([
1010
__DIR__.'/src',
11-
__DIR__.'/tests',
1211
])
1312
// uncomment to reach your current PHP version
1413
->withPhpSets()

src/Console/Commands/CommitMessage.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Igorsgm\GitHooks\Console\Commands;
46

57
use Igorsgm\GitHooks\Contracts\HookCommand;
@@ -19,12 +21,11 @@ class CommitMessage extends Command implements HookCommand
1921

2022
/**
2123
* The console command description.
24+
*
25+
* @var string
2226
*/
2327
protected $description = 'Run hook commit-msg';
2428

25-
/**
26-
* {@inheritDoc}
27-
*/
2829
public function getHook(): string
2930
{
3031
return 'commit-msg';

0 commit comments

Comments
 (0)