You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
rdrew 1ff7f47e26 1st 3 weeks ago
..
Rules 1st 3 weeks ago
fixtures 1st 3 weeks ago
tests 1st 3 weeks ago
.gitignore 1st 3 weeks ago
README.md 1st 3 weeks ago
composer.json 1st 3 weeks ago
phpunit.xml.dist 1st 3 weeks ago

README.md

Drupal custom PHPStan rules

This directory contains PHPStan rules specifically developed for Drupal.

Subdirectories

  • Rules: contains the actual rules.
  • tests: contains PHPUnit tests for the rules.
  • fixtures: contains fixture files for the PHPUnit tests of the rules.

Enabling rules

Rules are executed when they are added to the the phpstan.neon(.dist) configuration file of a PHPStan scan run. You need to add them under the rules entry in the file, specifying the fully qualified class name of the rule. For example:


rules:
  - Drupal\PHPStan\Rules\ComponentTestDoesNotExtendCoreTest

Testing rules

PHPStan rules must be tested in the context of the PHPStan testing framework, that differs in terms of dependencies from Drupal's one.

Note that for this reason, these tests are run separately from Drupal core tests.

A composer.json file is present in this directory, indicating the required packages for the execution of the tests. Installing via composer

$ composer install

builds a vendor subdirectory that includes all the packages required. Note this packages' codebase is totally independent from Drupal core's one.

In the context of this directory, you can then execute the rule tests like

$ vendor/bin/phpunit tests