diff --git a/.github/workflows/run-grumphp-test.yml b/.github/workflows/run-grumphp-test.yml new file mode 100644 index 0000000..d5d7fd9 --- /dev/null +++ b/.github/workflows/run-grumphp-test.yml @@ -0,0 +1,18 @@ +name: Run grumphp with different versions +on: [push] +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: + - '8.0' + - '8.1' + - '8.2' + container: + image: kanti/buildy:${{ matrix.php }} + steps: + - uses: actions/checkout@v2 + - run: composer install --no-progress --no-scripts -n + - run: ./vendor/bin/grumphp run diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1502b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/ +composer.lock diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc34782 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# phpstan-git-files + +This phpstan extension automatically adds all your `.php` files from git to be checked by phpstan. + +## install + +`composer req --dev phpstan/extension-installer andersundsehr/phpstan-git-files` + +
+ Manual installation + +If you don't want to use `phpstan/extension-installer`, put this into your phpstan.neon config: + +```NEON +includes: + - vendor/andersundsehr/phpstan-git-files/extension.neon +``` + +
diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..ba547ad --- /dev/null +++ b/composer.json @@ -0,0 +1,39 @@ +{ + "name": "andersundsehr/phpstan-git-files", + "description": "Add all git files into phpstan config automatically", + "type": "phpstan-extension", + "autoload": { + "psr-4": { + "AUS\\PhpstanGitFiles\\": "src/" + } + }, + "authors": [ + { + "name": "Matthias Vogel", + "email": "m.vogel@andersundsehr.com" + } + ], + "require": { + "phpstan/phpstan": "^1.9", + "php": "~8.0 || ~8.1 || ~8.2", + "composer-plugin-api" : "^2.1.0" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "phpro/grumphp": true, + "phpstan/extension-installer": true, + "pluswerk/grumphp-config": true + } + }, + "require-dev": { + "pluswerk/grumphp-config": "^6.1" + }, + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + } +} diff --git a/extension.neon b/extension.neon new file mode 100644 index 0000000..7d7751e --- /dev/null +++ b/extension.neon @@ -0,0 +1,2 @@ +includes: + - extension.php diff --git a/extension.php b/extension.php new file mode 100644 index 0000000..2399e58 --- /dev/null +++ b/extension.php @@ -0,0 +1,9 @@ + getcwd() . '/' . $string, $paths); +return [ + 'parameters' => [ + 'paths' => $absolutPaths, + ], +]; diff --git a/grumphp.yml b/grumphp.yml new file mode 100644 index 0000000..0c162b1 --- /dev/null +++ b/grumphp.yml @@ -0,0 +1,16 @@ +imports: + - { resource: vendor/pluswerk/grumphp-config/grumphp.yml } +parameters: + convention.process_timeout: 240 + convention.security_checker_blocking: true + convention.jsonlint_ignore_pattern: { } + convention.xmllint_ignore_pattern: { } + convention.yamllint_ignore_pattern: { } + convention.phpcslint_ignore_pattern: { } + convention.phpcslint_exclude: { } + convention.xlifflint_ignore_pattern: { } + convention.rector_ignore_pattern: { } + convention.rector_enabled: true + convention.rector_config: rector.php + convention.rector_clear-cache: false + convention.phpstan_level: max diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..2541c5b --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +includes: + - extension.neon + +parameters: + level: max diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..cb9a514 --- /dev/null +++ b/rector.php @@ -0,0 +1,46 @@ +parallel(); + $rectorConfig->importNames(); + $rectorConfig->importShortClasses(); + $rectorConfig->cacheClass(FileCacheStorage::class); + $rectorConfig->cacheDirectory('./var/cache/rector'); + + $rectorConfig->paths( + array_filter([ + is_dir(__DIR__ . '/src') ? __DIR__ . '/src' : null, + is_dir(__DIR__ . '/extensions') ? __DIR__ . '/extensions' : null, + is_dir(__DIR__ . '/Classes') ? __DIR__ . '/Classes' : null, + ]) + ); + + // define sets of rules + $rectorConfig->sets( + [ + ...RectorSettings::sets(true), + ...RectorSettings::setsTypo3(false), + ] + ); + + // remove some rules + // ignore some files + $rectorConfig->skip( + [ + ...RectorSettings::skip(), + ...RectorSettings::skipTypo3(), + + /** + * rector should not touch these files + */ + //__DIR__ . '/src/Example', + //__DIR__ . '/src/Example.php', + ] + ); +};