PHPackages                             suin/phpcs-psr4-sniff - 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. suin/phpcs-psr4-sniff

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

suin/phpcs-psr4-sniff
=====================

PHP\_CodeSniffer sniff that checks class name matches PSR-4 project structure.

v3.0.0(4y ago)271.7M—0.9%17[3 PRs](https://github.com/suin/phpcs-psr4-sniff/pulls)16MITPHPPHP &gt;=7.1

Since Sep 19Pushed 2y ago3 watchersCompare

[ Source](https://github.com/suin/phpcs-psr4-sniff)[ Packagist](https://packagist.org/packages/suin/phpcs-psr4-sniff)[ Docs](https://github.com/suin/php)[ RSS](/packages/suin-phpcs-psr4-sniff/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (14)Used By (16)

suin/phpcs-psr4-sniff
=====================

[](#suinphpcs-psr4-sniff)

A custom [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) sniff to help to find classes that is not compliant with [PSR-4 Autoloader](https://www.php-fig.org/psr/psr-4/).

Demo
----

[](#demo)

[![](tests/demo/demo.png)](tests/demo/demo.png)

Please visit [./tests/demo](/tests/demo), if you would like to try this sniff.

Features
--------

[](#features)

### Classes, interfaces and traits

[](#classes-interfaces-and-traits)

This sniff covers not only classes but also interfaces and traits.

### Namespaces and class names

[](#namespaces-and-class-names)

This sniff checks whether both of namespaces and class names match PSR-4 project structure.

### Configuration free

[](#configuration-free)

As this sniff respects `composer.json` [autoloading configuration](https://getcomposer.org/doc/04-schema.md#psr-4), you don't have to declare mapping between namespace prefixes and base directories.

Similar packages
----------------

[](#similar-packages)

### Psr4Fixer of PHP-CS-Fixer

[](#psr4fixer-of-php-cs-fixer)

[Psr4Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/src/Fixer/Basic/Psr4Fixer.php) checkes if class names should match the file name and fixes the class names if its don't correspond to the file names. It doesn't check the namespaces.

In contrast, suin/phpcs-psr4-sniff checks not only class names but also namespaces.

### SlevomatCodingStandard.Files.TypeNameMatchesFileName

[](#slevomatcodingstandardfilestypenamematchesfilename)

[SlevomatCodingStandard.Files.TypeNameMatchesFileName](https://github.com/slevomat/coding-standard#slevomatcodingstandardfilestypenamematchesfilename) is a custom PHP Code Sniffer sniff to check whether namespaces and class names follow PSR-0/PSR-4 project structure.

This sniff is similar to suin/phpcs-psr4-sniff, but it needs explicit configuration about the PSR-0/PSR-4 project structure. suin/phpcs-psr4-sniff takes implicit way as it follows the autoloding configuration of Composer.

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

[](#installation)

```
composer require --dev suin/phpcs-psr4-sniff

```

Usage
-----

[](#usage)

At first, create a PHPCS ruleset XML (phpcs.xml.dist or phpcs.xml) file in the root of your project.

```

```

Then run it with the command:

```
vendor/bin/phpcs src

```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://github.com/suin/php/blob/master/CHANGELOG.md) for more details.

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

[](#contributing)

Send [issue](https://github.com/suin/php/issues) or [pull-request](https://github.com/suin/php/pulls) to main repository.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity53

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~82 days

Recently: every ~227 days

Total

13

Last Release

1812d ago

Major Versions

v1.2.1 → v2.1.22018-12-05

2.3.0 → v3.0.02021-06-02

PHP version history (2 changes)v1.0.0PHP &gt;=7.1 &lt;7.4.0

v2.2.1PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

[![suin](https://avatars.githubusercontent.com/u/855338?v=4)](https://github.com/suin "suin (9 commits)")[![sveneld](https://avatars.githubusercontent.com/u/4028769?v=4)](https://github.com/sveneld "sveneld (2 commits)")[![bc-luke](https://avatars.githubusercontent.com/u/2160087?v=4)](https://github.com/bc-luke "bc-luke (1 commits)")

---

Tags

coding-standardscoding-stylecustom-sniffnamespacephp-codesnifferphpcspsr-4static-analysisthird-party-sniffphpcsstatic analysisPHP\_CodeSniffernamespacePSR-4coding-standardscoding-style

### Embed Badge

![Health badge](/badges/suin-phpcs-psr4-sniff/health.svg)

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

###  Alternatives

[automattic/vipwpcs

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

25510.2M145](/packages/automattic-vipwpcs)[yoast/yoastcs

PHP\_CodeSniffer rules for Yoast projects

221.1M29](/packages/yoast-yoastcs)[joomla/coding-standards

Joomla Coding Standards

129231.7k16](/packages/joomla-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)[inpsyde/php-coding-standards

PHP 7.4+ coding standards for Syde WordPress projects.

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

Strict PHP coding standard

19193.5k62](/packages/orisai-coding-standard)

PHPackages © 2026

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