drupol/php-conventions

PHP conventions based on Grumphp tasks.

Fund package maintenance!
drupol

1.8.16 2020-08-04 14:02 UTC

README

Latest Stable Version GitHub stars Total Downloads License Say Thanks! Donate!

PHP conventions

This development tool provides a pre-defined configuration for GrumPHP with the following checks enabled:

The package provides a default configuration for each task, and it's customizable at will through a simple configuration file.

The package will install the required dependencies, so it works out of the box.

Tasks can be also added or skipped according to your need.

Installation

composer require drupol/php-conventions:^1.8 --dev

If you're not using GrumPHP

Manually add to your composer.json file

    "extra": {
        "grumphp": {
            "config-default-path": "vendor/drupol/php-conventions/config/php71/grumphp.yml"
        }
    }

Replace the string php71 with the minimal version of php you want to support.

Current choices are:

  • psr12
  • php71
  • php73

If you're using GrumPHP already

Edit the file grumphp.yml.dist or grumphp.yml and add on the top it:

imports:
  - { resource: vendor/drupol/php-conventions/config/php71/grumphp.yml }

To add an extra Grumphp task:

imports:
  - { resource: vendor/drupol/php-conventions/config/php71/grumphp.yml }

parameters:
  extra_tasks:
    infection:
      threads: 1
      test_framework: phpspec
      configuration: infection.json.dist
      min_msi: 60
      min_covered_msi: 60
  skip_tasks:
    - phpcs

In conjunction with extra_tasks, use skip_tasks to skip tasks if needed.

Testsuites

Do you want to specify some pre-defined tasks you want to run? It is easy to configure and run custom testsuites.

Available testsuites are:

  • cs (composer, composer_normalize, yamllint, phplint, twigcs, phpcsfixer, phpcs)
  • static-analysis (phpstan)
  • security (securitychecker)

To run a particular testsuite:

./vendor/bin/grumphp run --testsuite=cs

Contributing

See the file CONTRIBUTING.md but feel free to contribute to this library by sending Github pull requests.