From b41e36bc2763153626a7366ca073e0f2cd44d78f Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen.haas@lakedrops.com> Date: Thu, 30 Jun 2022 16:45:55 +0200 Subject: [PATCH] composer/plugin/drupal-development-environment#6 Add php stand dependencies, configuration and ahoy commands --- ahoy.test.yml | 9 +++++++++ composer.json | 2 ++ src/Handler.php | 3 ++- templates/tests/phpstan.neon | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 templates/tests/phpstan.neon diff --git a/ahoy.test.yml b/ahoy.test.yml index ccc7f4a..9e7990c 100644 --- a/ahoy.test.yml +++ b/ahoy.test.yml @@ -38,3 +38,12 @@ commands: phpunit:list:groups: cmd: ahoy d4d exec vendor/bin/phpunit --configuration /var/www/html/tests/phpunit.xml.dist --list-groups "$@" usage: List available test groups of PHP unit tests + phpstan: + cmd: ahoy d4d exec vendor/bin/phpstan analyze --configuration=/var/www/html/tests/phpstan.neon "$@" + usage: PHPStan tests + phpstanmodule: + cmd: | + module=$1 + shift + ahoy d4d exec vendor/bin/phpstan analyze --configuration=/var/www/html/tests/phpstan.neon web/modules/contrib/$module $@ + usage: PHPStan tests by module diff --git a/composer.json b/composer.json index 1bc53ce..24b333e 100644 --- a/composer.json +++ b/composer.json @@ -49,11 +49,13 @@ "lakedrops/docker4drupal": "*", "lakedrops/dorgflow": "*", "lakedrops/drupal-environment": "*", + "mglaman/phpstan-drupal": "^1.1", "mikey179/vfsstream": "*", "phploc/phploc": "*", "phpmd/phpmd": "*", "phpspec/prophecy": "*", "phpspec/prophecy-phpunit": "*", + "phpstan/phpstan-deprecation-rules": "^1.0", "phpunit/phpunit": "*", "sebastian/phpcpd": "*", "squizlabs/php_codesniffer": "*", diff --git a/src/Handler.php b/src/Handler.php index 200b7c4..af22b29 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -120,13 +120,14 @@ class Handler extends BaseHandler { $handler->configureProject(); // Copy Test files. - foreach (['phpcs.files', 'phpunit.xml.dist'] as $template) { + foreach (['phpcs.files', 'phpstan.neon', 'phpunit.xml.dist'] as $template) { $rendered = $this->config->render($template, file_get_contents($pluginRoot . '/templates/tests/' . $template)); file_put_contents('tests/' . $template, $rendered); } // Git Ignore test files. $this->gitIgnore('tests/phpcs.files'); + $this->gitIgnore('tests/phpstan.neon'); $this->gitIgnore('tests/phpunit.xml.dist'); $this->gitIgnore('tests/codesniffer_results.txt'); $this->gitIgnore('tests/checkstyle.xml'); diff --git a/templates/tests/phpstan.neon b/templates/tests/phpstan.neon new file mode 100644 index 0000000..d94c0d9 --- /dev/null +++ b/templates/tests/phpstan.neon @@ -0,0 +1,15 @@ +parameters: + level: 2 + reportUnmatchedIgnoredErrors: false + customRulesetUsed: true + checkMissingIterableValueType: false + fileExtensions: + - module + - theme + - profile + - install + ignoreErrors: + - '#Plugin definitions cannot be altered.#' +includes: + - /drupal/vendor/mglaman/phpstan-drupal/extension.neon + - /drupal/vendor/phpstan/phpstan-deprecation-rules/rules.neon -- GitLab