diff --git a/CHANGELOG.md b/CHANGELOG.md index cea8f05..8ff1757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.2.0] +### Added +- Added coding standards for `drupal`. +- Added packages for `phpstan` for drupal based on [this documentation](https://www.drupal.org/docs/develop/development-tools/phpstan/getting-startedhttps://www.drupal.org/docs/develop/development-tools/phpstan/getting-started) + - `phpstan/phpstan` + - `phpstan/extension-installer` + - `mglaman/phpstan-drupal` + - `phpstan/phpstan-deprecation-rules` +- Added package for `phpcs` based on (this documentation)[https://www.drupal.org/docs/extending-drupal/contributed-modules/contributed-module-documentation/coder/installing-coder] + - `drupal/coder` + +### Fixed +- Mapping for drupal was added to prevent error that file is missing in `templates/mapping/project/drupal`. + +### Changed +- Allow `squizlabs/php_codesniffer` to be installed in a project with version `4.x` or higher, since the `drupal/coder` package requires this. + ## [3.1.2] ### Fixed - `Failed to locate the main schema resource at 'https://pmd.sourceforge.io/ruleset_xml_schema.xsd'` for php 8.3 and 8.4) @@ -33,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added exclude for UnusedFormalParameter to allow unused parameters in a function - Added exception for short variable name for $id - PHPCS Excluded Magento2.Annotation.MethodAnnotationStructure.MethodAnnotation + ### Fixed - Updated property for LongVariable did not work. diff --git a/README.md b/README.md index 4a26e5f..fdbeeca 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The Youwe Testing Suites offers pre-configured standards for the following proje | Testing Suite Project Type | Detected based on Composer Project Type | |----------------------------|----------------------------------------------------------------------------| -| `drupal` | `drupal-bundle`, `drupal-project` | +| `drupal` | `drupal-module`, `drupal-project` | | `magento2` | `magento-module`, `magento-project`, `magento2-module`, `magento2-project` | | `pimcore` | `pimcore-bundle`, `pimcore-project` | | `default` | Any other | diff --git a/composer.json b/composer.json index 9b06d8f..7d68d62 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "phpmd/phpmd": "^2.15 || 3.x-dev", "phpro/grumphp-shim": "^2.15", "phpstan/phpstan": "@stable", - "squizlabs/php_codesniffer": "^3.12.0", + "squizlabs/php_codesniffer": "^3.12.0 || ^4.0", "youwe/composer-dependency-installer": "^2.0", "youwe/composer-file-installer": "^2.0.0" }, diff --git a/config/drupal/grumphp.yml b/config/drupal/grumphp.yml index 3964359..824613c 100644 --- a/config/drupal/grumphp.yml +++ b/config/drupal/grumphp.yml @@ -8,3 +8,11 @@ parameters: # securitychecker.allow_list: # - CVE-2002-0121 # Add a jira ticket indicating when this vulnerability will be fixed (update/upgrade will be # performed). Within that ticket explain this (new) vulnerability. + +grumphp: + tasks: + phpcs: + ignore_patterns: + - /^build\// + - /^drush\// + - /^\.ddev\// \ No newline at end of file diff --git a/src/Installer/PackagesInstaller.php b/src/Installer/PackagesInstaller.php index b910629..4bdcc87 100644 --- a/src/Installer/PackagesInstaller.php +++ b/src/Installer/PackagesInstaller.php @@ -55,6 +55,33 @@ class PackagesInstaller implements InstallerInterface 'updateDependencies' => true, ] ], + 'drupal' => [ + 'drupal/coder' => [ + 'version' => '@stable', + 'updateDependencies' => true, + 'allowVersionOverride' => false, + ], + 'phpstan/phpstan' => [ + 'version' => '@stable', + 'updateDependencies' => true, + 'allowVersionOverride' => false, + ], + 'phpstan/extension-installer' => [ + 'version' => '@stable', + 'updateDependencies' => true, + 'allowVersionOverride' => false, + ], + 'mglaman/phpstan-drupal' => [ + 'version' => '@stable', + 'updateDependencies' => true, + 'allowVersionOverride' => false, + ], + 'phpstan/phpstan-deprecation-rules' => [ + 'version' => '@stable', + 'updateDependencies' => true, + 'allowVersionOverride' => false, + ], + ], 'pimcore' => [ 'phpstan/phpstan' => [ 'version' => '>=2.0', diff --git a/src/ProjectTypeResolver.php b/src/ProjectTypeResolver.php index 9711ae0..f7b1063 100644 --- a/src/ProjectTypeResolver.php +++ b/src/ProjectTypeResolver.php @@ -31,7 +31,7 @@ class ProjectTypeResolver /** @var array */ private $mapping = [ - 'drupal-bundle' => 'drupal', + 'drupal-module' => 'drupal', 'drupal-project' => 'drupal', 'magento-project' => 'magento2', 'magento2-module' => 'magento2', diff --git a/templates/files/drupal/phpcs.xml b/templates/files/drupal/phpcs.xml index a30dea4..7508902 100644 --- a/templates/files/drupal/phpcs.xml +++ b/templates/files/drupal/phpcs.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> PHPCS - + diff --git a/templates/mapping/project/drupal b/templates/mapping/project/drupal new file mode 100644 index 0000000..04763af --- /dev/null +++ b/templates/mapping/project/drupal @@ -0,0 +1,4 @@ +{drupal/,}grumphp.yml +{drupal/,}phpcs.xml +{drupal/,}phpmd.xml +{drupal/,}phpstan.neon diff --git a/tests/ProjectTypeResolverTest.php b/tests/ProjectTypeResolverTest.php index b2f9287..90352e0 100644 --- a/tests/ProjectTypeResolverTest.php +++ b/tests/ProjectTypeResolverTest.php @@ -26,7 +26,7 @@ class ProjectTypeResolverTest extends TestCase * @throws Exception */ #[TestWith(data: ['some-type', 'default'], name: 'some-type')] - #[TestWith(data: ['drupal-bundle', 'drupal'], name: 'drupal-bundle')] + #[TestWith(data: ['drupal-module', 'drupal'], name: 'drupal-bundle')] #[TestWith(data: ['drupal-project', 'drupal'], name: 'drupal-project')] #[TestWith(data: ['magento-project', 'magento2'], name: 'magento-project')] #[TestWith(data: ['magento2-module', 'magento2'], name: 'magento2-module')]