Skip to content

Commit

Permalink
Merge pull request #50 from pluswerk/feature/new-config-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti authored Feb 2, 2023
2 parents 36685e3 + 34415e0 commit 9da1be8
Show file tree
Hide file tree
Showing 12 changed files with 552 additions and 241 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/run-grumphp-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
composer:
- install --no-progress --no-scripts -n
- require phpro/grumphp:* --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: jq '.config.platform.php = "${{ matrix.php }}"' composer.json > composer.json_tmp && mv composer.json_tmp composer.json
- run: composer ${{ matrix.composer }}
- run: ./vendor/bin/grumphp run
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/composer.lock

.idea
var
41 changes: 2 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,11 @@
composer require pluswerk/grumphp-config --dev
````

pluswerk/grumphp-config will add the required ``extra.grumphp.config-default-path`` automatically to your ``composer.json``.

If pluswerk/grumphp-config should not edit your composer.json then you must add this:
````json
{
"extra": {
"pluswerk/grumphp-config": {
"auto-setting": false
}
}
}
````
pluswerk/grumphp-config will create `grumphp.yml`, `rector.php` and require some project specific resources if necessary

### You want to override settings?:

You need to deactivate the `auto-setting` = `false` and set the `grumphp.config-default-path` setting to `"grumphp.yml"`.

Make a new grumphp.yml config file. You can put it in the root folder.
````yaml
imports:
- { resource: vendor/pluswerk/grumphp-config/grumphp.yml }


parameters:
convention.phpstan_level: 1
convention.xmllint_ignore_pattern:
- "typo3conf/ext/extension/Resources/Private/Templates/List.xml"
````

There you can override some convention:


| Key | Default |
|-------------------------------------|-------------------------------|
| convention.process_timeout | 60 |
| convention.security_checker_blocking| true |
| convention.jsonlint_ignore_pattern | [] |
| convention.xmllint_ignore_pattern | [] |
| convention.yamllint_ignore_pattern | [] |
| convention.phpcslint_ignore_pattern | [] |
| convention.xlifflint_ignore_pattern | ["#typo3conf/l10n/(.*)#"] |
| convention.phpstan_level | max |
Look into your generated grumphp.yml


### Upgrade to grumphp-config 5
Expand Down
105 changes: 58 additions & 47 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,62 @@
{
"name": "pluswerk/grumphp-config",
"description": "GrumPHP config for php projects(mainly TYPO3)",
"type": "composer-plugin",
"license": "LGPL-3.0-or-later",
"authors": [
{
"name": "Matthias Vogel",
"email": "matthias.vogel@pluswerk.ag",
"homepage": "http://pluswerk.ag"
}
],
"config": {
"platform": {
"php": "7.4"
},
"preferred-install": {
"pluswerk/grumphp-bom-task": "source",
"pluswerk/grumphp-xliff-task": "source",
"*": "dist"
},
"allow-plugins": {
"phpro/grumphp": true
}
},
"support": {
"issues": "https://github.com/pluswerk/grumphp-config/issues"
},
"autoload": {
"psr-4": {
"PLUS\\": "src/"
}
},
"require": {
"php": "~7.4 || ~8.0 || ~8.1",
"composer-plugin-api": "^1.0.0 || ^2.0.0",
"phpro/grumphp": "^1.5.1",
"pluswerk/grumphp-bom-task": "^7.0.0",
"pluswerk/grumphp-xliff-task": "^5.0.0",
"squizlabs/php_codesniffer": "^3.6.2",
"enlightn/security-checker": "^1.10.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpstan/phpstan": "^1.4.7"
},
"extra": {
"class": "PLUS\\Composer\\Plugin"
"name" : "pluswerk/grumphp-config",
"description" : "GrumPHP config for php projects(mainly TYPO3)",
"type" : "composer-plugin",
"license" : "LGPL-3.0-or-later",
"authors" : [
{
"name" : "Matthias Vogel",
"email" : "matthias.vogel@pluswerk.ag",
"homepage" : "https://pluswerk.ag"
}
],
"config" : {
"preferred-install" : {
"pluswerk/grumphp-bom-task" : "source",
"pluswerk/grumphp-xliff-task" : "source",
"*" : "dist"
},
"require-dev": {
"composer/composer": "^1.10.25 || ^2.2.7"
"allow-plugins" : {
"phpro/grumphp": true,
"phpstan/extension-installer": true,
"typo3/cms-composer-installers": true,
"typo3/class-alias-loader": true
}
},
"support" : {
"issues" : "https://github.com/pluswerk/grumphp-config/issues"
},
"autoload" : {
"psr-4" : {
"PLUS\\GrumPHPConfig\\" : "src/"
}
},
"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"
},
"extra" : {
"class" : "PLUS\\GrumPHPConfig\\Composer\\Plugin"
},
"require-dev" : {
"saschaegerer/phpstan-typo3" : "^1.8.2",
"ssch/typo3-rector" : "^1.1.3",
"roave/security-advisories" : "dev-latest",
"composer/composer" : "^2.4.2"
},
"require-typo3" : {
"saschaegerer/phpstan-typo3" : "^1.8.2",
"ssch/typo3-rector" : "^1.1.3"
}
}
18 changes: 15 additions & 3 deletions grumphp.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
parameters:
convention.process_timeout: 60
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.xlifflint_ignore_pattern: ["#typo3conf/l10n/(.*)#"]
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

grumphp:
stop_on_failure: false
hide_circumvention_tip: true
Expand All @@ -29,7 +34,7 @@ grumphp:
ignore_patterns: "%convention.jsonlint_ignore_pattern%"
phpcs:
standard: "PSR12"
warning_severity: 900000
warning_severity: 0
tab_width: 4
ignore_patterns: "%convention.phpcslint_ignore_pattern%"
phpstan:
Expand All @@ -49,6 +54,13 @@ grumphp:
plus_bom_fixer:
metadata:
priority: 1
rector:
metadata:
enabled: "%convention.rector_enabled%"
config: "%convention.rector_config%"
triggered_by: [ 'php' ]
clear_cache: "%convention.rector_clear-cache%"
ignore_patterns: "%convention.rector_ignore_pattern%"
extensions:
- PLUS\GrumPHPBomTask\ExtensionLoader
- PLUS\GrumPHPXliffTask\ExtensionLoader
21 changes: 21 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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
9 changes: 7 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
includes:
- phpstan-baseline.neon

parameters:
stubFiles:
- stubs/ConfigSourceInterface.stub
level: max
reportUnmatchedIgnoredErrors: false
paths:
- src
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',
]
);
};
Loading

0 comments on commit 9da1be8

Please sign in to comment.