PHPackages                             yoast/yoastcs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. yoast/yoastcs

ActivePhpcodesniffer-standard[PSR &amp; Standards](/categories/psr-standards)

yoast/yoastcs
=============

PHP\_CodeSniffer rules for Yoast projects

3.4.1(2mo ago)221.1M↓10.8%1[16 issues](https://github.com/Yoast/yoastcs/issues)20MITPHPPHP &gt;=7.2CI passing

Since Jan 8Pushed 1mo ago13 watchersCompare

[ Source](https://github.com/Yoast/yoastcs)[ Packagist](https://packagist.org/packages/yoast/yoastcs)[ Docs](https://github.com/Yoast/yoastcs)[ RSS](/packages/yoast-yoastcs/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (26)Versions (38)Used By (20)

Yoast Coding Standards
======================

[](#yoast-coding-standards)

[![Coverage Status](https://camo.githubusercontent.com/2c486dfd3960856740d19c1caefb2cb90d34775ea851532dd91351aec71b4b23/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f596f6173742f796f61737463732f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/Yoast/yoastcs?branch=develop)

Yoast Coding Standards (YoastCS) is a project with rulesets for code style and quality tools to be used in Yoast projects.

Installation
------------

[](#installation)

### Standalone

[](#standalone)

Standards are provided as a [Composer](https://getcomposer.org/) package and can be installed with:

```
composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer global require --dev yoast/yoastcs:"^3.0"
```

### As dependency

[](#as-dependency)

To include standards as part of a project require them as development dependencies:

```
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer require --dev yoast/yoastcs:"^3.0"
```

Composer will automatically install dependencies and register YoastCS and other external standards with PHP\_CodeSniffer.

Tools provided via YoastCS
--------------------------

[](#tools-provided-via-yoastcs)

- PHP Parallel Lint
- PHP\_CodeSniffer and select standards for PHP\_CodeSniffer, including a number of Yoast native sniffs.

PHP Parallel Lint
-----------------

[](#php-parallel-lint)

[PHP Parallel Lint](https://github.com/php-parallel-lint/PHP-Parallel-Lint/) is a tool to lint PHP files against parse errors.

PHP Parallel Lint does not use a configuration file, so [command-line options](https://github.com/php-parallel-lint/PHP-Parallel-Lint/#command-line-options) need to be passed to configure what files to scan.

It is best practice within the Yoast projects, to add a script to the `composer.json` file which encapsules the command with the appropriate command-line options to ensure that running the tool will yield the same results each time.

Typically, (a variation on) the following snippet would be added to the `composer.json` file for a project:

```
    "scripts" : {
        "lint": [
            "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git"
        ]
    }
```

PHP Code Sniffer
----------------

[](#php-code-sniffer)

Set of [PHP\_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) rules.

Severity levels:

- error level issues are considered mandatory to fix in Yoast projects and enforced in continuous integration
- warning level issues are considered recommended to fix

### The YoastCS Standard

[](#the-yoastcs-standard)

The `Yoast` standard for PHP\_CodeSniffer is comprised of the following:

- The `WordPress` ruleset from the [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards) implementing the official [WordPress PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/), with some [select exclusions](https://github.com/Yoast/yoastcs/blob/develop/Yoast/ruleset.xml#L29-L75).
- The [`PHPCompatibilityWP`](https://github.com/PHPCompatibility/PHPCompatibilityWP) ruleset which checks code for PHP cross-version compatibility while preventing false positives for functionality polyfilled within WordPress.
- The [`VariableAnalysis`](https://github.com/sirbrillig/phpcs-variable-analysis/) ruleset.
- Select additional sniffs taken from [`PHP_CodeSniffer`](https://github.com/PHPCSStandards/PHP_CodeSniffer).
- Select additional sniffs taken from [`PHPCSExtra`](https://github.com/PHPCSStandards/PHPCSExtra).
- Select additional sniffs taken from [`SlevomatCodingStandard`](https://github.com/slevomat/coding-standard).
- Select additional sniffs taken from [WordPress VIP Coding Standards](https://github.com/Automattic/VIP-Coding-Standards/).
- A number of custom Yoast specific sniffs.

Files within version management and dependency related directories, such as the Composer `vendor` directory, are excluded from the scans by default.

#### Sniffs

[](#sniffs)

To obtain a list of all sniffs used within YoastCS:

```
"vendor/bin/phpcs" -e --standard=Yoast
```

#### Sniff Documentation

[](#sniff-documentation)

Not all sniffs have documentation available about what they sniff for, but for those which do, this documentation can be viewed from the command-line:

```
"vendor/bin/phpcs" --standard=Yoast --generator=Text
```

### Running the sniffs

[](#running-the-sniffs)

#### Command line

[](#command-line)

```
"vendor/bin/phpcs" --extensions=php /path/to/folder/
```

For more command-line options, please have a read through the [PHP\_CodeSniffer documentation](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage).

#### Yoast plugin repositories

[](#yoast-plugin-repositories)

All Yoast plugin repositories contain a `[.]phpcs.xml.dist` file which contains the repository specific configuration.

From the root of these repositories, you can run PHPCS by using:

```
composer check-cs-warnings
```

#### PhpStorm

[](#phpstorm)

Refer to [Using PHP Code Sniffer Tool](https://www.jetbrains.com/phpstorm/help/using-php-code-sniffer-tool.html) in the PhpStorm documentation.

After installation, the `Yoast` standard will be available as a choice in PHP Code Sniffer Validation inspection.

### The YoastCS "Threshold" report

[](#the-yoastcs-threshold-report)

The YoastCS package includes a custom `YoastCS\Yoast\Reports\Threshold` report for PHP\_CodeSniffer to compare the current PHPCS run results with predefined "threshold" settings.

The report will look in the runtime environment for the following two environment variables and will take the values of those as the thresholds to compare the PHPCS run results against:

- `YOASTCS_THRESHOLD_ERRORS`
- `YOASTCS_THRESHOLD_WARNINGS`

If the environment variables are not set, they will default to 0 for both, i.e. no errors or warnings allowed.

The report will not print any details about the issues found, it just shows a summary based on the thresholds:

```
PHP CODE SNIFFER THRESHOLD COMPARISON
------------------------------------------------------------------------------------------------------------------------
Coding standards ERRORS: 148/130.
Coding standards WARNINGS: 539/539.

Please fix any errors introduced in your code and run PHPCS again to verify.
Please fix any warnings introduced in your code and run PHPCS again to verify.

```

After the report has run, a global `YOASTCS_ABOVE_THRESHOLD` constant (boolean) will be available which can be used in calling scripts.

To use this report, run PHPCS with the following command-line argument: `--report=YoastCS\Yoast\Reports\Threshold`. *Note: depending on the OS the command is run on, the backslashes in the report name may need to be escaped (doubled).*

For those Yoast plugin repositories which use thresholds, the status can be checked locally by running:

```
composer check-cs-thresholds
```

Changelog
---------

[](#changelog)

The changelog for this package can be found in the [CHANGELOG.md](https://github.com/Yoast/yoastcs/blob/develop/CHANGELOG.md) file.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance73

Regular maintenance activity

Popularity47

Moderate usage in the ecosystem

Community37

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 75.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~137 days

Recently: every ~177 days

Total

28

Last Release

66d ago

Major Versions

0.5 → 1.02018-08-24

1.3.0 → 2.0.02019-12-17

2.3.1 → 3.0.02023-12-14

PHP version history (2 changes)0.5PHP &gt;=5.4

3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c276f443673da81d365a16828d46818ea4e3136f7ce05491abcc70f43c82fa4c?d=identicon)[jrfnl](/maintainers/jrfnl)

![](https://www.gravatar.com/avatar/6629c5cbca8a0a1133c6a3a9df23fe802036694d8d79b10b7606a4355e5cb6df?d=identicon)[YoastSystem](/maintainers/YoastSystem)

![](https://www.gravatar.com/avatar/802d833fa2bf883123eb3f8cb032848abf23ca6da4f0dbe867ebcd8448820679?d=identicon)[jdevalk](/maintainers/jdevalk)

---

Top Contributors

[![jrfnl](https://avatars.githubusercontent.com/u/663378?v=4)](https://github.com/jrfnl "jrfnl (746 commits)")[![moorscode](https://avatars.githubusercontent.com/u/2005352?v=4)](https://github.com/moorscode "moorscode (64 commits)")[![IreneStr](https://avatars.githubusercontent.com/u/17744553?v=4)](https://github.com/IreneStr "IreneStr (50 commits)")[![Rarst](https://avatars.githubusercontent.com/u/737584?v=4)](https://github.com/Rarst "Rarst (38 commits)")[![enricobattocchi](https://avatars.githubusercontent.com/u/15989132?v=4)](https://github.com/enricobattocchi "enricobattocchi (22 commits)")[![atimmer](https://avatars.githubusercontent.com/u/584693?v=4)](https://github.com/atimmer "atimmer (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![karlijnbok](https://avatars.githubusercontent.com/u/43582255?v=4)](https://github.com/karlijnbok "karlijnbok (5 commits)")[![johannadevos](https://avatars.githubusercontent.com/u/20280513?v=4)](https://github.com/johannadevos "johannadevos (5 commits)")[![bintzandt](https://avatars.githubusercontent.com/u/8782235?v=4)](https://github.com/bintzandt "bintzandt (4 commits)")[![diedexx](https://avatars.githubusercontent.com/u/5352634?v=4)](https://github.com/diedexx "diedexx (3 commits)")[![increddibelly](https://avatars.githubusercontent.com/u/3604126?v=4)](https://github.com/increddibelly "increddibelly (3 commits)")[![Dieterrr](https://avatars.githubusercontent.com/u/16388834?v=4)](https://github.com/Dieterrr "Dieterrr (3 commits)")[![JoseeWouters](https://avatars.githubusercontent.com/u/12784125?v=4)](https://github.com/JoseeWouters "JoseeWouters (2 commits)")[![igorschoester](https://avatars.githubusercontent.com/u/35524806?v=4)](https://github.com/igorschoester "igorschoester (2 commits)")[![thijsoo](https://avatars.githubusercontent.com/u/6975345?v=4)](https://github.com/thijsoo "thijsoo (1 commits)")[![hansjovis](https://avatars.githubusercontent.com/u/10195175?v=4)](https://github.com/hansjovis "hansjovis (1 commits)")[![jcomack](https://avatars.githubusercontent.com/u/4181340?v=4)](https://github.com/jcomack "jcomack (1 commits)")[![leonidasmi](https://avatars.githubusercontent.com/u/12400734?v=4)](https://github.com/leonidasmi "leonidasmi (1 commits)")[![GaryJones](https://avatars.githubusercontent.com/u/88371?v=4)](https://github.com/GaryJones "GaryJones (1 commits)")

---

Tags

coding-standardsmess-detectorphpstandardsphpcswordpressstatic analysisyoast

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yoast-yoastcs/health.svg)

```
[![Health](https://phpackages.com/badges/yoast-yoastcs/health.svg)](https://phpackages.com/packages/yoast-yoastcs)
```

###  Alternatives

[automattic/vipwpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions

25510.2M145](/packages/automattic-vipwpcs)[wp-coding-standards/wpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress coding conventions

2.8k42.5M1.6k](/packages/wp-coding-standards-wpcs)[wptrt/wpthemereview

PHP\_CodeSniffer rules (sniffs) to verify theme compliance with the rules for theme hosting on wordpress.org

217736.5k29](/packages/wptrt-wpthemereview)[infinum/eightshift-coding-standards

Eightshift WordPress Coding Standards

1785.2k3](/packages/infinum-eightshift-coding-standards)[inpsyde/php-coding-standards

PHP 7.4+ coding standards for Syde WordPress projects.

101163.9k45](/packages/inpsyde-php-coding-standards)[mayflower/mo4-coding-standard

PHP CodeSniffer ruleset implementing the MO4 coding standards extending the Symfony coding standards.

17508.3k5](/packages/mayflower-mo4-coding-standard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
