Custom PHPCS sniffs to find Code Smells
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Code Odor Sniffer

Custom PHP Code Sniffer sniffs to help find Code Smells (Odor).

Build Status codecov Scrutinizer Code Quality Code Climate Packagist Packagist

Inspired by:

What is it?

This package is a set of custom Sniffs for the PHP Code Sniffer that you can use in your CI build to ensure the ingegrity of your code base.

How to Install?

Install via Composer:

composer require bmitch/codor --dev

How to Use?

Create a PHPCS ruleset XML (codor.xml or whatever filename you want) file in the root of your project.

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Project">
    <description>Project Coding Standard</description>

    <rule ref="vendor/bmitch/codor/src/Codor/ruleset.xml"/>

Then run it with the command:

vendor/bin/phpcs --standard=codor.xml src 

Where src is the location of the source code you want to check.

Omitting Sniffs

You may not want to run all the sniffs provided so you can specify which sniffs you want to exclude with the --exclude flag like:

vendor/bin/phpcs --standard=codor.xml --exclude=Codor.ControlStructures.NoElse src

(if you want to exclude multiple just separate them with a comma)

Running Specific Sniffs

Or you can also specify which sniffs to specifically run:

vendor/bin/phpcs --standard=codor.xml --sniffs=Codor.ControlStructures.NoElse src

Sniffs Included


Does not allow for any else or elseif statements.


Functions/methods must be no more than 20 lines.


Functions/methods must have no more than 3 parameters.


Functions/methods must not return null.


Classes must be no more than 200 lines.


Functions/methods cannot contain "And" or "Or". This could be a sign of a function that does more than one thing.


Functions/methods cannot have more than 1 level of indentation.


Nested if statements are not allowed.

Customizing Sniffs

Some of the sniff rules can be customized to your liking. For example, if you'd want the Codor.Files.FunctionLength to make sure your functions are no more than 30 lines instead of 20, you can do that. Here's an example of a codor.xml file with that customization:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Project">
    <description>Project Coding Standard</description>

    <rule ref="vendor/bmitch/codor/src/Codor/ruleset.xml"/>
    <rule ref="Codor.Files.FunctionLength">
            <property name="maxLength" value="30"/>

Customizations Available

  • Codor.Files.FunctionLength
    • maxLength: The maximum number of lines a function/method can be (default = 200).
  • Codor.Files.FunctionParameter
    • maxParameters: The maximum number of parameters a function/method can have (default = 3).
  • Codor.Classes.ClassLength
    • maxLength: The maximum number of lines a Class can be (default = 20).
  • Codor.Files.IndentationLevel
    • indentationLimit: Cannot have more than or equal to this number of indentations (default = 2).


Please see


The MIT License (MIT). Please see License File for more information.