PHPackages                             zenify/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. zenify/coding-standard

Abandoned → [symplify/easy-coding-standard](/?search=symplify%2Feasy-coding-standard)Library[Utility &amp; Helpers](/categories/utility)

zenify/coding-standard
======================

Set of rules for PHP\_CodeSniffer preferring tabs and based on Nette coding standard.

v4.2(9y ago)1237.9k411MITPHPPHP ^7.0

Since Oct 11Pushed 9y ago4 watchersCompare

[ Source](https://github.com/deprecated-packages/CodingStandard)[ Packagist](https://packagist.org/packages/zenify/coding-standard)[ RSS](/packages/zenify-coding-standard/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (58)Used By (11)

Coding Standard
===============

[](#coding-standard)

[![Build Status](https://camo.githubusercontent.com/6ce9724cd3f6d034c0a6ced5a9e407166f80931d303b67eab0adca042ca69518/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5a656e6966792f436f64696e675374616e646172642e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Zenify/CodingStandard)[![Quality Score](https://camo.githubusercontent.com/3ce986ed7aab3433b8cbe2ae65c1f23a3391175962409c4a916fae1829a5e829/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f5a656e6966792f436f64696e675374616e646172642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Zenify/CodingStandard)[![Code Coverage](https://camo.githubusercontent.com/c83bf326ffb37fcc0cc8e6b5076c3435d15f583f64513d412c92f3b434261d54/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f5a656e6966792f436f64696e675374616e646172642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Zenify/CodingStandard)[![Downloads](https://camo.githubusercontent.com/21e275bc5029e92205796d8f6421681b8451d04c4755565d1e28e2b7c078648d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a656e6966792f636f64696e672d7374616e646172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenify/coding-standard)[![Latest stable](https://camo.githubusercontent.com/6b2563d579fb97a7eeb20847950415d0c4a4ee9237d23d79a76d316a5e246711/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e6966792f636f64696e672d7374616e646172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenify/coding-standard)

Set of rules for [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) preferring tabs and based on [Nette coding standard](http://nette.org/en/coding-standard).

**Check [rules overview](#rules-overview) for examples.**

Install
-------

[](#install)

```
$ composer require zenify/coding-standard --dev
```

Usage
-----

[](#usage)

Run with Php\_CodeSniffer:

```
vendor/bin/phpcs src --standard=vendor/zenify/coding-standard/src/ZenifyCodingStandard/ruleset.xml -p
```

That's all!

How to be both Lazy and Safe
----------------------------

[](#how-to-be-both-lazy-and-safe)

### Composer hook

[](#composer-hook)

In case you don't want to use Php\_CodeSniffer manually for every change in the code you make, you can add pre-commit hook via `composer.json`:

```
"scripts": {
	"post-install-cmd": [
		"Zenify\\CodingStandard\\Composer\\ScriptHandler::addPhpCsToPreCommitHook"
	],
	"post-update-cmd": [
		"Zenify\\CodingStandard\\Composer\\ScriptHandler::addPhpCsToPreCommitHook"
	]
}
```

**Every time you try to commit, Php\_CodeSniffer will run on changed `.php` files only.**

This is much faster than checking whole project, running manually or wait for CI.

*Pretty cool, huh?*

Testing
-------

[](#testing)

```
composer check-cs
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Rules are simple:

- new feature needs tests
- all tests must pass
- 1 feature per PR

We would be happy to merge your feature then!

---

Rules Overview
--------------

[](#rules-overview)

Rules uses default numeric parameters (some can be changed to match your needs).

**TOC:**

- [1 Classes](#1-classes)
- [2 Commenting](#2-commenting)
- [3 Control Structures](#3-control-structures)
- [4 Debug](#4-debug)
- [5 Namespaces](#5-namespaces)
- [6 Naming](#6-naming)

---

### 1 Classes

[](#1-classes)

#### ClassDeclarationSniff

[](#classdeclarationsniff)

- Opening brace for the class should be followed by 1 empty line
- Closing brace for the class should be preceded by 1 empty line

*Correct*

```
class SomeClass
{

	public function run()
	{

	}

}
```

*Wrong*

```
class SomeClass
{
	public function run()
	{

	}
}
```

#### FinalInterfaceSniff

[](#finalinterfacesniff)

- Non-abstract class that implements interface should be final.
- Except for Doctrine entities, they cannot be final.

*Correct*

```
final class SomeClass implements SomeInterface
{

	public function run()
	{

	}

}
```

*Wrong*

```
class SomeClass implements SomeInterface
{

	public function run()
	{

	}

}
```

### 2 Commenting

[](#2-commenting)

#### BlockPropertyCommentSniff

[](#blockpropertycommentsniff)

- Block comment should be used instead of one liner

*Correct*

```
class SomeClass
{

	/**
	 * @var int
	 */
	public $count;

}
```

*Wrong*

```
class SomeClass
{

	/** @var int */
	public $count;

}
```

#### ComponentFactoryCommentSniff

[](#componentfactorycommentsniff)

- CreateComponent\* method should have a doc comment
- CreateComponent\* method should have a return tag
- Return tag should contain type

*Correct*

```
/**
 * @return DisplayComponent
 */
protected function createComponentDisplay()
{
	$this->displayComponentFactory->create();
}
```

*Wrong*

```
protected function createComponentDisplay()
{
	$this->displayComponentFactory->create();
}
```

#### VarPropertyCommentSniff

[](#varpropertycommentsniff)

- Property should have docblock comment.

*Correct*

```
class SomeClass
{

	/**
	 * @var int
	 */
	private $someProperty;

}
```

*Wrong*

```
class SomeClass
{

	private $someProperty;

}
```

#### MethodCommentSniff

[](#methodcommentsniff)

- Method without parameter typehints should have docblock comment.

*Correct*

```
class SomeClass
{

	/**
	 * @param int $values
	 */
	public function count($values)
	{
	}

}
```

```
class SomeClass
{

	public function count(array $values)
	{
	}

}
```

*Wrong*

```
class SomeClass
{

	public function count($values)
	{
	}

}
```

#### MethodCommentReturnTagSniff

[](#methodcommentreturntagsniff)

- Getters should have @return tag or return type.

*Correct*

```
class SomeClass
{

	/**
	 * @return int
	 */
	public function getResult()
	{
		// ...
	}

}
```

*Wrong*

```
class SomeClass
{

	/**
	 * This will return something.
	 */
	public function getResult()
	{
	}

}
```

### 3 Control Structures

[](#3-control-structures)

#### NewClassSniff

[](#newclasssniff)

- New class statement should not have empty parentheses

*Correct*

```
$someClass = new SomeNamespace\SomeClass;
$someClass = new SomeNamespace\SomeClass($keyHandler);
```

*Wrong*

```
$someClass = new SomeNamespace\SomeClass();
```

#### SwitchDeclarationSniff

[](#switchdeclarationsniff)

*Correct*

```
$suit = 'case';

switch ($suit) {
	case 1:
		echo 'ok';
		break;
	default:
		echo 'not ok';
		break;
}
```

*Wrong*

```
$suit = 'case';

switch ($suit) {
case 1:
	echo 'ok';
	break;
}
```

#### YodaConditionSniff

[](#yodaconditionsniff)

- Yoda condition should not be used; switch expression order

*Correct*

```
if ($i === TRUE) {
	return;
}

$go = $decide === TRUE ?: FALSE;
```

*Wrong*

```
if (TRUE === $i) {
	return;
}

$go = TRUE === $decide ?: FALSE;
```

### 4 Debug

[](#4-debug)

#### DebugFunctionCallSniff

[](#debugfunctioncallsniff)

- Debug functions should not be left in the code

*Wrong*

```
dump('It works');
```

### 5 Namespaces

[](#5-namespaces)

#### NamespaceDeclarationSniff

[](#namespacedeclarationsniff)

- There must be 2 empty lines after the namespace declaration or 1 empty line followed by use statement.

*Correct*

```
namespace SomeNamespace;

use PHP_CodeSniffer;

class SomeClass
{

}
```

or

```
namespace SomeNamespace;

class SomeClass
{

}
```

*Wrong*

```
namespace SomeNamespace;

use SomeNamespace;

class SomeClass
{

}
```

or

```
namespace SomeNamespace;

class SomeClass
{

}
```

#### UseDeclarationSniff

[](#usedeclarationsniff)

- There must be one USE keyword per declaration
- There must be 2 blank lines after the last USE statement

*Correct*

```
namespace SomeNamespace;

use Sth;
use SthElse;

class SomeClass
{

}
```

*Wrong*

```
namespace SomeNamespace;

use Sth, SthElse;

class SomeClass
{

}
```

### 6 Naming

[](#6-naming)

#### AbstractClassNameSniff

[](#abstractclassnamesniff)

- Abstract class should have prefix "Abstract"

*Correct*

```
abstract class AbstractClass
{

}
```

*Wrong*

```
abstract class SomeClass
{

}
```

#### InterfaceNameSniff

[](#interfacenamesniff)

- Interface should have suffix "Interface"

*Correct*

```
interface SomeInterface
{

}
```

*Wrong*

```
interface Some
{

}
```

### 7 WhiteSpace

[](#7-whitespace)

#### DocBlockSniff

[](#docblocksniff)

- DocBlock lines should start with space (except first one)

*Correct*

```
/**
 * Counts feelings.
 */
public function ...
```

*Wrong*

```
/**
* Counts feelings.
*/
public function ...
```

#### ExclamationMarkSniff

[](#exclamationmarksniff)

- Not operator (!) should be surrounded by spaces

*Correct*

```
if ( ! $s) {
	return $s;
}
```

*Wrong*

```
if (!$s) {
	return $s;
}
```

#### IfElseTryCatchFinallySniff

[](#ifelsetrycatchfinallysniff)

- Else/elseif/catch/finally statement should be preceded by 1 empty line

*Correct*

```
if ($i === 1) {
	return $i;

} else {
	return $i * 2;
}
```

*Wrong*

```
try (1 === 2) {
	return 3;
} catch (2 === 3) {
	return 4;
} finally (2 === 3) {
	return 4;
}
```

#### InBetweenMethodSpacingSniff

[](#inbetweenmethodspacingsniff)

- Method should have 2 empty lines after itself

*Correct*

```
class SomeClass
{

	public function run()
	{
	}

	public function go()
	{
	}

}
```

*Wrong*

```
class SomeClass
{

	public function run()
	{
	}

	public function go()
	{
	}

}
```

#### PropertiesMethodsMutualSpacingSniff

[](#propertiesmethodsmutualspacingsniff)

- Between properties and methods should be 2 empty lines

*Correct*

```
class SomeClass
{

	private $jet;

	public function run()
	{
	}

}
```

*Wrong*

```
class SomeClass
{

	private $jet;

	public function run()
	{
	}

}
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~14 days

Recently: every ~99 days

Total

57

Last Release

3427d ago

Major Versions

v0.3.1 → v1.0.02014-11-06

v1.0.0 → v2.0.02014-11-14

v2.1.4 → v3.0.02014-12-10

v3.3.4 → v4.0.02016-11-01

PHP version history (4 changes)v2.1.0PHP &gt;=5.4

v3.0.0PHP &gt;=5.5

v3.2.0PHP &gt;=5.6

v4.0.0PHP ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/538058?v=4)[Milan Šulc](/maintainers/f3l1x)[@f3l1x](https://github.com/f3l1x)

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

---

Top Contributors

[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[shopsys/coding-standards

Coding standards definition compatible with PSR-2

20269.1k13](/packages/shopsys-coding-standards)[flyeralarm/php-code-validator

A custom coding standard for FLYERALARM

2226.9k6](/packages/flyeralarm-php-code-validator)

PHPackages © 2026

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