PHPackages                             lunr/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. lunr/coding-standard

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

lunr/coding-standard
====================

Lunr Coding Standard for PHP\_CodeSniffer

0.12.1(1mo ago)03914[1 issues](https://github.com/lunr-php/lunr-coding-standard/issues)1MITPHPPHP ^8.3

Since Aug 3Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/lunr-php/lunr-coding-standard)[ Packagist](https://packagist.org/packages/lunr/coding-standard)[ RSS](/packages/lunr-coding-standard/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (8)Versions (7)Used By (1)

Format style
============

[](#format-style)

Generic
-------

[](#generic)

- Always use Unix line endings.
- Lines should not be longer than 150 characters.
- Don't use PHP Short open tags, except the short echo tags.
- The PHP open tag should be on a line by itself.
- Use 4 spaces for indentation. NO TABS.
- Every scope change has a new 4 space indentation
- Every file should have a closing PHP tag
- All PHP files must end with a non-blank line, terminated with a single LF.
- When variables are assigned on multiple consecutive lines, the equals signs should be aligned.
- There should never be a space preceding a semicolon.
- Empty lines should not have whitespace.
- There should never be multiple successive empty lines.
- Lines should never end in whitespace.

General
-------

[](#general)

- PHP language constructs must be followed by a single whitespace.

Files
-----

[](#files)

- The header section in every file is categorized in blocks. Each block needs to be grouped together and separated by an empty line from the next block.
- Blocks in the header section need to be in this order:
    - Opening PHP tag
    - File-level docblock
    - Declare statements
    - Namespace declaration
    - Class-based use imports
    - Function-based use imports
    - Constant-based use imports

Types
-----

[](#types)

- There must not be a space before the colon of a function return type declaration.
- There must be one space after the colon of a function return type declaration.

Collections
-----------

[](#collections)

- Arrays should always use the short syntax.
- Arrays spanning multiple lines need to have 1 value per line.
- Associative arrays spanning multiple lines needs to have their key, values and double arrows aligned. With at least one space on either side of the double arrow.
- In multi line arrays each line needs to end in a comma, including the last one.
- In multi line arrays the closing bracket needs to be on its own line, in line with the indentation of the start of the declaration.
- Single line arrays need one space separating each bracket from the values.

```
$items  = [ 'item', 'more' ];
$config = [
   'field'   => 'fieldB',
   'search'  => '0',
   'replace' => 'b',
];
```

Naming
------

[](#naming)

- All constants names should be in all uppercase
- Use camelCaps naming for variables
- Use camelCaps naming for function and method names. snake\_case is allowed for legacy compatibility
- Class naming should be in PascalCase.

Comments
--------

[](#comments)

- All files should have a file comment
- All classes should have a class comment
- All functions should have a function comment with a description, a list of parameters (with type, name and description) and a return, but no type hints in the function.

Functions
---------

[](#functions)

- In the argument list, there must not be a space before each comma, and there must be one space after each comma.
- Function declarations must follow the "BSD/Allman style". The function brace is on the line following the function declaration and is indented to the same column as the start of the function declaration.
- Functions must always have visibility defined (public, protected, private); abstract and final MUST be declared before the visibility; static MUST be declared after the visibility
- There must be an empty line before and after each function in a class.
- There must be a single space after the scope keyword.
- The closing bracket must be directly after the body.
- All function keywords must be lowercase.
- Closures must have one space between the `function` keyword and the opening bracket, one space before and after the `use` keyword and one space before the curly bracket of the body
- If the closure body is empty, there must be no space between the curly brackets. If it is not empty there must be one space after the opening and before the closing curly bracket
- Arrow functions must have no space between the `fn` keyword and the opening bracket, and a space before and after the `=>`

Control structures
------------------

[](#control-structures)

- Make sure there are no spaces directly after the opening bracket or before the closing bracket.
- Each line in a multi-line IF statement must begin with a boolean operator
- First condition of a multi-line IF statement must directly follow the opening parenthesis.
- Closing parenthesis of a multi-line IF statement must be on a new line.
- Always use elseif over else if.
- All control structure keywords must be lowercase.
- Control structure bracket spacing should be according to [psr-2/#5-control-structures](https://www.php-fig.org/psr/psr-2/#5-control-structures)

Classes
-------

[](#classes)

- Classes must have their opening bracket on a new line and not have it indented.
- There must be a single space after the scope keyword.
- All class keywords must be lowercase.
- There must be only one class declaration per file

Use declarations
----------------

[](#use-declarations)

- Use declarations should be according to PSR-2 [psr-2/#3-namespace-and-use-declarations](https://www.php-fig.org/psr/psr-2/#3-namespace-and-use-declarations)
- Use imports should be sorted alphabetically
- All classes from other namespaces should be referenced through use statements
- Classes from the same namespace should not be referenced through use statements

Strings
-------

[](#strings)

- Always have one space preceding and succeeding the concatenation symbol.

Operators
---------

[](#operators)

- There must be one space before and after a logical operator.
- All operators should have one space surrounding them.
- There should be one space after a cast operator.
- There should be no spaces between a variable and the increment/decrement operators.
- There should be no spaces after the spread operator.

Code style
==========

[](#code-style)

PHP Function usage
------------------

[](#php-function-usage)

- Some function aliases should not be used.
    - Use count instead of sizeof
    - Use unset instead of delete
- Functions that are deprecated in PHP should not be used.
- Only ever use include\_once in conditionals and use require\_once otherwise.

Types
-----

[](#types-1)

- Nullable type declarations must not have a space between the question mark and the type name.
- Use short versions of types:
    - Use int instead of integer
    - Use bool instead of boolean

Strings
-------

[](#strings-1)

- String concatenation should not be used if the string could be written as one string.
- Double quotes should only be used when required, always use single quotes instead.

Operators
---------

[](#operators-1)

- Never use the logical "and" and "or" operators.
- Never use the backtick operator.

Classes
-------

[](#classes-1)

- Classes must use a PHP5 style constructor.
- Class constants must have visibility declared.

Functions
---------

[](#functions-1)

- Empty functions should contain a //NO-OP comment.
- Use of call-time pass-by-reference is not allowed.

Control structures
------------------

[](#control-structures-1)

- Use of [Yoda conditions](https://en.wikipedia.org/wiki/Yoda_conditions) is not allowed
- Guard clauses should be used where possible to return from functions early

Tests
-----

[](#tests)

- Test classes should be ordered the same way the system under test is: tests for the first failure first, ending in the succesful cases.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance93

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.1% 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 ~130 days

Recently: every ~158 days

Total

6

Last Release

36d ago

PHP version history (2 changes)0.10.0PHP ^8.1

0.12.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d947cb57fe64548b6f9eda414f1add9b39e62200c6f509af20db0119bb8b245?d=identicon)[pprkut](/maintainers/pprkut)

---

Top Contributors

[![pprkut](https://avatars.githubusercontent.com/u/56635?v=4)](https://github.com/pprkut "pprkut (135 commits)")[![SMillerDev](https://avatars.githubusercontent.com/u/1484494?v=4)](https://github.com/SMillerDev "SMillerDev (3 commits)")[![DavidCova](https://avatars.githubusercontent.com/u/17008531?v=4)](https://github.com/DavidCova "DavidCova (1 commits)")

---

Tags

lunrone-flowossphpphpcsdev

### Embed Badge

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

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

###  Alternatives

[slevomat/coding-standard

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

1.5k130.4M2.1k](/packages/slevomat-coding-standard)[wp-cli/wp-cli-tests

WP-CLI testing framework

423.0M129](/packages/wp-cli-wp-cli-tests)[acquia/coding-standards

PHP\_CodeSniffer rules (sniffs) for Acquia coding standards

204.9M33](/packages/acquia-coding-standards)[youwe/testing-suite

Contains Youwe's default testing packages for php.

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

PHPackages © 2026

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