You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+69-1Lines changed: 69 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,72 @@ All notable changes to this project will be documented in this file.
4
4
5
5
This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
6
6
7
+
### [2.0.0] - 2019-12-17
8
+
9
+
#### Added
10
+
* PHPCS: New `Yoast.NamingConventions.ObjectNameDepth` sniff.
11
+
- For objects _declared within a namespace_, this sniff verifies that an object name consist of maximum three words separated by underscores.
12
+
- For objects which are part of a unit test suite, a `_Test`, `_Mock` or `_Double` suffix at the end of the object name will be disregarded for the purposes of the word count.
13
+
- The sniff has two configurable properties `max_words` (error) and `recommended_max_words` (warning). The default for both is `3`.
14
+
* PHPCS: New `Yoast.NamingConventions.NamespaceName` sniff.
15
+
This sniff verifies that:
16
+
- Namespace names consist of a maximum of three levels (excluding the plugin specific prefix) and recommends for the name to be maximum two levels deep.
17
+
For unit test files, `Tests\(Doubles\)` directly after the prefix will be ignored when determining the level depth.
18
+
- The levels in the namespace name directly translate to the directory path to the file.
19
+
- The sniff has four configurable properties:
20
+
-`max_levels` (error) and `recommended_max_levels` (warning) which are by default set to `3` and `2` respectively.
21
+
-`src_directory` to indicate the project root(s) for the _path-to-name_ translation when the project root is not the repo root directory.
22
+
-`prefixes` to set the plugin specific prefix(es) to take into account.
23
+
* PHPCS: New `Yoast.NamingConventions.ValidHookName` sniff.
24
+
This sniff extends and adds to the upstream `WordPress.NamingConventions.ValidHookName` sniff.
25
+
The sniff will ignore non-prefixed hooks and hooks with a prefix unrelated to the plugin being examined, to prevent errors being thrown about hook names which are outside of our control.
26
+
This sniff verifies that:
27
+
- Hook names are in lowercase with words separated by underscores (same as WordPressCS).
28
+
- Hook names are prefixed with the plugin specific prefix in namespace format, i.e. `Yoast\WP\PluginName`.
29
+
Note: The prefix is exempt from the _lowercase with words separated by underscores_ rule.
30
+
If the non-namespace type prefix for a plugin is used, the sniff will throw a `warning`.
31
+
- The actual hook name (after the prefix) consist of maximum four words separated by underscores.
32
+
- Note: _The hook_name part should be descriptive for the (dev-)user and does not need to follow the namespace or file path of the file they are in._
33
+
- Also note: for dynamic hook names where the hook name length can not reliably be determined, the sniff will throw a `warning` at severity `3` suggesting the hook name be inspected manually.
34
+
As the default `severity` for PHPCS is `5`, this `warning` at severity `3` will normally not be shown.
35
+
It is there to allow for intermittently checking of the dynamic hook names. To trigger it, `--severity=3` should be passed on the command line.
36
+
- The sniff has three configurable properties:
37
+
-`maximum_depth` (error) and `soft_maximum_depth` (warning). The default for both is `4`.
38
+
-`prefixes` to set the plugin specific prefix(es) to take into account.
39
+
* PHPCS: The `Generic.Arrays.DisallowLongArraySyntax` sniff.
40
+
WPCS 2.2.0 demands long array syntax. In contrast to that, YoastCS demands short array syntax.
41
+
* PHPCS: The `Generic.ControlStructures.DisallowYodaConditions` sniff.
42
+
In contrast to WPCS, YoastCS never demanded Yoda conditions. With the addition of this sniff, "normal" (non-Yoda) conditions will now be enforced.
43
+
* PHPCS: The `Generic.WhiteSpace.SpreadOperatorSpacingAfter` sniff.
44
+
Enforces no space between the `...` spread operator and the variable/function call it applies to.
45
+
* PHPCS: The `PEAR.WhiteSpace.ObjectOperatorIndent` sniff.
46
+
Enforce consistent indentation of chained method calls to one more or less than the previous call in the chain and always at least one in from the start of the chain.
47
+
* PHPCS: The `PSR12.Classes.ClosingBrace` sniff.
48
+
This sniff disallows the outdated practice of `// end ...` comments for OO stuctures.
49
+
* PHPCS: The `PSR12.Files.ImportStatement` sniff.
50
+
Import `use` statements must always be fully qualified, so a leading backslash is redundant (and discouraged by PHP itself).
51
+
This sniff enforces that no leading backslash is used for import `use` statements.
52
+
* PHPCS: The `PSR12.Files.OpenTag` sniff.
53
+
Enforces that a PHP open tag is on a line by itself in PHP-only files.
54
+
* PHPCS: A `CustomPrefixesTrait` to handle checking names against a list of custom prefixes.
55
+
* Composer: `lint` script which uses the [Parallel-Lint] package for faster and more readable linting results.
56
+
57
+
#### Changed
58
+
*:warning: PHPCS: `Yoast.Files.FileName` sniff: the public `$prefixes` property, which can be used to indicate which _prefixes_ should be stripped of a class name when translating it to a file name, has been renamed to `$oo_prefixes`.
59
+
Custom repo specific rulesets using the property should be updates to reflect this change.
60
+
*:warning: PHPCS: `Yoast.Files.FileName` sniff: the public `$exclude` property, which can be used to indicate which files to exclude from the file name versus object name check, has been renamed to `$excluded_files_strict_check`.
61
+
Custom repo specific rulesets using the property should be updates to reflect this change.
62
+
* PHPCS: The default setting for the minimum supported PHP version for repos using YoastCS is now PHP 5.6 (was 5.2).
63
+
* PHPCS: The default value for the `minimum_supported_wp_version` property which is used by various WPCS sniffs has been update to WP `5.2` (was `4.9`).
64
+
* Composer: Supported version of [PHP_CodeSniffer] has been changed from `^3.4.2` to `^3.5.0`.
65
+
Note: this makes the option `--filter=gitstaged` available which can be used in git `pre-commit` hooks to only check staged files.
66
+
* Composer: Supported version of [WordPressCS] has been changed from `^2.1.1` to `^2.2.0`.
67
+
* Composer: Supported version of [PHPCompatibilityWP] has been changed from `^2.0.0` to `^2.1.0`.
68
+
* Travis: the build check is now run in stages.
69
+
* Travis: Tests against PHP 7.4 are no longer allowed to fail.
70
+
* Various housekeeping & code compliance with YoastCS 2.0.0.
71
+
72
+
7
73
### [1.3.0] - 2019-07-31
8
74
9
75
#### Added
@@ -285,12 +351,14 @@ Initial public release as a stand-alone package.
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Severity levels:
36
36
### The YoastCS Standard
37
37
38
38
The `Yoast` standard for PHP_CodeSniffer is comprised of the following:
39
-
* The `WordPress` ruleset from the [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) implementing the official [WordPress PHP Coding Standards](https://make.wordpress.org/core/handbook/coding-standards/php/), with some [select exclusions](https://github.com/Yoast/yoastcs/blob/develop/Yoast/ruleset.xml#L29-L75).
39
+
* The `WordPress` ruleset from the [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards) implementing the official [WordPress PHP Coding Standards](https://make.wordpress.org/core/handbook/coding-standards/php/), with some [select exclusions](https://github.com/Yoast/yoastcs/blob/develop/Yoast/ruleset.xml#L29-L75).
40
40
* The [`PHPCompatibilityWP`](https://github.com/PHPCompatibility/PHPCompatibilityWP) ruleset which checks code for PHP cross-version compatibility while preventing false positives for functionality polyfilled within WordPress.
41
41
* Select additional sniffs taken from [`PHP_CodeSniffer`](https://github.com/squizlabs/PHP_CodeSniffer).
The name of objects - classes, interfaces, traits - declared within a namespace should consist of a maximum of three words.
6
+
7
+
A partial exception is made for test, mock and double classes. These can have a `_Test`, `_Mock` or `_Double` class name suffix, which won't be counted.
8
+
9
+
Note: the maximum (error) and the recommended (warning) maximum length are configurable.
10
+
]]>
11
+
</standard>
12
+
<code_comparison>
13
+
<codetitle="Valid: long class name in a file without a namespace.">
14
+
<![CDATA[
15
+
class <em>Non_Namespaced_Long_Class_Name</em> {}
16
+
]]>
17
+
</code>
18
+
<codetitle="Invalid: long class name in a namespaced file.">
19
+
<![CDATA[
20
+
namespace Yoast\WP\Plugin;
21
+
22
+
class <em>Namespaced_Long_Class_Name</em> {}
23
+
]]>
24
+
</code>
25
+
</code_comparison>
26
+
<code_comparison>
27
+
<codetitle="Valid: short class name in a namespaced file.">
28
+
<![CDATA[
29
+
namespace Yoast\WP\Plugin;
30
+
31
+
class <em>Short_Class_Name</em> {}
32
+
]]>
33
+
</code>
34
+
<codetitle="Invalid: long class name in a namespaced file.">
35
+
<![CDATA[
36
+
namespace Yoast\WP\Plugin;
37
+
38
+
class <em>Namespaced_Too_Long_Class_Name</em> {}
39
+
]]>
40
+
</code>
41
+
</code_comparison>
42
+
<code_comparison>
43
+
<codetitle="Valid: test class in a namespaced file.">
44
+
<![CDATA[
45
+
namespace Yoast\WP\Plugin\Tests;
46
+
47
+
use PHPUnit\Framework\TestCase;
48
+
49
+
class <em>Short_Class_Name_Test</em>
50
+
extends TestCase {}
51
+
]]>
52
+
</code>
53
+
<codetitle="Invalid: long test class name in a namespaced file.">
54
+
<![CDATA[
55
+
namespace Yoast\WP\Plugin\Tests;
56
+
57
+
use PHPUnit\Framework\TestCase;
58
+
59
+
class <em>Namespaced_Too_Long_Class_Name_Test</em>
0 commit comments