PHPackages                             previousnext/coding-standard - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. previousnext/coding-standard

ActivePhpcodesniffer-standard[Testing &amp; Quality](/categories/testing)

previousnext/coding-standard
============================

1.2.0(2mo ago)350.9k↓46.7%[3 issues](https://github.com/previousnext/coding-standard/issues)[2 PRs](https://github.com/previousnext/coding-standard/pulls)4MITPHPPHP ^8.2CI passing

Since Jan 12Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/previousnext/coding-standard)[ Packagist](https://packagist.org/packages/previousnext/coding-standard)[ Docs](https://github.com/previousnext/coding-standard)[ RSS](/packages/previousnext-coding-standard/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (18)Versions (14)Used By (4)

PreviousNext Drupal Coding Standard
===================================

[](#previousnext-drupal-coding-standard)

[![Latest Stable Version](https://camo.githubusercontent.com/3acd7b73dfc9a906f9a95cd5789c43eff5d1c13d9975736f3b3d8f3131cfc67f/687474703a2f2f706f7365722e707567782e6f72672f70726576696f75736e6578742f636f64696e672d7374616e646172642f76)](https://packagist.org/packages/previousnext/coding-standard)[![Total Downloads](https://camo.githubusercontent.com/b569dba8ee04dc702a1d3ac8811e7dd128f0be50ebabbf5b3212a64c2be86c2a/687474703a2f2f706f7365722e707567782e6f72672f70726576696f75736e6578742f636f64696e672d7374616e646172642f646f776e6c6f616473)](https://packagist.org/packages/previousnext/coding-standard)[![GitHub branch checks state](https://camo.githubusercontent.com/53c6bcbf71d3d777aef2554be03a8584edffc86335f2f9fbcfd4b6ceac776e63/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636865636b732d7374617475732f70726576696f75736e6578742f636f64696e672d7374616e646172642f6d61696e)](https://github.com/previousnext/coding-standard/actions)[![License](https://camo.githubusercontent.com/5e17f74aec6b95ca23d2c2bb406247e115e13786564cf01cad8e1f67707562cf/687474703a2f2f706f7365722e707567782e6f72672f70726576696f75736e6578742f636f64696e672d7374616e646172642f6c6963656e7365)](https://packagist.org/packages/previousnext/coding-standard)

This is a PHP Codesniffer standard enhancing the [Drupal Coder](https://www.drupal.org/project/coder)project. It is designed to be utilised on full Drupal site projects, rather than core or contrib, or projects outside of Drupal.

The standard improves upon the Drupal standard, while maintaining the general style of Drupal.

Rules are loosened where static analysis tools such as PHPStan are better at enforcing.

Documentation rules are loosened, trusting developers to properly self describe code. Suggestions to improve documentation are encouraged during human code review of MR/PR's.

Rules added are generally those we think would be accepted by Drupal Coder itself.

Generally, rules that are not auto-fixable, especially documentation/commenting related, will be stripped from the ruleset.

New rules may be introduced in minor versions. You can choose to lock a version until you are ready, or utilise the baseline project.

License
=======

[](#license)

MIT

Transitioning
=============

[](#transitioning)

Consider using the [Baseliner](https://github.com/123inkt/php-codesniffer-baseline) project when transitioning. A quick `phpcbf` beforehand will eliminate most or all problems before they are added to a baseline.

```
composer require --dev digitalrevolution/php-codesniffer-baseline
php bin/phpcs --report=\\DR\\CodeSnifferBaseline\\Reports\\Baseline --report-file=phpcs.baseline.xml
```

Unlike PHPStan's `reportUnmatchedIgnoredErrors`, warnings will not display when items in the PHPCS baseline are resolved. Instead, work until no CS issues are reported with `phpcs`, then regenerate with the same baseline command above.

Using the standard
==================

[](#using-the-standard)

Use the installer via Composer:

```
composer require dealerdirect/phpcodesniffer-composer-installer
```

Install this project with:

```
composer require previousnext/coding-standard
```

Dependencies such as Coding standard, Drupal Coder, and Slevomat Coding Standard will be brought in automatically.

Configuration Template
----------------------

[](#configuration-template)

Create a `phpcs.xml` file in a project root with the following contents:

```

    ./src
    ./tests
    ./app/modules/custom
    ./app/profiles/custom
    ./app/themes/custom

```

This standard does not assume the location of code, so all covered paths must be added to the extending ruleset.

Tips
====

[](#tips)

Parameters and return documentation may be omitted. If you intend to add typing, but do not care to document what a param or return does, then consider using `@phpstan-` prefixed annotations. Such as `@phpstan-param` or `@phpstan-return`.

**Example**

From *Drupal Coder* style:

```
/**
 * Does a thing.
 *
 * @param array $data
 *   Some data.
 *
 * @return int
 *   An integer.
 */
function foo(array $data): int {
}
```

To:

Remove useless documentation for the function/method itself. Human code review must ensure the function/method/variable/param, etc, are self describing.

```
/**
 * @phpstan-param array{bar: int} $data
 * @phpstan-return int{0, max}
 */
function doesAThing(array $data): int {
}
```

Style
=====

[](#style)

Added Sniffs
------------

[](#added-sniffs)

#### PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose

[](#psr2methodsfunctionclosingbracespacingbeforeclose)

#### SlevomatCodingStandard.Classes.ClassStructure

[](#slevomatcodingstandardclassesclassstructure)

#### SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature

[](#slevomatcodingstandardclassesrequiremultilinemethodsignature)

#### SlevomatCodingStandard.Commenting.UselessInheritDocComment

[](#slevomatcodingstandardcommentinguselessinheritdoccomment)

#### SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator

[](#slevomatcodingstandardcontrolstructuresrequirenullsafeobjectoperator)

#### SlevomatCodingStandard.Functions.RequireTrailingCommaInCall

[](#slevomatcodingstandardfunctionsrequiretrailingcommaincall)

#### SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration

[](#slevomatcodingstandardfunctionsrequiretrailingcommaindeclaration)

#### SlevomatCodingStandard.Functions.StaticClosure

[](#slevomatcodingstandardfunctionsstaticclosure)

#### SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure

[](#slevomatcodingstandardfunctionsunusedinheritedvariablepassedtoclosure)

#### SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses

[](#slevomatcodingstandardnamespacesalphabeticallysorteduses)

#### SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions

[](#slevomatcodingstandardnamespacesfullyqualifiedglobalfunctions)

PHPStorm can be configured with Editor -&gt; General -&gt; Auto Import: *Function*: `Prefer FQN`

#### SlevomatCodingStandard.TypeHints.DeclareStrictTypes

[](#slevomatcodingstandardtypehintsdeclarestricttypes)

#### SlevomatCodingStandard.TypeHints.ReturnTypeHint

[](#slevomatcodingstandardtypehintsreturntypehint)

#### SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing

[](#slevomatcodingstandardtypehintsreturntypehintspacing)

#### Squiz.WhiteSpace.FunctionOpeningBraceSpace.SpacingAfter

[](#squizwhitespacefunctionopeningbracespacespacingafter)

Removed/Loosened Inherited Sniffs
---------------------------------

[](#removedloosened-inherited-sniffs)

#### Drupal.Arrays.Array.LongLineDeclaration

[](#drupalarraysarraylonglinedeclaration)

#### Drupal.Commenting.\*

[](#drupalcommenting)

- Drupal.Commenting.ClassComment.Short
- Drupal.Commenting.DocComment.MissingShort
- Drupal.Commenting.FileComment.Missing
- Drupal.Commenting.FunctionComment.IncorrectParamVarName
- Drupal.Commenting.FunctionComment.InvalidReturn
- Drupal.Commenting.TodoComment.TodoFormat
- Drupal.Commenting.VariableComment.Missing

Commenting rules are not auto-fixable, are usually boilerplate-y.

Developers are entrusted to properly self-describe code. Suggestions to improve documentation are encouraged during human code review of MR/PR's.

#### Squiz.PHP.NonExecutableCode.Unreachable

[](#squizphpnonexecutablecodeunreachable)

This rule has trouble with newer PHP syntax, especially expression throwables. In any case this rule is best enforced with static analysis.

---

*Drupal is a registered trademark of Dries Buytaert.*

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance66

Regular maintenance activity

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 54.2% 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 ~119 days

Recently: every ~220 days

Total

11

Last Release

73d ago

Major Versions

0.2.0 → 1.0.02023-11-21

PHP version history (3 changes)0.1.0PHP ^8.0

1.1.0PHP ^8.1

1.1.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fb4020bd7f47e4b88e336a1049bdd6e376a64125fd7070889de60e00c34ddce?d=identicon)[pnx-bot](/maintainers/pnx-bot)

---

Top Contributors

[![dpi](https://avatars.githubusercontent.com/u/21850?v=4)](https://github.com/dpi "dpi (26 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![kimpepper](https://avatars.githubusercontent.com/u/6132?v=4)](https://github.com/kimpepper "kimpepper (7 commits)")[![acbramley](https://avatars.githubusercontent.com/u/569927?v=4)](https://github.com/acbramley "acbramley (1 commits)")

---

Tags

coding-standarddrupalphpcsdrupal

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/previousnext-coding-standard/health.svg)

```
[![Health](https://phpackages.com/badges/previousnext-coding-standard/health.svg)](https://phpackages.com/packages/previousnext-coding-standard)
```

###  Alternatives

[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k134.0M2.3k](/packages/slevomat-coding-standard)[acquia/coding-standards

PHP\_CodeSniffer rules (sniffs) for Acquia coding standards

225.0M35](/packages/acquia-coding-standards)[drupal/coder

Coder is a library to review Drupal code.

3045.9M577](/packages/drupal-coder)[wp-cli/wp-cli-tests

WP-CLI testing framework

423.1M142](/packages/wp-cli-wp-cli-tests)[youwe/testing-suite

Contains Youwe's default testing packages for php.

13191.0k8](/packages/youwe-testing-suite)

PHPackages © 2026

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