Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ 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.1.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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this URL will work

- `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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate fixed

- Mapping for drupal was added to prevent error that file is missing in `templates/mapping/project/drupal`.
### Fixed
- Magento 2 makes use of `phtml` moved triggered by for phpcs from default to magento2 scope.

## [3.0.3]
### Fixed
- When running GrumPHP on an environment with the Redis PHP extension installed, it errored with `The package
Expand Down
2 changes: 1 addition & 1 deletion config/default/grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ parameters:

phpcs.enabled: true
phpcs.standard: ./phpcs.xml
phpcs.triggered_by: [php,phtml]
phpcs.triggered_by: [php]

phpcsfixer.enabled: false
phpcsfixer.allow_risky: false
Expand Down
6 changes: 1 addition & 5 deletions config/drupal/grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@ imports:

# Extend git triggers with common Drupal constructs
parameters:
git_blacklist.triggered_by: [ 'php', 'js', 'twig' ]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need .module files to be checked for conflict markers, die() calls etc. too if they are just PHP files under the hood?


# 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.
phpcs.triggered_by: [ 'php' , 'module' ]
4 changes: 2 additions & 2 deletions config/drupal/phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 https://pmd.sourceforge.io/ruleset_xml_schema.xsd">
<description>PHPMD rules for Drupal projects.</description>
<rule ref="./config/default/phpmd.xml" />
<rule ref="./vendor/youwe/testing-suite/config/default/phpmd.xml" />

<!-- No overrides compared to default. Revisit this file and recreate default drupal rulesets for projects if needed.
Note: seperate ruleset needed until https://github.com/phpmd/phpmd/issues/39 is resolved -->
</ruleset>
</ruleset>
6 changes: 2 additions & 4 deletions config/drupal/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<ruleset name="Youwe/Drupal">
<description>Youwe coding standard extensions for sniffing code in Drupal projects.</description>

<!-- Use default Youwe coding standards for PHP projects. -->
<rule ref="../default" />
<!-- Additional Drupal-specific rulesets. -->

</ruleset>
<rule ref="Drupal" />
</ruleset>
1 change: 1 addition & 0 deletions config/magento2/grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ parameters:
- "<?php echo"
- "Magento\\\\Framework\\\\App\\\\ObjectManager"
git_blacklist.triggered_by: [ 'php', 'js', 'phtml' ]
phpcs.triggered_by: [ 'php' , 'phtml' ]

# securitychecker.allow_list:
# - CVE-2002-0121 # Add a jira ticket indicating when this vulnerability will be fixed (update/upgrade will be
Expand Down
2 changes: 1 addition & 1 deletion grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ parameters:
composer.strict: false
xmllint.ignore_patterns:
- /^phpcs.xml$/
- /^phpmd.xml$/
- /(^|\/)phpmd\.xml$/
- /^phpunit.xml$/
- /^pdepend.xml$/
- /^templates/
Expand Down
27 changes: 27 additions & 0 deletions src/Installer/PackagesInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/ProjectTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion templates/files/drupal/grumphp.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
imports:
- resource: 'vendor/youwe/testing-suite/config/pimcore/grumphp.yml'
- resource: 'vendor/youwe/testing-suite/config/drupal/grumphp.yml'
8 changes: 5 additions & 3 deletions templates/files/drupal/phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<ruleset name="YouweDrupal"
<ruleset name="YouweMagento2"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unintentional. We don't want the ruleset for drupal to be called this, right? :P

xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
Expand All @@ -9,5 +9,7 @@
<!-- Append arg -s to phpcs to display the name of failed sniffs -->
<arg value="s"/>

<!--<exclude-pattern>path/to/exclude/*</exclude-pattern>-->
</ruleset>
<exclude-pattern>build</exclude-pattern>
<exclude-pattern>drush</exclude-pattern>
<exclude-pattern>.ddev</exclude-pattern>
</ruleset>
10 changes: 2 additions & 8 deletions templates/files/drupal/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ includes:
# - phpstan-baseline.neon

parameters:
level: 1
Copy link
Copy Markdown
Member

@Anve94 Anve94 Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why level 1? It barely does anything. If needed due to issues they can just generate a baseline, no? The other neon configuration files also don't have a level defined. Level 1 just for undefined variables, unknown magic methods and properties on classes with __call and __get, so it analyses barely anything.

paths:
- web

# Add any other project folder containing source files, e.g.
# - tests

excludePaths:
# Add any path you want to exclude (note, only files/folders within the configured `paths` are relevant to note here), e.g.:
# - tests/fixtures/*
- web/modules/custom
4 changes: 4 additions & 0 deletions templates/mapping/project/drupal
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{drupal/,}grumphp.yml
{drupal/,}phpcs.xml
{drupal/,}phpmd.xml
{drupal/,}phpstan.neon
2 changes: 1 addition & 1 deletion tests/ProjectTypeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-module')]
#[TestWith(data: ['drupal-project', 'drupal'], name: 'drupal-project')]
#[TestWith(data: ['magento-project', 'magento2'], name: 'magento-project')]
#[TestWith(data: ['magento2-module', 'magento2'], name: 'magento2-module')]
Expand Down