Skip to content

Commit

Permalink
🎉 inital commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Feb 3, 2023
0 parents commit 52a6fca
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/run-grumphp-test.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor/
composer.lock
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`

<details>
<summary>Manual installation</summary>

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
```

</details>
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
}
],
"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"
]
}
}
}
2 changes: 2 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
includes:
- extension.php
9 changes: 9 additions & 0 deletions extension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$paths = array_filter(explode("\n", (string)shell_exec("git ls-files | grep '\.php$'")));
$absolutPaths = array_map(static fn($string) => getcwd() . '/' . $string, $paths);
return [
'parameters' => [
'paths' => $absolutPaths,
],
];
16 changes: 16 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
includes:
- extension.neon

parameters:
level: max
46 changes: 46 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

use PLUS\GrumPHPConfig\RectorSettings;
use Rector\Config\RectorConfig;
use Rector\Caching\ValueObject\Storage\FileCacheStorage;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->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',
]
);
};

0 comments on commit 52a6fca

Please sign in to comment.