All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning and Keep a CHANGELOG.
3.4.1 - 2026-03-03
- PHPCS: a PHPCS run with the SlevomatCodingStandard locked at a version below 8.17.0 would error out on a "ERROR: Property "checkIfConditions" does not exist" error.
3.4.0 - 2026-02-20
- Composer: Supported version of PHPCompatibilityWP has been changed from
^2.1.6to^3.0.0@alpha. This allows for installing the much, much improved PHPCompatibility 10.0.0 (prerelease). To do so, thecomposer.jsonfile of packages requiring this package must have"minimum-stability": "dev"or"alpha"(or other tweaks which net the same effect).
3.3.0 - 2026-02-04
- PHPCS: The
SlevomatCodingStandard.Arrays.ArrayAccesssniff. - PHPCS: The
SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperatorsniff. - PHPCS: The
SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperatorsniff. - PHPCS: The
SlevomatCodingStandard.Functions.RequireTrailingCommaInCallsniff. - PHPCS: The
SlevomatCodingStandard.Functions.DisallowTrailingCommaInCallsniff (for single-line function calls). - PHPCS: The
SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparatorsniff. - PHPCS: The
Universal.Attributes.TrailingCommasniff. - PHPCS: The
Universal.Attributes.BracketSpacingsniff (via WordPressCS). - PHPCS: The
Universal.Attributes.DisallowAttributeParenthesessniff (via WordPressCS). - PHPCS: The
Universal.PHP.NoFQNTrueFalseNullsniff. - PHPCS: The
Universal.PHP.RequireExitDieParenthesessniff. - PHPCS: The
WordPress.WP.GetMetaSinglesniff (via WordPressCS).
- Composer: Supported version of PHPCSExtra has been changed from
^1.2.1to^1.5.0. - Composer: Supported version of VariableAnalysis has been changed from
^2.12.0to^2.13.0. - Composer: Supported version of WordPressCS has been changed from
^3.1.0to^3.3.0. - PHPCS: The default value for the
minimum_wp_versionproperty which is used by various WPCS sniffs has been updated to WP6.8(was6.6). - Various housekeeping.
3.2.0 - 2025-03-19
- PHPCS: The
Generic.Strings.UnnecessaryHeredocsniff. - PHPCS: The
Generic.WhiteSpace.HereNowdocIdentifierSpacingsniff.
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.9.1to^3.12.0. - Composer: Supported version of PHPCSUtils has been changed from
^1.0.10to^1.0.12. - Composer: Supported version of PHPCompatibilityWP has been changed from
^2.1.4to^2.1.6. - Composer: Supported version of VariableAnalysis has been changed from
^2.11.17to^2.12.0. - Composer: Supported version of WordPressVIP Coding Standards has been changed from
^3.0.0to^3.0.1. - Composer: Updated the supported versions of dev dependencies.
- PHPCS: The default setting for the minimum supported PHP version for repos using YoastCS is now PHP
7.4(was7.2). - PHPCS: The default value for the
minimum_wp_versionproperty which is used by various WPCS sniffs has been updated to WP6.6(was6.3). - PHPCS: verified runtime compatibility with PHP 8.4.
- PHPCS: compatibility with SlevomatCodingStandard 8.16.0.
- Various housekeeping.
- PHPCS: The spacing around comma's in short arrays nested in function calls will now be flagged correctly again.
3.1.0 - 2024-04-05
- Threshold report: aside from the pre-existing
YOASTCS_ABOVE_THRESHOLDconstant, a newYOASTCS_THRESHOLD_EXACT_MATCHconstant will now be available to determine (from a calling script) whether the error/warning thresholds were matched exactly or need to be updated.
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.8.0to^3.9.1. - Composer: Supported version of PHPCSUtils has been changed from
^1.0.9to^1.0.10. - Composer: Supported version of WordPressCS has been changed from
^3.0.1to^3.1.0. This introduces one new sniff -Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence- to the YoastCS ruleset. - Composer: Supported version of SlevomatCodingStandard has been changed from
^8.14.0to^8.15.0. - Composer: Supported version of PHP Parallel Lint has been changed from
^1.3.2to^1.4.0. - PHPCS: The default value for the
minimum_wp_version(previouslyminimum_supported_wp_version) property which is used by various WPCS sniffs has been updated to WP6.3(was6.2). - Various housekeeping.
3.0.0 - 2023-12-14
- Composer/PHPCS: Dependencies on the following external PHPCS standards packages: PHPCSUtils, PHPCSExtra, SlevomatCodingStandard, VariableAnalysis and WordPressVIP Coding Standards.
- PHPCS: A best effort has been made to add support for new PHP syntaxes/features to all YoastCS native sniffs and utility functions (or to verify/improve existing support).
YoastCS native sniffs and utilities have received fixes for the following syntaxes:
- PHP 5.6
- Parameter unpacking in function calls.
- PHP 8.0
- Named arguments in function calls.
- PHP 8.1
- Enumerations.
- First class callables.
- PHP 8.2
- Readonly classes.
- PHP 5.6
- PHPCS: The
Yoast.Commenting.CoversTagsniff includes a new warning for the use ofClassName<*>type@coversannotations, as these have been deprecated as of PHPUnit 9.0. - PHPCS: The
Yoast.Files.FileNamesniff now has the (optional) ability to check whether file names comply with PSR-4. To enable this ability, add the custompsr4_pathsproperty to your ruleset. Thepsr4_pathsproperty is an array property and mirrors thepsr4setting in the Composerautoloaddirective. It expects a namespace prefix as the array key and a comma separated list of relative paths as the array value. Multiple PSR-4 paths can be passed (array elements). For files containing OO structures in a "PSR4 path", theoo_prefixesand theexcluded_files_strict_checkproperties will be ignored. - PHPCS: The
Yoast.NamingConventions.NamespaceNamesniff will now throw aMissingPrefixerror if a prefix is expected, but the namespace name does not include a prefix. - PHPCS: The
Yoast.NamingConventions.NamespaceNamesniff will now throw aDirectoryInvaliderror if a file is in a directory which would not result in a valid namespace name. - PHPCS: The
Yoast.NamingConventions.NamespaceNamesniff now has the (optional) ability to check whether namespace names comply with PSR-4. To enable this ability, add the custompsr4_pathsproperty to your ruleset. Thepsr4_pathsproperty is an array property and mirrors thepsr4setting in the Composerautoloaddirective. It expects a namespace prefix as the array key and a comma separated list of relative paths as the array value. Multiple PSR-4 paths can be passed (array elements). Apsr4_pathsproperty will take precedence over the, potentially set,src_directoryandprefixesproperties. - PHPCS: The following sniffs/error codes have been added to/enabled in the YoastCS ruleset (with appropriate configuration):
- All new sniffs which were added/included in WordPressCS 3.0.0.
PSR1.Classes.ClassDeclaration(for tests only)PSR12.Properties.ConstantVisibilitySlevomatCodingStandard.Arrays.DisallowImplicitArrayCreationSlevomatCodingStandard.Classes.ClassStructureSlevomatCodingStandard.Classes.ModernClassNameReferenceSlevomatCodingStandard.Functions.StaticClosureSlevomatCodingStandard.Namespaces.AlphabeticallySortedUsesSlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstantsSlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctionsSlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnlySlevomatCodingStandard.Namespaces.UnusedUsesSlevomatCodingStandard.Namespaces.UseFromSameNamespaceSlevomatCodingStandard.TypeHints.DisallowMixedTypeHint(tests excluded)SlevomatCodingStandard.TypeHints.LongTypeHintsSlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValueSlevomatCodingStandard.TypeHints.NullTypeHintOnLastPositionSlevomatCodingStandard.TypeHints.ParameterTypeHintSlevomatCodingStandard.TypeHints.PropertyTypeHintSlevomatCodingStandard.TypeHints.ReturnTypeHintSquiz.Commenting.FunctionComment.InvalidReturnNotVoidSquiz.Commenting.FunctionComment.MissingReturnSquiz.Commenting.FunctionComment.ParamCommentNotCapitalSquiz.Commenting.FunctionComment.SpacingAfterParamNameSquiz.WhiteSpace.SuperfluousWhitespace.EmptyLinesUniversal.Classes.RequireFinalClass(for tests only, doubles/mocks excluded)Universal.CodeAnalysis.NoDoubleNegativeUniversal.ControlStructures.DisallowAlternativeSyntaxUniversal.ControlStructures.IfElseDeclarationUniversal.FunctionDeclarations.NoLongClosuresUniversal.Operators.ConcatPositionUniversal.Operators.DisallowLogicalAndOrUniversal.PHP.LowercasePHPTagUniversal.UseStatements.DisallowUseConstUniversal.UseStatements.DisallowUseFunctionVariableAnalysis.CodeAnalysis.VariableAnalysisWordPressVIPMinimum.Classes.DeclarationCompatibilityWordPressVIPMinimum.Hooks.AlwaysReturnInFilterWordPressVIPMinimum.Security.EscapingVoidReturnFunctionsWordPressVIPMinimum.Security.ProperEscapingFunction
- PHPCS: New
PathHelper,PathValidationHelperandPSR4PathsTraitsclasses/traits for use by the sniffs. - Readme: section on the YoastCS
Thresholdreport.
⚠️ The minimum supported PHP version for this package is now PHP 7.2 (was 5.4).- PHPCS: all sniffs are now runtime compatible with PHP 7.2 - 8.3.
⚠️ PHPCS: All non-abstract classes in YoastCS are nowfinaland all non-publicmethods and properties are nowprivate. Additionally, all non-private methods in traits have also been madefinal.- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.7.1to^3.8.0. ⚠️ Composer: Supported version of WordPressCS has been changed from^2.3.0to^3.0.1. YoastCS is now fully compatible with WordPressCS 3.0. Note: WordPressCS 3.0.0 contains breaking changes. Please read the WordPressCS release announcement and follow the WordPressCS upgrade guides.- PHPCS: The default value for the
minimum_wp_version(previouslyminimum_supported_wp_version) property which is used by various WPCS sniffs has been updated to WP6.2(was6.0). - PHPCS: Files in a
wp-content/plugins/subdirectory will now always be ignored for PHPCS scans. - PHPCS: The ruleset included value for the
doubles_pathproperty in theYoast.Files.TestDoublessniff has been updated to include the typical Yoasttest/Unit/Doublesandtest/WP/Doublesdirectories as per the restructured tests. - PHPCS: The
Yoast.Commenting.CodeCoverageIgnoreDeprecatedsniff will now also examine class docblocks. - PHPCS: The
Yoast.Commenting.FileCommentsniff will no longer flag a file docblock in a namespaced file which doesn't contain an OO structure as redundant. - PHPCS: The
Yoast.Files.FileNamesniff will now also examine the file name of PHP files using only the PHP short open tag (<?=). - PHPCS: The
Yoast.Files.FileNamesniff will now respect inline PHPCS native ignore/disable annotations for the sniff. Note: the annotations are respected for the sniff itself, but not for individual error codes from the sniff! - PHPCS: The
Yoast.Files.FileNamesniff now recognizes more word separators, meaning that files using other word separators than underscores will now be flagged for not using hyphenation. - PHPCS: The
Yoast.Files.FileNamesniff will now throw a potential "missing basepath" warning only once per run, not for each file triggering the sniff. - PHPCS: The default value for the
doubles_pathproperty in theYoast.Files.TestDoublessniff is now an empty array. This property should now always be set in a custom ruleset. Note: the YoastCS ruleset sets this property, so if the ruleset is used instead of explicitly including the individual sniff, this change has no impact. - PHPCS: The "namespace level depth" check in the
Yoast.NamingConventions.NamespaceNamesniff now allows for test fixtures directories being at a deeper level than directly under atestsdirectory. - PHPCS: The
Yoast.NamingConventions.ObjectNameDepthsniff now allows for test classes using a_TestCasesuffix and will allow for extra object name depth for those, same as for test classes with a_Testsuffix. ⚠️ PHPCS: TheYoast.Yoast.AlternativeFunctionssniff has been renamed toYoast.Yoast.JsonEncodeAlternative.- The
Yoast.Yoast.JsonEncodeAlternativesniff (previouslyYoast.Yoast.AlternativeFunctions) is now disabled by default for files in a/tests/directory. - The
Generic.CodeAnalysis.UselessOverridingMethodsniff is now disabled by default for files in a/tests/*/Doubles/directory. - The
WordPress.WP.GlobalVariablesOverridesniff is now disabled by default for files in a/tests/directory. - PHPCS: The eror messages for the
Yoast.Files.TestDoublessniff have been improved for accuracy. - PHPCS: The error message for the
Yoast.NamingConventions.NamespaceName.Invaliderror has been made more informative/actionable. - PHPCS: The error message for the
Yoast.NamingConventions.ValidHookName.NonStringwarning has been made more actionable. - PHPCS: Various sniffs have received efficiency fixes for improved performance.
- PHPCS: the XML documentation for various sniffs has been updated and improved.
- Various housekeeping.
- PHPCS: The
Yoast.ControlStructures.IfElseDeclarationsniff (replaced by theUniversal.ControlStructures.IfElseDeclarationsniff from PHPCSExtra). - PHPCS: The
Yoast.Namespaces.NamespaceDeclarationsniff (replaced by a variety of sniffs from PHPCSExtra). - PHPCS: Various explicit rule inclusions for sniffs which are now inherited from WordPressCS 3.0.
- PHPCS: Support for the
Yoast.Files.TestDoublesdoubles_pathproperty being passed as a string instead of an array. Passing the property as a string was previously deprecated in YoastCS 1.1.0. - PHPCS: The
Yoast.Files.TestDoubles.OneObjectPerFileerror code. This is already checked via theGeneric.Files.OneObjectStructurePerFilesniff, which is included in WordPressCS, anyway.
- PHPCS: Various sniffs now include more defensive coding to prevent potential PHP notices/errors, particularly when running the sniffs during live coding in an IDE.
- PHPCS: Various sniffs have received fixes for improved handling of directory path and file names passed through custom properties.
- PHPCS: The
Yoast.Commenting.CoversTagsniff will no longer flag::<[!]visibility>annotations as an invalid format when combined with a@coversDefaultClasstag. - PHPCS: The
Yoast.Commenting.TestHaveCoversTagsniff will no longer examine global functions. - PHPCS: The
Yoast.Files.FileNamesniff will now handle the values for theexcluded_files_strict_checkproperty in a case-sensitive manner (as file names are case-sensitive on most operating systems). - PHPCS: The
Yoast.Files.TestDoublessniff will now handle the values for thedoubles_pathproperty in a case-sensitive manner (as directory names are case-sensitive on most operating systems). - PHPCS: The
Yoast.NamingConventions.NamespaceNamesniff will now bow out earlier if the namespace name is invalid (parse error). - PHPCS: The
Yoast.NamingConventions.NamespaceNamesniff will now handle "directory to namespace name" translations more accurately and will no longer throw an error if the directory name contains an underscore. - PHPCS: The
Yoast.NamingConventions.ObjectNameDepthsniff now has a more accurate object name depth calculation for OO structures with a name inCamelCaps. This should prevent various false positives for test classes/test doubles. - PHPCS: The
Yoast.NamingConventions.ObjectNameDepthsniff will no longer check if a class extends a known "TestCase" to determine whether to allow for extra object name depth, it will just base itself on the name of the object under examination, which should prevent some false positives. - PHPCS: The fixer in the
Yoast.Yoast.JsonEncodeAlternativesniff (previouslyYoast.Yoast.AlternativeFunctions) will no longer inadvertently create a parse error when fixing fully qualified function calls. - PHPCS: The
Yoast.Yoast.JsonEncodeAlternativesniff (previouslyYoast.Yoast.AlternativeFunctions) will now no longer try to auto-fix when it encounters PHP 5.6+ parameter unpacking. - PHPCS: The
Yoast.Yoast.JsonEncodeAlternativesniff (previouslyYoast.Yoast.AlternativeFunctions) will now no longer try to auto-fix when it encounters a PHP 8.1+ first class callable.
2.3.1 - 2023-03-09
- PHPCS: The default setting for the minimum supported PHP version for repos using YoastCS is now PHP 7.2 (was 5.6).
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.7.1to^3.7.2.
2.3.0 - 2023-01-09
- PHPCS: New
Yoast.Tools.BrainMonkeyRaceConditionsniff. This sniff will flag test code which is likely to run into a particular race condition when using BrainMonkey to set expectations for WP hook functions.
- PHPCS: The default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs has been updated to WP6.0(was5.7). - Composer: The package will now identify itself as a static analysis tool. Thanks @GaryJones!
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.6.2to^3.7.1. - Composer: Supported version of PHPCompatibilityWP has been changed from
^2.1.3to^2.1.4. - Composer: Supported version of the Composer PHPCS plugin has been changed from
^0.5 || ^0.6.2 || ^0.7to^0.6.2 || ^0.7 || ^1.0. - Various housekeeping.
- PHPCS:
Yoast.Files.FileComment: the sniff will now allow for and respectphpcs:disablecomments for this sniff when found in a file docblock.
2.2.1 - 2022-02-22
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.6.0to^3.6.2. - Composer: Supported version of PHPCompatibilityWP has been changed from
^2.1.0to^2.1.3. - Composer: Supported version of PHP Parallel Lint has been changed from
^1.3.1to^1.3.2. - Composer: Supported version of PHP Console Highlighter has been changed from
^0.5.0to^1.0.0. - Readme: Updated installation instructions for compatibility with Composer 2.2+ and other minor improvements.
- Various housekeeping.
2.2.0 - 2021-09-22
- PHP Parallel Lint will now be provided via YoastCS.
If
php-parallel-lint/php-parallel-lintandphp-parallel-lint/php-console-highlighterare included in therequire-devof yourcomposer.jsonfile, you can remove these after updating the version constraint for YoastCS to"yoast/yoastcs": "^2.2.0". - PHPCS: A custom
YoastCS\Yoast\Reports\Thresholdreport. This commit adds a custom report for use with PHPCS to compare the run results with "threshold" settings.- The report will look in the runtime environment for the following two environment variables and will take the values of those as the thresholds to compare the PHPCS run results against:
YOASTCS_THRESHOLD_ERRORSYOASTCS_THRESHOLD_WARNINGS
- If the environment variables are not set, they will default to 0 for both, i.e. no errors or warnings allowed.
- After the report has run, a global
YOASTCS_ABOVE_THRESHOLDconstant (boolean) will be available which can be used in calling scripts. - To use this report, run PHPCS with the following command-line argument:
--report=YoastCS\Yoast\Reports\Threshold. Note: depending on the OS the command is run on, the backslashes in the report name may need to be escaped (doubled).
- The report will look in the runtime environment for the following two environment variables and will take the values of those as the thresholds to compare the PHPCS run results against:
- PHPCS: The
PSR12.ControlStructures.BooleanOperatorPlacementsniff. Enforces that boolean operators in multi-line control structures are always placed at the start of a line. - PHPCS:
Yoast.Commenting.CodeCoverageIgnoreDeprecated: Support for attributes (PHP 8.0+) placed between a function or class declaration and the associated docblock. - PHPCS:
Yoast.Commenting.TestHaveCoversTag: Support for attributes (PHP 8.0+) placed between a function or class declaration and the associated docblock. - PHPCS:
Yoast.NamingConventions.ObjectNameDepth: Support for attributes (PHP 8.0+) placed between a function or class declaration and the associated docblock. - PHPCS:
Yoast.NamingConventions.ObjectNameDepth: Support for examining the word count in CamelCaps class names. - PHPCS:
Yoast.NamingConventions.ValidHookName: Verification that backslashes in namespace-like prefixes in double quoted strings are slash-escaped. - An initial CONTRIBUTING file with guidelines on acceptance testing changes to the sniffs in this repository.
- PHPCS: The default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs has been updated to WP5.7(was5.4). - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.5.0to^3.6.0. - Composer: Supported version of WordPressCS has been changed from
^2.2.0to^2.3.0. - Composer: Updated the supported versions of dev dependencies.
- Readme: Minor documentation improvements.
- Continuous Integration: CI has been moved from Travis to GitHub Actions.
- Various housekeeping.
- PHPCS:
Yoast.Commenting.CoversTag:@coverstags refering to classes and functions which don't follow the WordPressCS naming conventions will now be regarded as valid. - PHPCS:
Yoast.Commenting.TestsHaveCoversTag: the sniff will now also report missing@coverstags for test methods without docblock. - PHPCS:
Yoast.Commenting.TestsHaveCoversTag: the determination whether a class or method is a test class or method has been made more flexible to allow for different test naming conventions. - PHPCS:
Yoast.Commenting.TestsHaveCoversTag: will no longer expect a@coverstag for abstract test methods. - PHPCS:
Yoast.Files.FileComment: fixed performance issue. - PHPCS:
Yoast.Files.FileName: will no longer throw an error when a class names is an exact match for one of the "removable" prefixes (as there would be nothing left to name the file as). - PHPCS:
Yoast.NamingConventions.ObjectNameDepth: the object name depth for underscore prefixed class names will now be calculated correctly. - PHPCS:
Yoast.NamingConventions.ValidHookName: will now recognize slash-escaped backslashes in namespace-like prefixes correctly when in a double quoted string.
2.1.0 - 2020-10-27
- PHPCS: A new check to the
Yoast.Files.TestDoublessniff to verify that all double/mock classes have eitherDoubleorMockin the class name. - PHPCS: Metrics to the
Yoast.NamingConventions.NamespaceNamesniff to see the breakdown of the number of levels used in namespace names across a code base. To see the metrics, run PHPCS with the--report=infooption. - PHPCS: Metrics to the
Yoast.NamingConventions.ObjectNameDepthsniff to see the breakdown of the number of words used in object names across a code base. To see the metrics, run PHPCS with the--report=infooption. - PHPCS: Metrics to the
Yoast.NamingConventions.ValidHookNamesniff to see the breakdown of the number of words used in hook names across a code base, as well as a break down of old-style versus new-style hook name usage. To see the metrics, run PHPCS with the--report=infooption.
- PHPCS: The default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs has been updated to WP5.4(was5.3). - Composer: Supported version of the Composer PHPCS plugin has been changed to allow for the newly released
0.7.0version which adds support for Composer 2.0. Note: this requirement is flexible to prevent conflicts with included standards which may include the plugin as well. - Travis: improved testing against the upcoming PHP 8.0.
- Various housekeeping.
- PHPCS: The
Yoast.Files.FileNamesniff expects a-functionssuffix for a function-only file. The sniff has been updated to also allow such a file to be calledfunctions.phpwithout further specification. This widening is specifically intended for namespaced function-only files. - PHPCS: The
Yoast.NamingConventions.NamespaceNamesniff has improved handling of the allowance for an extra namespace level for test double directories for non-conventional test directory set-ups (like YoastSEO).
2.0.2 - 2020-04-02
- PHPCS: The default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs has been updated to WP5.3(was5.2).
2.0.1 - 2020-02-06
- Composer: Supported version of the Composer PHPCS plugin has been changed from
^0.5.0to^0.5 || ^0.6. Note: this requirement is flexible to prevent conflicts with included standards which may include the plugin as well. - Various housekeeping.
- PHPCS:
Yoast.NamingConventions.NamespaceName: fixed a potential "undefined index" notice.
2.0.0 - 2019-12-17
- PHPCS: New
Yoast.NamingConventions.ObjectNameDepthsniff.- For objects declared within a namespace, this sniff verifies that an object name consist of maximum three words separated by underscores.
- For objects which are part of a unit test suite, a
_Test,_Mockor_Doublesuffix at the end of the object name will be disregarded for the purposes of the word count. - The sniff has two configurable properties
max_words(error) andrecommended_max_words(warning). The default for both is3.
- PHPCS: New
Yoast.NamingConventions.NamespaceNamesniff. This sniff verifies that:- 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.
For unit test files,
Tests\(Doubles\)directly after the prefix will be ignored when determining the level depth. - The levels in the namespace name directly translate to the directory path to the file.
- The sniff has four configurable properties:
max_levels(error) andrecommended_max_levels(warning) which are by default set to3and2respectively.src_directoryto indicate the project root(s) for the path-to-name translation when the project root is not the repo root directory.prefixesto set the plugin specific prefix(es) to take into account.
- 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.
For unit test files,
- PHPCS: New
Yoast.NamingConventions.ValidHookNamesniff. This sniff extends and adds to the upstreamWordPress.NamingConventions.ValidHookNamesniff. 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. This sniff verifies that:- Hook names are in lowercase with words separated by underscores (same as WordPressCS).
- Hook names are prefixed with the plugin specific prefix in namespace format, i.e.
Yoast\WP\PluginName. Note: The prefix is exempt from the lowercase with words separated by underscores rule. If the non-namespace type prefix for a plugin is used, the sniff will throw awarning. - The actual hook name (after the prefix) consist of maximum four words separated by underscores.
- 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.
- Also note: for dynamic hook names where the hook name length can not reliably be determined, the sniff will throw a
warningat severity3suggesting the hook name be inspected manually. As the defaultseverityfor PHPCS is5, thiswarningat severity3will normally not be shown. It is there to allow for intermittently checking of the dynamic hook names. To trigger it,--severity=3should be passed on the command line.
- The sniff has three configurable properties:
maximum_depth(error) andsoft_maximum_depth(warning). The default for both is4.prefixesto set the plugin specific prefix(es) to take into account.
- PHPCS: The
Generic.Arrays.DisallowLongArraySyntaxsniff. WPCS 2.2.0 demands long array syntax. In contrast to that, YoastCS demands short array syntax. - PHPCS: The
Generic.ControlStructures.DisallowYodaConditionssniff. In contrast to WPCS, YoastCS never demanded Yoda conditions. With the addition of this sniff, "normal" (non-Yoda) conditions will now be enforced. - PHPCS: The
Generic.WhiteSpace.SpreadOperatorSpacingAftersniff. Enforces no space between the...spread operator and the variable/function call it applies to. - PHPCS: The
PEAR.WhiteSpace.ObjectOperatorIndentsniff. 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. - PHPCS: The
PSR12.Classes.ClosingBracesniff. This sniff disallows the outdated practice of// end ...comments for OO stuctures. - PHPCS: The
PSR12.Files.ImportStatementsniff. Importusestatements must always be fully qualified, so a leading backslash is redundant (and discouraged by PHP itself). This sniff enforces that no leading backslash is used for importusestatements. - PHPCS: The
PSR12.Files.OpenTagsniff. Enforces that a PHP open tag is on a line by itself in PHP-only files. - PHPCS: A
CustomPrefixesTraitto handle checking names against a list of custom prefixes. - Composer:
lintscript which uses the PHP Parallel Lint package for faster and more readable linting results.
⚠️ PHPCS:Yoast.Files.FileNamesniff: the public$prefixesproperty, 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. Custom repo specific rulesets using the property should be updates to reflect this change.⚠️ PHPCS:Yoast.Files.FileNamesniff: the public$excludeproperty, 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. Custom repo specific rulesets using the property should be updates to reflect this change.- PHPCS: The default setting for the minimum supported PHP version for repos using YoastCS is now PHP 5.6 (was 5.2).
- PHPCS: The default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs has been updated to WP5.2(was4.9). - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.4.2to^3.5.0. Note: this makes the option--filter=gitstagedavailable which can be used in gitpre-commithooks to only check staged files. - Composer: Supported version of WordPressCS has been changed from
^2.1.1to^2.2.0. - Composer: Supported version of PHPCompatibilityWP has been changed from
^2.0.0to^2.1.0. - Travis: the build check is now run in stages.
- Travis: Tests against PHP 7.4 are no longer allowed to fail.
- Various housekeeping & code compliance with YoastCS 2.0.0.
1.3.0 - 2019-07-31
- PHPCS: New
Yoast.Commenting.CoversTagsniff. This sniff verifies that:- the contents of a
@coversannotation is valid based on what's supported by PHPUnit; - there are no duplicate
@coversor@coversNothingtags in a docblock; - a docblock doesn't contain both a
@coverstag as well as a@coversNothingtag; Includes a fixer for common errors.
- the contents of a
- PHPCS: New
Yoast.Commenting.TestsHaveCoversTagsniff. This sniff verifies that all unit test functions have at least one@coverstag - or a@coversNothingtag - in the function docblock or in the class docblock. - PHPCS: New
Yoast.Yoast.AlternativeFunctionssniff. This sniff allows for discouraging/forbidding the use of PHP/WP native functions in favor of using Yoast native functions. In this initial version, the sniff checks for the use of thejson_encode()andwp_json_encode()functions and suggests usingWPSEO_Utils::format_json_encode()instead. Note: this sniff contains an auto-fixer. If for any of the repos, the auto-fixer should not be used, the auto-fixer can be disabled from within the repo specific ruleset using<rule ref="..." phpcs-only="true"/>. - PHPCS: The
Squiz.WhiteSpace.MemberVarSpacingsniff. This sniff verifies and auto-fixes the number of blank lines between property declarations within OO-structures. - PHPCS: A default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs. The current default is WP4.9. Previously this value would have to be set via aconfigdirective in custom repo specific rulesets. For those rulesets which use the Yoast default, thisconfigdirective can now be removed. For more details, see #131. - PHPCS: All YoastCS native sniffs are now accompanied by documentation which can be viewed from the command-line using
phpcs --generator=Text --standard=Yoast. - Repo/QA: Various templates for typical pull requests to this repo.
- Composer:
fix-csscript. - Travis: Testing of the code against PHP 7.4 (unstable).
- PHPCS: Files in the following directories will now be excluded from all scans by default:
/.git//.wordpress-svn//node-modules//vendor//vendor_prefixed/Custom repo specific rulesets which contain excludes to this effect, can now remove them safely.
- PHPCS: The message type for issues reported by the
Generic.Formatting.MultipleStatementAlignmentandWordPress.Arrays.MultipleStatementAlignmentsniffs, has been upgraded fromwarningtoerror. - PHPCS: The WPCS native check for the
json_encode()function in theWordPress.WP.AlternativeFunctionshas been disabled in favor of the new YoastCS nativeYoast.Yoast.AlternativeFunctionssniff. - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.4.0to^3.4.2. - Composer: Supported version of WordPressCS has been changed from
^2.0.0to^2.1.1. - Travis: As there is now a sniff which extends a WPCS sniff, the unit tests will now run against various combinations of PHPCS and WPCS combined.
- Minor housekeeping.
- PHPMD is no longer part of the YoastCS repo. PHPMD was not used as a stand-alone tool by any of the repos, only in combination with CodeClimate.
- Travis: Testing of the repo against PHP
nightly(PHP 8, unstable) as no viable PHPUnit version is currently available.
- PHPCS: The
Yoast.Files.FileNamesniff will now always suggest removing the longest prefix of the prefixes passed in the configuration.
1.2.2 - 2019-01-21
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.3.2to^3.4.0. - Composer: Supported version of WordPressCS has been changed from
^1.2.0to^2.0.0. - PHPCS: The PHPCompatibility ruleset will now explicitly only be applied to PHP files.
1.2.1 - 2018-12-28
- PHPCS: Undefined variable in the
Yoast.Namespaces.NamespaceDeclarationsniff.
1.2.0 - 2018-12-21
- PHPCS: New
Yoast.Commenting.FileCommentsniff. This sniff is a wrapper around theFileCommentsniff used in WordPressCS and manages the slightly different requirements for file comments set for the Yoast organisation, in particular:- If a file is namespaced, no file comment is needed (and having one is discouraged).
- PHPCS: New
Yoast.Namespaces.NamespaceDeclarationsniff. This sniff forbids the use of:- Namespace declarations without a namespace name, i.e.
namespace;which in effect means "global namespace". - Scoped namespace declarations.
- Multiple namespace declarations in one file.
- Namespace declarations without a namespace name, i.e.
1.1.0 - 2018-12-18
- PHPCS: New
Yoast.Commenting.CodeCoverageIgnoreDeprecatedsniff. This sniff verifies that functions which have a@deprecatedtag in the function docblock, also have a@codeCoverageIgnoretag in the same docblock. - PHPCS: Added XSD schema tags to the ruleset.
- Composer: requirement of the Composer PHPCS plugin at version
^0.5.0. This means that - in most cases - projects whichrequire(-dev)YoastCS, will no longer need to have the plugin in their owncomposer.jsonand will still get the benefit of it. - Travis: Validation of the ruleset against the PHPCS XSD schema.
- Travis: Testing of the code against PHP 7.3.
- PHPCS: The
Yoast.Files.TestDoublessniff now allows setting multiple valid paths for test doubles to be placed in. To this end, the publicdoubles_pathproperty has been changed from astringto anarray. - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.3.1to^3.3.2. - Composer: Supported version of WordPressCS has been changed from
^1.0.0to^1.2.0. - Composer: Supported version of PHPCompatibilityWP has been changed from
^1.0.0to^2.0.0, which uses PHPCompatibility^9.0.0under the hood. - Composer: The
config-setscript for use with this repo has been renamed toconfig-yoastcsto be in line with the same script in other repos. - Minor housekeeping: updated
.gitignore.
- PHPCS: Minor housekeeping: removed some unused code.
- Composer:
suggestsection. The Composer PHPCS plugin is now included in therequiresection.
- PHPCS: Various fixes to the
Yoast.Files.TestDoublessniff.- If the
basepathcontained a trailing slash, the sniff could give incorrect results. - Prevent the sniff from recognizing a path like
/tests/doublesniffas correct when/test/doublesis in the allowed list. - The
OneObjectPerFilecheck will now check both code above the detected mock/double class as well as code below it.
- If the
1.0.0 - 2018-08-24
- PHPCS: New
Yoast.Files.TestDoublessniff. This sniff verifies that testdouble/mockclasses are in their own file in adoublestest sub-directory. - PHPCS: New
Yoast.WhiteSpace.FunctionSpacingsniff. This sniff is based on the PHPCS nativeSquiz.WhiteSpace.FunctionSpacingsniff and verifies and auto-fixes the amount of blank lines between methods within OO-structures. - PHPCS: The
Generic.PHP.LowerCaseTypesniff, as introduced in PHP_CodeSniffer 3.3.0, to the YoastCS ruleset. - PHPCS: The
PSR2.Methods.FunctionClosingBracesniff to the YoastCS ruleset. - PHPCS: The
PSR12.Keywords.ShortFormTypeKeywordssniff, as introduced in PHP_CodeSniffer 3.3.0, to the YoastCS ruleset. - Composer:
roave/security-advisoriesdependency to prevent dependencies with known security issues from being installed. - Composer: An explanation about the Composer PHPCS plugin dependency suggestion this package makes.
- Composer:
--devrequirement of the PHPCompatibility library at version^8.2.0.
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.2.0to^3.3.1. - Composer: Supported version of WordPressCS has been changed from
~0.14.0to^1.0.0. - Composer/PHPCS: Switched from using the external PHPCompatibility standard to using PHPCompatibilityWP at version
^1.0.0. - Composer: The command to run
check-csover the code in this repo. PHP_CodeSniffer 3.3.0 allows overruling config directives from the command-line. This also simplies the ruleset used for the YoastCS codebase. - PHPCS: The format for declaring array properties in the ruleset has been updated to the new format available in PHP_CodeSniffer 3.3.0.
- Travis: The installation of dependencies is now done via Composer instead of via cloning repos.
- Travis: CS warnings are no longer allowed in this codebase. The codebase is currently 100% clean, let's keep it that way.
- Composer: The
composer.lockfile. This file is not necessary for library packages and makes the testing of YoastCS sniffs more involved. - PHPCS: Custom excludes for the
PHPCompatibilityruleset. These are no longer necessary after the switch toPHPCompatibilityWP. - PHPCS: Some stray debug code.
- PHPCS:
// End ...comments from the codebase. - Travis: Work-around for the PHPUnit version in the PHP 7.2 and nightly images as PHP_CodeSniffer supports PHPUnit 6.x since version 3.3.0.
- Travis: Builds on PHP 7.2 and nightly were failing because of changes in the Travis images (higher PHPUnit version).
0.5 - 2018-01-25
- PHPCS: New
Yoast.Files.FileNamesniff and exclude the wholeWordPress.Files.FileNamesniff. TheYoast.Files.FileNamesniff verifies that file names comply with the Yoast specific file name rules. - PHPCS: The external PHPCompatibility standard to the YoastCS ruleset at version
^8.1.0. Checking against this standard was previously disabled as it was incompatible with Composer. This has since been fixed. - PHPCS: A WP specific set of excludes for the
PHPCompatibilitystandard to prevent false positives for native PHP functionality which is back-filled by WordPress. - PHPCS: A custom configuration for the new
WordPress.Arrays.MultipleStatementAlignmentsniff as introduced in WordPressCS 0.14.0. - PHPCS: An exclusion for the
WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileConditionerror code. - PHPCS: An exclusion for the
WordPress.PHP.StrictInArray.FoundNonStrictFalseerror code. - Composer: Repository
typeindicator for compatibility with Composer plugins which handle the setting of the PHP_CodeSnifferinstalled_pathsdirective. - Composer: Suggest requiring the Composer PHPCS plugin, i.e.
dealerdirect/phpcodesniffer-composer-installer, for handling the PHP_CodeSnifferinstalled_pathsdirective at version^0.4.3. - Travis: Validation and CS check of the XML files.
- Travis: Testing of the repo against PHP 7.2.
- Travis: Checking of the code style of the YoastCS native PHP files.
- Travis: Validation of the
composer.jsonfile. - A
.gitattributesfile to keep the code distributed via GH archives and Packagist clean of development related files. - A custom PHPCS ruleset,
.phpcs.xml.dist, based on YoastCS to check the code style of the code in the YoastCS repository itself. - A
phpunit.xml.distfile to document the PHPUnit configuration used for testing the YoastCS native sniffs.
- The minimum supported PHP version for YoastCS is now PHP 5.4 (was 5.2).
- Composer: Supported version of PHP_CodeSniffer has been changed from
2.8.1to^3.2.0. - Composer: Supported version of WordPressCS has been changed from
~0.10.0to~0.14.0. - PHPCS: The native YoastCS sniffs are now compatible with PHP_CodeSniffer 3.x.
- PHPCS: Improvements to the native
Yoast.ControlStructures.IfElseDeclarationsniff:- The sniff now has improved detection of issues when non-custom code style is used.
- The sniff has been made more efficient and will exit earlier when no issues are or can be detected.
- The error message has been made more descriptive.
- The sniff will no longer hide one error behind another.
- The sniff will no longer throw false positives when the new PHP_CodeSniffer 3.2.0 inline annotations are encountered.
- Improved inline documentation in the PHPCS ruleset.
- Travis: Minor tweaks to make the builds more efficient.
- Composer: Superfluous
conflictdirective. This has been superseded by a higher minimum PHP_CodeSniffer requirement. - PHPCS: Support for PHP_CodeSniffer 2.x for the YoastCS native sniffs.
- PHPCS: The exclusion of the
Generic.Files.LineEndings.InvalidEOLCharerror code. - PHPCS: The inclusion of the
Generic.Strings.UnnecessaryStringConcatsniff, including custom configuration. This sniff is now included in WordPressCS since version 0.11.0. - PHPCS: The exclusion of the
PEAR.Functions.FunctionCallSignature.Indenterror code as code should comply with this. - PHPCS: The inclusion of the
Squiz.ControlStructurescategory and the related detail configuration. This is now largely covered by WordPressCS 0.14.0. - PHPCS: The exclusion of the whole
WordPress.Variables.GlobalVariablessniff. This sniff was previously excluded because of a bug in WordPressCS. This bug has been fixed in WordPressCS 0.11.0. - PHPCS: The exclusion of the
WordPress.VIP.DirectDatabaseQuery,WordPress.VIP.FileSystemWritesDisallow,WordPress.XSS.EscapeOutput,WordPress.VIP.ValidatedSanitizedInputsniffs and theGeneric.Commenting.DocComment.MissingShorterror code. These kind of excludes should be handled in the plugin specific rulesets, not across the board in the YoastCS ruleset. - PHPCS: The group exclusion configurations for the
WordPress.VIP.RestrictedFunctions,WordPress.VIP.RestrictedVariablesand theWordPress.VIP.PostsPerPagesniffs. This kind of configuration should be handled in the plugin specific rulesets, not across the board in the YoastCS ruleset.
- Code style consistency for the
xmlfiles in this repository. - Code style consistency for the
phpfiles in this repository. - PHPCS: Exclusion patterns for the empty
index.phpfiles.
0.4.3 - 2017-08-02
- PHPCS: The
Generic.Strings.UnnecessaryStringConcatsniff to the YoastCS ruleset. - PHPCS: An exclusion for the
Generic.PHP.Syntaxsniff. The Yoast plugins all runphp lintagainst a variety of PHP versions, which is the recommended way to check for PHP syntax errors. - PHPCS: Exclusions for the following additional function groups for the
WordPress.VIP.RestrictedFunctionssniff:error_log,runtime_configuration,prevent_path_disclosure,url_to_postid.
- Travis: Limit the testing of the sniff unit tests to PHP_CodeSniffer 2.x as YoastCS does not yet support PHP_CodeSniffer 3.x.
- Travis: Builds for PHP 5.2 and 5.3 were failing because of changes in the Travis images.
0.4.2 - 2017-03-22
- Composer: Included version of PHP_CodeSniffer has been changed from
2.7.0to2.8.1. The minimum supported version remains at2.8.1as updated in YoastCS 0.4.1. - Composer: Included version of PHP Mess Detector has been updated from
2.4.3to2.6.0. The minimum supported version remains at2.2.3. - PHPCS: YoastCS is now based on the full
WordPressruleset, rather than theWordPress-VIPruleset. See: #16.
- PHPCS: The exclusion of the whole
WordPress.NamingConventions.ValidVariableNamesniff. This sniff was previously excluded because of a bug in WordPressCS. This bug has been fixed in WordPressCS 0.10.0.
0.4.1 - 2017-03-21
- PHPCS: Unit tests for the
Yoast.ControlStructures.IfElseDeclarationsniff. - Travis build testing.
- Composer: Supported version of PHP_CodeSniffer has been changed from
2.7.0to~2.8.1. - PHPCS: Exclude function groups rather than individual error codes for WordPressCS sniffs which allow for this.
- PHPCS: The exclusion for the
Squiz.Commenting.FunctionComment.ScalarTypeHintMissingerror code. This is already taken care of upstream in WordPressCS 0.10.0. - PHPCS: Explicit inclusion of the YoastCS native
Yoast.ControlStructures.IfElseDeclarationsniff from the YoastCS ruleset. AllYoastsniffs are automatically included, so the explicit inclusion was redundant.
0.4 - 2016-09-06
- Composer: Supported version of PHP_CodeSniffer has been changed from
2.5.1to~2.7.0. - Composer: Supported version of WordPressCS has been changed from
0.9to~0.10.0. - Composer: Included version of PHP Mess Detector has been updated from
2.4.2to2.4.3. The minimum supported version remains at2.2.3.
0.3 - 2016-05-03
- PHPCS: An exclusion for the
WordPress.VIP.RestrictedFunctions.get_pageserror code to the YoastCS ruleset.
0.2 - 2016-04-01
- PHPCS: An exclusion for the
PEAR.Functions.FunctionCallSignature.Indenterror code to the YoastCS ruleset. - PHPCS: An exclusion for the
Squiz.Commenting.FunctionComment.ScalarTypeHintMissingerror code. - PHPCS: An exclusion for the whole
WordPress.NamingConventions.ValidVariableNamesniff. - PHPCS: An exclusion for the
WordPress.VIP.RestrictedFunctions.count_user_postserror code. - PHPMD:
wpto the list of common exceptions to theShortVariablename rule.
- Composer: Supported version of PHP_CodeSniffer has been changed from
^2.2.0to2.5.1. - Composer: Supported version of WordPressCS has been changed from
0.6to0.9. - Composer: Included version of PHP Mess Detector has been updated from
2.2.3to2.4.2. The minimum supported version remains at2.2.3.
- PHPCS: The exclusion of the whole
WordPress.NamingConventions.ValidFunctionNamesniff from the YoastCS ruleset.
Initial public release as a stand-alone package.