All Projects → suin → phpcs-psr4-sniff

suin / phpcs-psr4-sniff

Licence: other
[READ-ONLY] PHP_CodeSniffer sniff that checks class name matches PSR-4 project structure.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to phpcs-psr4-sniff

wptide
🌊 Tide is a series of automated tests run against every WordPress.org theme and plugin
Stars: ✭ 77 (+234.78%)
Mutual labels:  coding-standards, php-codesniffer, phpcs
php-codesniffer-sniffs
Custom sniffs for PHP_CodeSniffer
Stars: ✭ 16 (-30.43%)
Mutual labels:  static-analysis, coding-standards, php-codesniffer
Codor
Custom PHPCS sniffs to find Code Smells
Stars: ✭ 40 (+73.91%)
Mutual labels:  coding-standards, coding-style, php-codesniffer
OpenStaticAnalyzer
OpenStaticAnalyzer is a source code analyzer tool, which can perform deep static analysis of the source code of complex systems.
Stars: ✭ 19 (-17.39%)
Mutual labels:  static-analysis, coding-standards, coding-style
coding-standard
Consistence - Coding Standard - PHP Code Sniffer rules
Stars: ✭ 73 (+217.39%)
Mutual labels:  coding-standards, php-codesniffer
eslint-config
MOXY eslint configuration to be used across several JavaScript projects
Stars: ✭ 14 (-39.13%)
Mutual labels:  coding-standards, coding-style
verilog-coding-style
Verilog (SystemVerilog) coding style
Stars: ✭ 36 (+56.52%)
Mutual labels:  coding-standards, coding-style
XS-Labs-Style-Guide
XS-Labs Coding Style Guide for C, C++, Objective-C and x86 Assembly
Stars: ✭ 20 (-13.04%)
Mutual labels:  coding-standards, coding-style
codingstyle
Java coding style and template project used at Munich university of applied sciences
Stars: ✭ 19 (-17.39%)
Mutual labels:  coding-standards, coding-style
Coding-Standards
Coding Guidelines for C#
Stars: ✭ 125 (+443.48%)
Mutual labels:  coding-standards, coding-style
Phpcs Calisthenics Rules
Object Calisthenics rules for PHP_CodeSniffer
Stars: ✭ 605 (+2530.43%)
Mutual labels:  static-analysis, php-codesniffer
codeclimate-phpcodesniffer
Code Climate Engine for PHP Code Sniffer
Stars: ✭ 27 (+17.39%)
Mutual labels:  static-analysis, php-codesniffer
Phpqa
Docker image that provides static analysis tools for PHP
Stars: ✭ 853 (+3608.7%)
Mutual labels:  static-analysis, php-codesniffer
sniff
Simpler PHP code sniffer built on top of PHP-CS-Fixer.
Stars: ✭ 14 (-39.13%)
Mutual labels:  coding-standards, php-codesniffer
cscs
A curated list of Coding Style Conventions and Standards.
Stars: ✭ 1,486 (+6360.87%)
Mutual labels:  coding-standards, coding-style
Wordpress Coding Standards
PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
Stars: ✭ 2,070 (+8900%)
Mutual labels:  php-codesniffer, phpcs
phpcs-gitlab
Gitlab Report for PHP_CodeSniffer (display the violations in the Gitlab CI/CD Code Quality Report)
Stars: ✭ 29 (+26.09%)
Mutual labels:  php-codesniffer, phpcs
Phpcompatibility
PHP Compatibility check for PHP_CodeSniffer
Stars: ✭ 1,705 (+7313.04%)
Mutual labels:  php-codesniffer, phpcs
wpcs-docs
WordPress Coding Standards Docs
Stars: ✭ 59 (+156.52%)
Mutual labels:  coding-standards, phpcs
Php codesniffer
PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.
Stars: ✭ 9,004 (+39047.83%)
Mutual labels:  static-analysis, coding-standards

suin/phpcs-psr4-sniff

A custom PHP Code Sniffer sniff to help to find classes that is not compliant with PSR-4 Autoloader.

Demo

Please visit ./tests/demo, if you would like to try this sniff.

Features

Classes, interfaces and traits

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

Namespaces and class names

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

Configuration free

As this sniff respects composer.json autoloading configuration, you don't have to declare mapping between namespace prefixes and base directories.

Similar packages

Psr4Fixer of PHP-CS-Fixer

Psr4Fixer 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

SlevomatCodingStandard.Files.TypeNameMatchesFileName 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

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

Usage

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

<?xml version="1.0"?>
<ruleset name="My Project">
    <!-- Specify directory that composer.json is placed. Usually it would be
    project root directory. -->
    <arg name="basepath" value="."/>

    <!-- Relative path to your ruleset.xml -->
    <rule ref="vendor/suin/phpcs-psr4-sniff/src/Suin"/>

    <!-- Optional: If you have to specify composer.json path, please add
    following section. -->
    <rule ref="Suin.Classes.PSR4">
        <properties>
            <!-- composerJsonPath must be relative path to "basepath" -->
            <property name="composerJsonPath" value="sub-dir/composer.json"/>
        </properties>
    </rule>
</ruleset>

Then run it with the command:

vendor/bin/phpcs src

Changelog

Please see CHANGELOG for more details.

Contributing

Send issue or pull-request to main repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].