-
Notifications
You must be signed in to change notification settings - Fork 2
Upgrading to 2.0
Here are some "gotchas"/changes that are worth mentioning when upgrading to Alley Coding Standards 2.0 (which subsequently upgrades projects to WPCS/VIPCS 3.0).
To start, upgrade the dependency:
"require-dev": {
"alleyinteractive/alley-coding-standards": "^2.0"
}
Run composer update
and then PHP Code Beautifier (phpcbf
/vendor/bin/phpcbf
) to fix a good chunk of the issues on your project.
Various sniffs were renamed and/or moved. Please review the following guide and CHANGELOG for more information (some sniffs are outlined below):
Functions with unused method parameters will now throw errors in PHPCS. These issues cannot be fixed by phpcbf
and will requiring a code change. To ignore these errors, you can exclude the rule in your PHPCS Configuration:
<?xml version="1.0"?>
<ruleset name="National Review">
<description>PHP_CodeSniffer standard for National Review.</description>
<!-- Include Alley Rules -->
<rule ref="Alley-Interactive">
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed" />
</rule>
</ruleset>
Introduced with the new version, the order of your use
statements must match PSR 12 order:
<?php
namespace Vendor\Package;
use Vendor\Package\{ClassA as A, ClassB, ClassC as C};
use Vendor\Package\SomeNamespace\ClassD as D;
use function Vendor\Package\{functionA, functionB, functionC};
use const Vendor\Package\{ConstantA, ConstantB, ConstantC};
class Foo extends Bar implements FooInterface {}
The important thing to note here the order being:
- Classes
- Functions
- Constants