Skip to content

Commit

Permalink
Add test case for happy path
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Sep 27, 2023
1 parent 8776b2a commit f232754
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 2 deletions.
6 changes: 6 additions & 0 deletions 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 @@ -129,6 +133,7 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
)) {
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 @@ -39,7 +39,7 @@ public function getErrorList()
288 => 1,
289 => 1,
298 => 1,
396 => 1,
416 => 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;
}

0 comments on commit f232754

Please sign in to comment.