Skip to content

Commit 2cf24b3

Browse files
committed
Implement changes approved to @see tag in Dev guild
1 parent c2e4f0a commit 2cf24b3

6 files changed

+75
-1
lines changed

Magento2/Helpers/Commenting/PHPDocFormattingValidator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
class PHPDocFormattingValidator
1515
{
16+
private const REMOVED_IN_VERSION = 'removed in version';
17+
1618
/**
1719
* Finds matching PHPDoc for current pointer
1820
*
@@ -123,7 +125,10 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
123125
}
124126
$seePtr = $this->getTagPosition('@see', $commentStartPtr, $tokens);
125127
if ($seePtr === -1) {
126-
return false;
128+
if (!stripos($tokens[$deprecatedPtr + 2]['content'], self::REMOVED_IN_VERSION, 0)) {
129+
return false;
130+
}
131+
return true;
127132
}
128133

129134
return $tokens[$seePtr + 2]['code'] === T_DOC_COMMENT_STRING;

Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,24 @@ class MethodAnnotationFixture
369369
{
370370
return true;
371371
}
372+
373+
/**
374+
* This deprecated function is correct even though it only contains the @deprecated tag.
375+
*
376+
* @deprecated It will be removed in version 1.0.0
377+
*/
378+
public function correctBecauseOfKeywordPhrase()
379+
{
380+
return false;
381+
}
382+
383+
/**
384+
* This deprecated function is correct even though it only contains the @deprecated tag.
385+
*
386+
* @deprecated WOW! It will be removed in version 1.0.0
387+
*/
388+
public function alsoCorrectBecauseOfKeywordPhrase()
389+
{
390+
return false;
391+
}
372392
}

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.1.inc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,20 @@ class OldHandler
162162
{
163163

164164
}
165+
166+
/**
167+
* @deprecated It will be removed in version 1.0.0
168+
*/
169+
class DeprecatedButHandler
170+
{
171+
172+
}
173+
174+
/**
175+
* @deprecated It's also deprecated, but it will be removed in version 1.0.0
176+
*/
177+
class AlsoDeprecatedButHandler
178+
{
179+
180+
}
181+

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.2.inc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,19 @@ interface DoNotCareHandler
153153
{
154154

155155
}
156+
157+
/**
158+
* @deprecated This interface will be removed in version 1.0.0
159+
*/
160+
interface DeprecatedButHandler
161+
{
162+
163+
}
164+
165+
/**
166+
* @deprecated Yeah! This interface will be removed in version 1.0.0
167+
*/
168+
interface AlsoDeprecatedButHandler
169+
{
170+
171+
}

Magento2/Tests/Commenting/ClassPropertyPHPDocFormattingUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,10 @@ class correctlyFormattedClassMemberDocBlock
194194
* @see Message with some reference
195195
*/
196196
protected string $itIsCorrect;
197+
198+
/**
199+
* @var string
200+
* @deprecated This property will be removed in version 1.0.0
201+
*/
202+
protected string $deprecatedWithKeyword;
197203
}

Magento2/Tests/Commenting/ConstantsPHPDocFormattingUnitTest.2.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,14 @@ class Profiler
6363
* @see
6464
*/
6565
const d = 100;
66+
67+
/**
68+
* @deprecated This constant will be removed in version 1.0.0
69+
*/
70+
const KEYWORD_PHRASE = false;
71+
72+
/**
73+
* @deprecated It's awesome - This constant will be removed in version 1.0.0
74+
*/
75+
const WITH_KEYWORD_PHRASE = false;
6676
}

0 commit comments

Comments
 (0)