PHPackages                             devstrict/phpcs - 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. devstrict/phpcs

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

devstrict/phpcs
===============

Custom PHP\_CodeSniffer ruleset for strict development standards

v0.2.6(3mo ago)0189MITPHPPHP ^8.3CI failing

Since Nov 25Pushed 1mo agoCompare

[ Source](https://github.com/vix-4800/phpcs-devstrict)[ Packagist](https://packagist.org/packages/devstrict/phpcs)[ RSS](/packages/devstrict-phpcs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (12)Used By (0)

DevStrict - PHP\_CodeSniffer Custom Ruleset
===========================================

[](#devstrict---php_codesniffer-custom-ruleset)

[![CI](https://github.com/vix-4800/phpcs-devstrict/workflows/CI/badge.svg)](https://github.com/vix-4800/phpcs-devstrict/actions)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHPStan](https://camo.githubusercontent.com/43cbcc4193ce0d13c99fbc045f1f6bdd0de0d7f00a1429e751727038a25769f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230382d627269676874677265656e2e7376673f266c6162656c3d7068707374616e)](https://camo.githubusercontent.com/43cbcc4193ce0d13c99fbc045f1f6bdd0de0d7f00a1429e751727038a25769f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230382d627269676874677265656e2e7376673f266c6162656c3d7068707374616e)[![PHP-CS-Fixer](https://camo.githubusercontent.com/4cdf582a8d1aa3d33de37ea1bbed5b968a8a4ec1148b51420e0bbd6fd7305698/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f66697865722d656e61626c65642d627269676874677265656e2e7376673f266c6162656c3d7068702d63732d6669786572)](https://camo.githubusercontent.com/4cdf582a8d1aa3d33de37ea1bbed5b968a8a4ec1148b51420e0bbd6fd7305698/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f66697865722d656e61626c65642d627269676874677265656e2e7376673f266c6162656c3d7068702d63732d6669786572)[![PHPUnit](https://camo.githubusercontent.com/9156635dc7f558d41786cecd0772e39290b8eebbf830d66d8ff3668d5cc1a734/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7465737465642d656e61626c65642d627269676874677265656e2e7376673f266c6162656c3d706870756e6974)](https://camo.githubusercontent.com/9156635dc7f558d41786cecd0772e39290b8eebbf830d66d8ff3668d5cc1a734/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7465737465642d656e61626c65642d627269676874677265656e2e7376673f266c6162656c3d706870756e6974)[![PHP Version](https://camo.githubusercontent.com/ef0054230522e542bc1f908ac005c6c75888dea255bac910f9015e12095e31d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c7565)](https://www.php.net/)

A comprehensive set of strict PHP\_CodeSniffer rules for general PHP, Laravel, and Yii2 projects to maintain high code quality standards in your projects.

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

[](#installation)

### Requirements

[](#requirements)

- PHP 8.3 or higher
- Composer

### Install via Composer

[](#install-via-composer)

```
composer require --dev devstrict/phpcs
```

Usage
-----

[](#usage)

### Basic Configuration

[](#basic-configuration)

Create a `phpcs.xml` file in your project root:

```

    My project coding standard

    src
    tests

```

Rulesets
--------

[](#rulesets)

### DevStrict

[](#devstrict)

The main ruleset includes all available rules. See [RULES.md](RULES.md) for detailed documentation of each rule.

**Core Rules:**

- [`DevStrict.Attributes.ForbiddenAttributes`](RULES.md#devstrictattributesforbiddenattributes) - Disallow specific attributes (e.g. `#[ArrayShape]`)
- [`DevStrict.ControlStructures.DisallowCountInLoop`](RULES.md#devstrictcontrolstructuresdisallowcountinloop) - Prevent `count()` in loop conditions for performance
- [`DevStrict.ControlStructures.DisallowGotoStatement`](RULES.md#devstrictcontrolstructuresdisallowgotostatement) - Disallow `goto` statements as anti-pattern
- [`DevStrict.ControlStructures.DisallowThrowInTernary`](RULES.md#devstrictcontrolstructuresdisallowthrowinternary) - No exceptions in ternary operators
- [`DevStrict.ControlStructures.UseInArray`](RULES.md#devstrictcontrolstructuresuseinarray) - Suggest `in_array()` for multiple OR comparisons
- [`DevStrict.Formatting.MethodChainingIndentation`](RULES.md#devstrictformattingmethodchainingindentation) - Enforce four-space indentation for multi-line method chains
- [`DevStrict.Formatting.MethodChainingPerLine`](RULES.md#devstrictformattingmethodchainingperline) - Require one chained call per line once the chain is broken
- [`DevStrict.Formatting.ConsistentStatementIndentation`](RULES.md#devstrictformattingconsistentstatementindentation) - Keep statements at the same nesting level aligned with identical indentation
- [`DevStrict.Formatting.DisallowMultipleThrowsPerLine`](RULES.md#devstrictformattingdisallowmultiplethrowsperline) - Require separate `@throws` annotations for each exception type
- [`DevStrict.Functions.DisallowCastFunctions`](RULES.md#devstrictfunctionsdisallowcastfunctions) - Use type casts instead of `strval()`, `intval()`, `floatval()`, `boolval()`
- [`DevStrict.Functions.PreferModernStringFunctions`](RULES.md#devstrictfunctionsprefermodernstringfunctions) - Suggest modern string functions (`str_contains()`, `str_starts_with()`, `str_ends_with()`) instead of `strpos()`
- [`DevStrict.Functions.PreferJsonValidate`](RULES.md#devstrictfunctionspreferjsonvalidate) - Suggest `json_validate()` instead of `json_decode()` for validation-only use cases
- [`DevStrict.Objects.DisallowVariableStaticProperty`](RULES.md#devstrictobjectsdisallowvariablestaticproperty) - Forbid `$object::$property` static property access

**Yii2 Framework Rules:**

- [`DevStrict.Yii2.DisallowResponseFormatAssignment`](RULES.md#devstrictyii2disallowresponseformatassignment) - Use controller methods like `asJson()` instead of direct assignment
- [`DevStrict.Yii2.PreferActiveRecordShortcuts`](RULES.md#devstrictyii2preferactiverecordshortcuts) - Suggest `findOne()`/`findAll()` over `find()->where()->one()/all()`
- [`DevStrict.Yii2.PreferExistsOverCount`](RULES.md#devstrictyii2preferexistsovercount) - Use `exists()` instead of `count() > 0` for better performance
- [`DevStrict.Yii2.PreferIsGuestOverUserIdCheck`](RULES.md#devstrictyii2preferisguestoveruseridcheck) - Use `Yii::$app->user->isGuest` instead of checking `id` directly

Development
-----------

[](#development)

### Guidelines

[](#guidelines)

- All new sniffs must have tests
- Follow the existing code style
- Update documentation when necessary
- Ensure all checks pass (`composer check`)

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Additional Resources
--------------------

[](#additional-resources)

- [PHP\_CodeSniffer Documentation](https://github.com/squizlabs/PHP_CodeSniffer/wiki)
- [Creating Custom Sniffs](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance86

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.6% 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 ~10 days

Total

8

Last Release

100d ago

### Community

Maintainers

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

---

Top Contributors

[![vix-4800](https://avatars.githubusercontent.com/u/55950607?v=4)](https://github.com/vix-4800 "vix-4800 (113 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")

---

Tags

phpcsdevstatic analysiscode sniffercoding-standards

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/devstrict-phpcs/health.svg)

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

###  Alternatives

[slevomat/coding-standard

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

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[wp-coding-standards/wpcs

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

2.8k42.5M1.6k](/packages/wp-coding-standards-wpcs)[escapestudios/symfony2-coding-standard

CodeSniffer ruleset for the Symfony 2+ coding standard

40611.1M275](/packages/escapestudios-symfony2-coding-standard)[phpcompatibility/phpcompatibility-wp

A ruleset for PHP\_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.

22130.6M587](/packages/phpcompatibility-phpcompatibility-wp)[sirbrillig/phpcs-variable-analysis

A PHPCS sniff to detect problems with variables.

14548.5M97](/packages/sirbrillig-phpcs-variable-analysis)[phpcsstandards/phpcsextra

A collection of sniffs and standards for use with PHP\_CodeSniffer.

10324.3M44](/packages/phpcsstandards-phpcsextra)

PHPackages © 2026

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