Skip to content
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

Allow more version numbers in @deprecated tag #439

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion Magento2/Helpers/Commenting/PHPDocFormattingValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento2\Helpers\Commenting;

use PHP_CodeSniffer\Files\File;
Expand All @@ -18,6 +19,7 @@ class PHPDocFormattingValidator
*
* @param int $startPtr
* @param File $phpcsFile
*
* @return int
*/
public function findPHPDoc($startPtr, $phpcsFile)
Expand Down Expand Up @@ -53,6 +55,7 @@ public function findPHPDoc($startPtr, $phpcsFile)
* @param int $namePtr
* @param int $commentStartPtr
* @param array $tokens
*
* @return bool
*/
public function providesMeaning($namePtr, $commentStartPtr, $tokens)
Expand Down Expand Up @@ -113,6 +116,7 @@ public function providesMeaning($namePtr, $commentStartPtr, $tokens)
*
* @param int $commentStartPtr
* @param array $tokens
*
* @return bool
*/
public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
Expand All @@ -124,11 +128,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/",
"/This [a-zA-Z]+ will be removed in version \d+\.\d+\.\d+ without replacement/",
$tokens[$deprecatedPtr + 2]['content']
)) {
return true;
}

return false;
}

Expand All @@ -141,6 +146,7 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
* @param string $tag
* @param int $commentStartPtr
* @param array $tokens
*
* @return int
*/
private function getTagPosition($tag, $commentStartPtr, $tokens)
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 @@ -380,6 +380,16 @@ class MethodAnnotationFixture
return false;
}

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

/**
* This deprecated function is correct even though it only contains the @deprecated tag.
*
Expand All @@ -390,6 +400,16 @@ class MethodAnnotationFixture
return false;
}

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

/** @var OutputInterface */
private $output;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public function getErrorList()
288 => 1,
289 => 1,
298 => 1,
396 => 1,
407 => 1,
418 => 1,
424 => 1,
416 => 1,
427 => 1,
438 => 1,
444 => 1,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ class DeprecatedButHandler

}

/**
* @deprecated This class will be removed in version 123.45.6789 without replacement
*/
class DeprecatedButHandlerLongVersion
{

}

/**
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
*/
Expand All @@ -179,6 +187,14 @@ class AlsoDeprecatedButHandler

}

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

}

/**
* @package this tag should not be used
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ class DeprecatedButHandler

}

/**
* @deprecated This class will be removed in version 123.45.6789 without replacement
*/
class DeprecatedButHandlerLongVersion
{

}

/**
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
*/
Expand All @@ -159,6 +167,14 @@ class AlsoDeprecatedButHandler

}

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

}

class OnlyUselessCommentContent
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ interface DeprecatedButHandler

}

/**
* @deprecated This interface will be removed in version 123.45.6789 without replacement
*/
interface DeprecatedButHandlerLongVersion
{

}

/**
* @deprecated Yeah! This interface will be removed in version 1.0.0 without replacement
*/
Expand All @@ -179,6 +187,14 @@ interface AlsoDeprecatedButHandler

}

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

}

/**
* @package this tag should not be used
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ interface DeprecatedButHandler

}

/**
* @deprecated This interface will be removed in version 123.45.6789 without replacement
*/
interface DeprecatedButHandlerLongVersion
{

}

/**
* @deprecated Yeah! This interface will be removed in version 1.0.0 without replacement
*/
Expand All @@ -159,6 +167,14 @@ interface AlsoDeprecatedButHandler

}

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

}

interface OnlyUselessCommentContent
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento2\Tests\Commenting;

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
Expand Down Expand Up @@ -37,7 +38,7 @@ public function getWarningList($testFile = '')
109 => 1,
118 => 1,
127 => 1,
183 => 1,
199 => 1,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ class correctlyFormattedClassMemberDocBlock
*/
protected string $deprecatedWithKeyword;

/**
* @var string
* @deprecated This property will be removed in version 123.45.6789 without replacement
*/
protected string $deprecatedWithKeywordLongVersion;

/**
* @var string
*/
Expand Down
10 changes: 10 additions & 0 deletions Magento2/Tests/Commenting/ConstantsPHPDocFormattingUnitTest.2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ class Profiler
*/
const KEYWORD_PHRASE = false;

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

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

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