Skip to content
Snippets Groups Projects
Unverified Commit a05b9d08 authored by Eirik Morland's avatar Eirik Morland Committed by GitHub
Browse files

fix(Deprecated): Semantic versions support for contrib projects (#3138133 by eiriksm)

parent fb226796
No related branches found
No related tags found
No related merge requests found
......@@ -169,14 +169,12 @@ class DeprecatedSniff implements Sniff
}
} else {
// The text follows the basic layout. Now check that the versions
// match drupal:n.n.n or project:n.x-n.n or project:n.x-n.n-version[n].
// match drupal:n.n.n or project:n.x-n.n or project:n.x-n.n-version[n]
// or project:n.n.n or project:n.n.n-version[n].
// The text must be all lower case and numbers can be one or two digits.
foreach (['deprecation-version' => $matches[1], 'removal-version' => $matches[2]] as $name => $version) {
if (preg_match('/^drupal:\d{1,2}\.\d{1,2}\.\d{1,2}$/', $version) === 0
&& preg_match('/^[a-z\d_]+:\d{1,2}\.x\-\d{1,2}\.\d{1,2}$/', $version) === 0
&& preg_match('/^[a-z\d_]+:\d{1,2}\.x\-\d{1,2}\.\d{1,2}-[a-z]{1,5}\d{1,2}$/', $version) === 0
) {
$error = "The %s '%s' does not match the lower-case machine-name standard: drupal:n.n.n or project:n.x-n.n or project:n.x-n.n-version[n]";
if (preg_match('/^[a-z\d_]+:(\d{1,2}\.\d{1,2}\.\d{1,2}|\d{1,2}\.x\-\d{1,2}\.\d{1,2})(-[a-z]{1,5}\d{1,2})?$/', $version) === 0) {
$error = "The %s '%s' does not match the lower-case machine-name standard: drupal:n.n.n or project:n.x-n.n or project:n.x-n.n-version[n] or project:n.n.n or project:n.n.n-version[n]";
$phpcsFile->addWarning($error, $stackPtr, 'DeprecatedVersionFormat', [$name, $version]);
}
}
......
......@@ -100,3 +100,13 @@ function w() {
* has 'removal', upper-case 'drupal' and short second version.
* @see http://www.drupal.org/node/123?.
*/
/**
* This contrib doc block will pass the 'Deprecated' standards checks.
*
* @deprecated in project:8.1.0 and is removed from project:8.2.0. This uses
* semantic versioning, but this is now allowed, so we should allow it as well.
* @see http://www.drupal.org/node/7890
*/
function meanwhile() {
}
......@@ -100,3 +100,13 @@ function w() {
* has 'removal', upper-case 'drupal' and short second version.
* @see http://www.drupal.org/node/123
*/
/**
* This contrib doc block will pass the 'Deprecated' standards checks.
*
* @deprecated in project:8.1.0 and is removed from project:8.2.0. This uses
* semantic versioning, but this is now allowed, so we should allow it as well.
* @see http://www.drupal.org/node/7890
*/
function meanwhile() {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment