@@ -75,20 +94,79 @@ class DeprecatedSniff implements Sniff
}
}
$depText=trim($depText);
// The standard format for the deprecation text is:
// @deprecated in %in-version% and will be removed from %removal-version%. %extra-info%.
// Use (?U) 'ungreedy' before the version so that only the text up to
// the first '. ' is matched, as there may be more than one sentence in
// the extra-info part.
// @deprecated in %in-version% and is removed from %removal-version%. %extra-info%.
$standardFormat="@deprecated in %%deprecation-version%% and is removed from %%removal-version%%. %%extra-info%%.";
// Use (?U) 'ungreedy' before the removal-version so that only the text
// up to the first dot+space is matched, as there may be more than one
// sentence in the extra-info part.
$fullText=trim(implode(' ',$textItems));
$matches=[];
preg_match('/in (.+) and is removed from (?U)(.+)\. (.+)$/',$depText,$matches);
preg_match('/^in (.+) and is removed from (?U)(.+)(?:\. | |\.$|$)(.*)$/',$fullText,$matches);
// There should be 4 items in $matches: 0 is full text, 1 = in-version,
// 2 = removal-version, 3 = extra-info.
// 2 = removal-version, 3 = extra-info (can be blank at this stage).
if(count($matches)!==4){
$error="The text '@deprecated %s' does not match the standard format: @deprecated in %%deprecation-version%% and is removed from %%removal-version%%. %%extra-info%%.";