diff --git a/ahoy.test.yml b/ahoy.test.yml
index ccc7f4a95d8884a5f43c204e16375089b723276b..9e7990cdbb17be0ea804e4df4e048a8e74395f31 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 1bc53cef351333fbebc5e6412b0dfb80d3acea8e..24b333ec57b02c2f618de065ba5afcd98a129336 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 200b7c43a8dede7d72586fb9ffbff6c9974f8f5e..af22b296423cb445613fbb8788527b22ff725190 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 0000000000000000000000000000000000000000..d94c0d97c29769cf05b3b8ca3b5a9c142c48af04
--- /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