Skip to content

Commit 48e43f0

Browse files
feat(work in progress): use PHP CS Fixer for Pimcore projects
Resolves #41
1 parent 9056a18 commit 48e43f0

File tree

8 files changed

+120
-49
lines changed

8 files changed

+120
-49
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Upstream projects not having phpunit installed will install phpunit with an @stable version.
1616
- Added support for Drupal configuration and templates.
1717
- Migration docs for migration from v2 to v3 of the testing suite.
18+
- Pimcore coding standards now uses PHP CS Fixer to support PER 2.0 coding standards
1819

1920
### Changed
2021
- [BREAKING] The composer.json configurations `config.youwe-testing-suite.type` and `config.mediact-testing-suite.type`
@@ -32,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3233
- Updated remote schema location URL for phpmd rulesets to prevent redirecting which may cause flaky builds.
3334
- Bumped phpro/grumphp-shim dependency from v1 to v2
3435
- Bumped youwe/composer-dependency-installer from v1 to v2
36+
- Default Pimcore coding standards disables PHPCS in favour of PHP CS Fixer
3537

3638
### Removed
3739
- Removed support for EOL PHP versions. Projects running PHP < 8.1 can stick to version 2 of the testing-suite.

config/pimcore/grumphp.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,21 @@ imports:
33

44
# Extend git triggers with common pimcore constructs
55
parameters:
6-
git_blacklist.triggered_by: [ 'php', 'js', 'twig' ]
6+
git_blacklist.triggered_by: [ 'php', 'js', 'twig' ]
7+
8+
phpcsfixer.allow_risky: false
9+
phpcsfixer.verbose: true
10+
phpcsfixer.diff: true
11+
phpcsfixer.triggered_by: ['php']
12+
13+
grumphp:
14+
tasks:
15+
# Disable PHPCS in favor of PHP CS Fixer
16+
phpcs:
17+
metadata:
18+
enabled: false
19+
phpcsfixer:
20+
allow_risky: '%phpcsfixer.allow_risky%'
21+
verbose: '%phpcsfixer.verbose%'
22+
diff: '%phpcsfixer.diff%'
23+
triggered_by: '%phpcsfixer.triggered_by%'

config/pimcore/ruleset.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/Installer/PackagesInstaller.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ class PackagesInstaller implements InstallerInterface
5555
'updateDependencies' => true,
5656
]
5757
],
58+
'pimcore' => [
59+
// For Pimcore, use PHP CS Fixer instead of PHP Code Sniffer, because the latter lacks support for PER
60+
// coding standards
61+
'php-cs-fixer/shim' => [
62+
'version' => '@stable',
63+
],
64+
],
5865
];
5966

6067
/**
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create() // @phpstan-ignore class.notFound (class lives in phar file and can't be seen)
6+
->in(__DIR__)
7+
->exclude([
8+
/**
9+
* Default Pimcore excludes
10+
*/
11+
12+
// Symfony files
13+
'bin/console',
14+
'public/index.php',
15+
// Full var folder, this contains all kind of auto-generated files (from cache to class definitions)
16+
'var',
17+
// Configuration written by Pimcore (which is written to var/ or to config/pimcore depending on settings)
18+
'config/pimcore',
19+
20+
/**
21+
* Add any project specific exclude below
22+
*/
23+
]);
24+
25+
$config = new PhpCsFixer\Config(); // @phpstan-ignore class.notFound (class lives in phar file and can't be seen)
26+
return $config // @phpstan-ignore class.notFound (class lives in phar file and can't be seen)
27+
->setRules([
28+
// Alias for the latest revision of PER-CS rules, replace with '@PER-CS2.0' if you want explicitly use PER 2.0
29+
'@PER-CS' => true,
30+
])
31+
->setFinder($finder);

templates/files/pimcore/dotgitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# symfony default
2+
/.web-server-pid
3+
/config/pimcore/parameters.yml
4+
/public/bundles/
5+
6+
# local config
7+
/.env.local
8+
/.env.local.php
9+
/.env.*.local
10+
11+
/var/*
12+
!/var/.gitkeep
13+
!/var/classes/
14+
/var/classes/DataObject
15+
16+
!/var/config
17+
/var/config/debug-mode.php
18+
/var/config/maintenance.php
19+
20+
!/var/admin/
21+
/var/admin/*
22+
!/var/admin/custom-logo.image
23+
24+
# project specific recommendations
25+
/var/config/tag-manager.php
26+
/var/config/reports.php
27+
/var/config/portal
28+
29+
/public/var/
30+
/public/sitemap*.xml
31+
32+
# PHP-CS-Fixer
33+
/.php_cs
34+
/.php_cs.cache
35+
36+
# composer
37+
/vendor/
38+
/build/deployer/vendor
39+
40+
# PhpStorm / IDEA
41+
.idea
42+
# NetBeans
43+
nbproject
44+
# VS Code
45+
.prettierrc
46+
47+
# temp
48+
.temp
49+
50+
.DS_Store
51+
*.swp
52+
53+
# PhpUnit
54+
phpunit.result.xml
55+
.phpunit.result.cache
56+
57+
# PHP CS Fixer cache & local config
58+
.php-cs-fixer.cache
59+
.php-cs-fixer.php

templates/files/pimcore/phpcs.xml

Lines changed: 0 additions & 34 deletions
This file was deleted.

templates/mapping/project/pimcore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
{pimcore/,}phpcs.xml
1+
{pimcore/,}.php-cs-fixer.dist.php
2+
{pimcore/dot,.}gitignore
3+
{pimcore/,}grumphp.yml
24
{pimcore/,}phpmd.xml
35
{pimcore/,}phpstan.neon

0 commit comments

Comments
 (0)