Skip to content

Allow to skip see tag in annotation with specific deprecated comment #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Magento2/Helpers/Commenting/PHPDocFormattingValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
}
$seePtr = $this->getTagPosition('@see', $commentStartPtr, $tokens);
if ($seePtr === -1) {
if (preg_match(
"/This [a-zA-Z]* will be removed in version \d.\d.\d without replacement/",
$tokens[$deprecatedPtr + 2]['content']
)) {
return true;
}
return false;
}

Expand Down
20 changes: 20 additions & 0 deletions Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,24 @@ class MethodAnnotationFixture
{
return true;
}

/**
* This deprecated function is correct even though it only contains the @deprecated tag.
*
* @deprecated This method will be removed in version 1.0.0 without replacement
*/
public function correctBecauseOfKeywordPhrase()
{
return false;
}

/**
* This deprecated function is correct even though it only contains the @deprecated tag.
*
* @deprecated WOW! This method will be removed in version 1.0.0 without replacement
*/
public function alsoCorrectBecauseOfKeywordPhrase()
{
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,20 @@ class OldHandler
{

}

/**
* @deprecated This class will be removed in version 1.0.0 without replacement
*/
class DeprecatedButHandler
{

}

/**
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
*/
class AlsoDeprecatedButHandler
{

}

Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,19 @@ interface DoNotCareHandler
{

}

/**
* @deprecated This interface will be removed in version 1.0.0 without replacement
*/
interface DeprecatedButHandler
{

}

/**
* @deprecated Yeah! This interface will be removed in version 1.0.0 without replacement
*/
interface AlsoDeprecatedButHandler
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,10 @@ class correctlyFormattedClassMemberDocBlock
* @see Message with some reference
*/
protected string $itIsCorrect;

/**
* @var string
* @deprecated This property will be removed in version 1.0.0 without replacement
*/
protected string $deprecatedWithKeyword;
}
10 changes: 10 additions & 0 deletions Magento2/Tests/Commenting/ConstantsPHPDocFormattingUnitTest.2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,14 @@ class Profiler
* @see
*/
const d = 100;

/**
* @deprecated This constant will be removed in version 1.0.0 without replacement
*/
const KEYWORD_PHRASE = false;

/**
* @deprecated It's awesome - This constant will be removed in version 1.0.0 without replacement
*/
const WITH_KEYWORD_PHRASE = false;
}