achttienvijftien/building-techniques

Building techniques for WordPress

Installs: 562

Dependents: 7

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Type:phpcodesniffer-standard

1.1.0 2024-10-10 08:37 UTC

This package is auto-updated.

Last update: 2024-11-17 07:27:45 UTC


README

This package contains the building techniques (=code style) used in WordPress projects.

About

This package provides a ruleset for PHP_CodeSniffer that extends the ruleset for Timber, which is composed of the WordPress coding standard with some added exceptions. The deviations from the WordPress coding standard are:

  • Class filenames should adhere to PSR-4.
  • Classnames should use StudlyCaps.
  • Lines should be 100 chars long maximum (triggers warning),
  • Lines should in no case exceed 120 characters (triggers error).
  • Allow / as word delimiter in hook names.
  • Allow short array syntax ([]).

Prerequisites

Install Composer to add this package to your project.

Installing

Install the package using composer:

composer require --dev achttienvijftien/building-techniques

After the installation, the phpcs and phpcbf scripts are available in the vendor/bin folder.

We recommend also installing phpcodesniffer-composer-installer to automatically register the coding standard with PHP_CodeSniffer:

composer require --dev dealerdirect/phpcodesniffer-composer-installer

Now, the coding standard should be available for use when running phpcs. You can check the installed coding standards by running:

./vendor/bin/phpcs -i

The list should contain 1815BuildingTechniques.

Usage

To run PHP_CodeSniffer with the appropriate coding standard:

./vendor/bin/phpcs --standard=1815BuildingTechniques path/to/file-or-directory

To fix code style violations that can be corrected automatically:

./vendor/bin/phpcbf --standard=1815BuildingTechniques path/to/file-or-directory

Adding composer scripts

Composer scripts for phpcs and phpcbf can be added to composer.json for convenience.

{
    "scripts": {
        "format": "phpcbf --standard=1815BuildingTechniques --report-summary --report-source",
        "lint": "phpcs --standard=1815BuildingTechniques"
    }
}

IDE Support

Please refer to the Wiki for guides on integrating PHP_Codesniffer with IDEs like PhpStorm.