Skip to content

openeuropa/code-review-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

code-review-library

Packagist

Coding standard dependencies for PHP libraries.

Make automatic conventions checking on each commit via GrumPHP.

Installation

Install the code review component via Composer:

composer require --dev openeuropa/code-review-library

In your project root create the following grumphp.yml.dist:

imports:
  - { resource: ./vendor/openeuropa/code-review-library/dist/library-conventions.yml }

Commands

GrumPHP tasks will be run at every commit, if you wish to run them without performing a commit use the following command:

./vendor/bin/grumphp run

If you want to simulate the tasks that will be run when creating a new commit:

./vendor/bin/grumphp git:pre-commit

Check GrumPHP documentation for more.

Customization

This component offers a variety of ready conventions that all projects need to follow. This list of default conventions can be found in CONVENTIONS.md.

Since GrumPHP uses the Symfony Dependency Injection component you can override specific parameters in your project's grumphp.yml.dist file as follows:

imports:
  - { resource: ./vendor/openeuropa/code-review-library/dist/library-conventions.yml }

parameters:
  tasks.git_commit_message.matchers: ['/^JIRA-\d+: [A-Z].+\./']

Below the list of task parameters can that be overridden on a per-project basis:

  • tasks.phpcs.standard
  • tasks.phpcs.ignore_patterns
  • tasks.phpcs.triggered_by
  • tasks.phpcs.whitelist_patterns
  • tasks.phpcs.warning_severity
  • tasks.phpstan.autoload_file
  • tasks.phpstan.configuration
  • tasks.phpstan.level
  • tasks.phpstan.force_patterns
  • tasks.phpstan.triggered_by
  • tasks.git_commit_message.matchers

It is also possible to extend the list of tasks to be run by adding tasks under the tasks: tree as shown below:

imports:
  - { resource: ./vendor/openeuropa/code-review-library/dist/library-conventions.yml }

grumphp:
  tasks:
    phpparser: ~

GrumPHP already has a series of tasks that can be used out of the box, you can find the complete list in the GrumPHP tasks page.

If you wih you can create your own tasks as explained in the GrumPHP extensions page.

Transition from code-review 2.x

If you wish to transition to code-review-library from code-review version 2.x, please replace the package via Composer:

composer remove --dev openeuropa/code-review
composer require --dev openeuropa/code-review-library

Besides replacement of the package, some adjustments are needed in grumphp.yml file.

This component removes ExtraTasks extension. Any aditional task previously declared in extra_tasks will need to be placed inside tasks under grumphp tree.

- extra_tasks:
-   phpparser:
-      ignore_patterns:
-       - vendor/
-
- grumphp:
-   extensions:
-     - OpenEuropa\CodeReview\ExtraTasksExtension

+ grumphp:
+   tasks:
+     phpparser:
+      ignore_patterns:
+        - vendor/

In addition, PHP Mess Detector is no longer available as part of the configured tasks. The task and related parameters have been removed. If you wish to continue using PHP Mess Detector, you can add it as part of GrumPHP as previously described.

All other conventions and parameters remain the same.

About

Coding standard dependencies for PHP libraries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published