Skip to content

Commit

Permalink
Merge pull request #52 from pluswerk/feature/automatic-phpstan.neon-c…
Browse files Browse the repository at this point in the history
…reation
  • Loading branch information
Kanti authored Feb 3, 2023
2 parents 54b5059 + 1774147 commit 8d7b847
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 47 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/run-grumphp-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ jobs:
- '8.0'
- '8.1'
- '8.2'
composer:
- install --no-progress --no-scripts -n
- update --no-progress --no-scripts -n --prefer-lowest
container:
image: kanti/buildy:${{ matrix.php }}
steps:
- uses: actions/checkout@v2
- run: composer ${{ matrix.composer }}
- run: composer install --no-progress --no-scripts -n
- run: ./vendor/bin/grumphp run
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

.idea
var
public/
31 changes: 17 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
"preferred-install" : {
"pluswerk/grumphp-bom-task" : "source",
"pluswerk/grumphp-xliff-task" : "source",
"andersundsehr/phpstan-git-files" : "source",
"*" : "dist"
},
"allow-plugins" : {
"phpro/grumphp": true,
"phpstan/extension-installer": true,
"typo3/cms-composer-installers": true,
"typo3/class-alias-loader": true
}
},
"sort-packages": true
},
"support" : {
"issues" : "https://github.com/pluswerk/grumphp-config/issues"
Expand All @@ -32,19 +34,20 @@
}
},
"require" : {
"php" : "~8.0 || ~8.1 || ~8.2",
"composer-plugin-api" : "^2.1.0",
"phpro/grumphp" : "^1.15",
"pluswerk/grumphp-bom-task" : "^7.0.0",
"pluswerk/grumphp-xliff-task" : "^5.0.0",
"squizlabs/php_codesniffer" : "^3.7.1",
"enlightn/security-checker" : "^1.10.0",
"php-parallel-lint/php-parallel-lint" : "^1.3.2",
"phpstan/phpstan" : "^1.8.8",
"phpstan/extension-installer" : "^1.1",
"rector/rector" : "^0.15.10",
"composer/semver" : "^3.3.0",
"symfony/yaml" : "^5.4.0 || ^6.0"
"php": "~8.0 || ~8.1 || ~8.2",
"composer-plugin-api": "^2.1.0",
"andersundsehr/phpstan-git-files": "^1.0.1",
"composer/semver": "^3.3.0",
"enlightn/security-checker": "^1.10.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpro/grumphp": "^1.15",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.9.0",
"pluswerk/grumphp-bom-task": "^7.0.0",
"pluswerk/grumphp-xliff-task": "^5.0.0",
"rector/rector": "^0.15.10",
"squizlabs/php_codesniffer": "^3.7.1",
"symfony/yaml": "^5.4.0 || ^6.0"
},
"extra" : {
"class" : "PLUS\\GrumPHPConfig\\Composer\\Plugin"
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parameters:
convention.rector_enabled: true
convention.rector_config: 'rector.php'
convention.rector_clear-cache: false
convention.phpstan_level: max
convention.phpstan_level: ~

grumphp:
stop_on_failure: false
Expand Down
21 changes: 1 addition & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
parameters:
ignoreErrors:
-
message: "#^Cannot access offset 'config\\-default\\-path' on mixed\\.$#"
count: 1
path: src/Composer/Plugin.php

-
message: "#^Cannot access offset 'php' on mixed\\.$#"
count: 1
path: src/VersionUtility.php

-
message: "#^Method PLUS\\\\GrumPHPConfig\\\\VersionUtility\\:\\:getRequire\\(\\) should return array\\<string, string\\> but returns mixed\\.$#"
count: 1
path: src/VersionUtility.php

-
message: "#^Method PLUS\\\\GrumPHPConfig\\\\VersionUtility\\:\\:readJson\\(\\) should return array\\<string, mixed\\> but returns mixed\\.$#"
count: 1
path: src/VersionUtility.php
ignoreErrors: []
5 changes: 2 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
includes:
- phpstan-baseline.neon
- vendor/andersundsehr/phpstan-git-files/extension.php

parameters:
level: max
level: 8
reportUnmatchedIgnoredErrors: false
paths:
- src
6 changes: 1 addition & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
$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,
])
array_filter(explode("\n", (string)shell_exec("git ls-files | grep '\.php$'")))
);

// define sets of rules
Expand Down
12 changes: 12 additions & 0 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function heavyProcessing(): void
$this->removeOldConfigPath();
$this->installTypo3Dependencies();
$this->createGrumphpConfig();
$this->createPhpStanConfig();

$this->simpleProcessing();
}
Expand Down Expand Up @@ -185,6 +186,17 @@ private function createGrumphpConfig(): void
}
}

private function createPhpStanConfig(): void
{
$fileNames = ['phpstan.neon', 'phpstan-baseline.neon'];
foreach ($fileNames as $fileName) {
if (!file_exists(getcwd() . '/' . $fileName)) {
copy(dirname(__DIR__, 2) . '/' . $fileName, getcwd() . '/' . $fileName);
$this->message($fileName . ' file created', 'yellow');
}
}
}

// HELPER:

private function message(string $message, string $color = null): void
Expand Down

0 comments on commit 8d7b847

Please sign in to comment.