PHP 8.6 is out. DressCode rewrites your code for it. Upgrading to a newer PHP →

From PHP_CodeSniffer and Slevomat to DressCode

Instead of phpcs and phpcbf, you run dresscode check and fix, your phpcs:ignore comments keep working, and dresscode migrate config converts phpcs.xml, Slevomat sniffs included. The configuration then says how the code should look, not which sniff checks what: the blank lines of PSR-12, which take nine sniffs in PHP_CodeSniffer, are six values of one section here.

DressCode as an Alternative to PHP_CodeSniffer

In DressCode, the PSR12 standard is called psr12, and one tool does both checking and fixing: fix does what check does and also writes the changes. And the same run can upgrade the code to a newer PHP and to new versions of Nette, Symfony or Laravel.

On Laravel, the two tools checked each other's work. After phpcbf fixed Laravel under PSR12, DressCode still found 772 places, among them constants without visibility, which PSR-12 requires and phpcbf reports but cannot add. In the other direction, after dresscode fix --use psr12, PHP_CodeSniffer reported 83 findings across all of Laravel. The comparison has the details, measured in October 2026 with PHP_CodeSniffer 4.0.

PHP_CodeSniffer, on the other hand, runs on PHP 7.2, so for a project that has to stay on PHP 7 it remains the right tool. DressCode needs PHP 8.4 to run and checks code written for PHP 8.0 or newer.

Before You Start

Start with the common steps; this page adds only what is different with PHP_CodeSniffer. And one piece of good news right away: phpcs.xml is XML, so migrate config reads it even after PHP_CodeSniffer and Slevomat have been uninstalled.

Converting the Configuration

dresscode migrate config

The PSR1, PSR2 and PSR12 sets are translated to the psr12 standard. Individual sniffs (rules of PHP_CodeSniffer) are translated to decisions, together with their property from <properties> where it has a counterpart: Generic.Files.LineLength is file.longLines and its absoluteLineLimit becomes the value of file.lineLength; SlevomatCodingStandard.Namespaces.UnusedUses is imports.unused, which always counts a name in a doc comment as used, as with the searchAnnotations property; Squiz.WhiteSpace.OperatorSpacing is spacing.binaryOperator. In DressCode there is one line length for everything, so migrate config also takes it from other sniffs that carry a length, and when the values differ, it keeps the smallest one and tells you so. Which decision matches which sniff is listed in the tables of PHP_CodeSniffer sniffs and Slevomat sniffs.

migrate config carries over both excluding a sniff inside a set (<exclude name="…"/>) and silencing it with <severity>0</severity> as the value keep for the decision that matches the sniff. But when the same decision is also covered by another sniff, migrate config leaves the decision alone and adds a note; the same happens when you exclude one message of a sniff (Generic.PHP.ForbiddenFunctions.Found), because a decision cannot be narrowed to one message. A sniff with no counterpart is listed in the block at the end of the generated file; typically these are sniffs about doc comments from the Squiz.Commenting group, and sniffs that check the same thing as another sniff, only in different words.

migrate config carries the paths over by itself: <file> goes to paths, <exclude-pattern> to excludePaths, and an <exclude-pattern> inside a <rule> to an override that gives the decisions of the sniff the value keep for those paths; the patterns are described in Configuration. You rewrite by hand whatever in phpcs.xml is neither a rule nor a path:

  • <arg name="extensions"> goes to the fileExtensions key.
  • <config name="php_version"> is not needed; DressCode reads the target version from composer.json.
  • <arg name="tab-width"> goes to the decision indentation.tabWidth; the indentation is set by the standard, or by the decision indentation.unit.

Slevomat sniffs that DressCode covers are translated by name, like any others. Slevomat's helper classes and the installed_paths setting are not needed here.

Sections Instead of Sniffs

PHP_CodeSniffer builds one area of style from sniffs by different authors, and each one has its own vocabulary. Blank lines in PSR-12, with one line between methods, none after the opening brace of a class and of a block, and one before return, take nine sniffs:

<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="PSR2.Namespaces.UseDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
	<properties>
		<property name="linesCountAfterOpeningBrace" value="0"/>
		<property name="linesCountBeforeClosingBrace" value="0"/>
	</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing">
	<properties>
		<property name="linesCountBetweenMembers" value="1"/>
	</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing">
	<properties>
		<property name="minLinesCount" value="1"/>
		<property name="maxLinesCount" value="1"/>
	</properties>
</rule>
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<rule ref="PSR2.Methods.FunctionClosingBrace"/>
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
	<properties>
		<property name="jumpStatements" type="array">
			<element value="return"/>
		</property>
		<property name="linesCountBefore" value="1"/>
		<property name="linesCountBeforeFirst" value="0"/>
		<property name="linesCountAfter" value="0"/>
		<property name="linesCountAfterLast" value="0"/>
	</properties>
</rule>

In DressCode it is one section, blankLines, with six values whose keys say where the blank lines go:

blankLines:
	afterNamespace: 1
	afterImports: 1
	aroundMethods: 1
	bodyStart: 0
	bodyEnd: 0
	beforeStatement:
		return: 1

Both configurations do the same thing with the same file. The difference is in what you need to know to write and read them: with sniffs, which sniff checks which place and what its property is called; here, only how many blank lines you want where. The whole section, including ranges like 1-2 for “one or two”, is described on its page.

Commands

PHP_CodeSniffer DressCode
phpcs src dresscode check src
phpcbf src dresscode fix src
phpcs --standard=PSR12 src dresscode check --use psr12 src
phpcs --sniffs=SlevomatCodingStandard.Namespaces.UnusedUses src dresscode check --only imports.unused src
phpcs --exclude=SlevomatCodingStandard.Namespaces.UnusedUses src dresscode check --set imports.unused=keep src
phpcs -e dresscode catalogue or dresscode config
phpcs --report=checkstyle dresscode check -f checkstyle
phpcs --report=json dresscode check -f json
phpcs --parallel=8 dresscode check --jobs 8
phpcs --cache the cache is on by itself; --no-cache bypasses it
phpcs -p progress is shown in the terminal by itself

PHP_CodeSniffer uses its exit code to tell whether the violations found can be fixed, and phpcbf has its own scale. DressCode has one scale for every command, see Exit Codes; the summary of check and the json format tell you how many violations remain after a fix. A script that evaluates the exit code needs one change.

What Is Different

  • One tool for checking and fixing. phpcs and phpcbf were two commands that sometimes disagreed, because a fix could reveal more violations. Here fix is the same as check plus writing the files, and what fix does not fix, it reports just like check.
  • The message tells you what the fix can change. The messages of both tools give the expected and the found value; the difference is elsewhere. Slevomat has the StrictCall sniff, and for two in_array() calls without $strict it writes the same thing twice: Strict parameter missing in in_array() call. DressCode with types from PHPStan can tell that the first call searches for an int in a list<int>, and adds true there by itself; in the second call the value searched for is mixed, so it only reports the fix with the sentence Risky because a strict search no longer finds a value of another type. The same output also shows things that no standard shipped with PHP_CodeSniffer has a sniff for: an overriding method whose parameter is named differently than in the parent, so a call with a named argument fails with an error, and a call to a method the library marked as deprecated, together with the library's advice on what to write instead. The full output is shown on the home page.
  • You can also try a decision that the standard does not have. In PHP_CodeSniffer, --sniffs can only choose from the sniffs the selected standard contains. dresscode check --set path=value --only path --diff gives a decision a value for one run and shows only its changes, see Configuration.
  • The comments phpcs:ignore, phpcs:disable, phpcs:enable, phpcs:ignoreFile and @phpcsSuppress keep working, even with the sniff names, which DressCode translates to decisions. The only difference is that phpcs:ignore on a line of its own covers the whole next statement, not just one line, see the common steps. Rewriting them to dresscode:* is one command, and it is optional.
  • The baseline is built in. In PHP_CodeSniffer it has been discussed for years and is solved by third-party add-ons. Here the dresscode baseline command records it, and it contains only what fix cannot fix, so it does not get in the way of fixes; see Baseline.
  • A custom sniff is not carried over but rewritten; written against the tree, it usually shrinks to a fraction of its length. The guide is on a separate page.

What is different for every tool, such as rules having no priorities, is summed up in the common steps.

Show on GitHub · Report a problem with this page on GitHub · Nov 9, 2026