Skip to content

Commit 6f6f7e0

Browse files
committed
Add test case for happy path
1 parent ad4d668 commit 6f6f7e0

9 files changed

+108
-1
lines changed

Magento2/Helpers/Commenting/PHPDocFormattingValidator.php

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
78
namespace Magento2\Helpers\Commenting;
89

910
use PHP_CodeSniffer\Files\File;
@@ -18,6 +19,7 @@ class PHPDocFormattingValidator
1819
*
1920
* @param int $startPtr
2021
* @param File $phpcsFile
22+
*
2123
* @return int
2224
*/
2325
public function findPHPDoc($startPtr, $phpcsFile)
@@ -53,6 +55,7 @@ public function findPHPDoc($startPtr, $phpcsFile)
5355
* @param int $namePtr
5456
* @param int $commentStartPtr
5557
* @param array $tokens
58+
*
5659
* @return bool
5760
*/
5861
public function providesMeaning($namePtr, $commentStartPtr, $tokens)
@@ -113,6 +116,7 @@ public function providesMeaning($namePtr, $commentStartPtr, $tokens)
113116
*
114117
* @param int $commentStartPtr
115118
* @param array $tokens
119+
*
116120
* @return bool
117121
*/
118122
public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
@@ -129,6 +133,7 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
129133
)) {
130134
return true;
131135
}
136+
132137
return false;
133138
}
134139

@@ -141,6 +146,7 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
141146
* @param string $tag
142147
* @param int $commentStartPtr
143148
* @param array $tokens
149+
*
144150
* @return int
145151
*/
146152
private function getTagPosition($tag, $commentStartPtr, $tokens)

Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc

+20
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,16 @@ class MethodAnnotationFixture
380380
return false;
381381
}
382382

383+
/**
384+
* This deprecated function is correct even though it only contains the @deprecated tag.
385+
*
386+
* @deprecated This method will be removed in version 123.45.6789 without replacement
387+
*/
388+
public function correctBecauseOfKeywordPhraseLongVersion()
389+
{
390+
return false;
391+
}
392+
383393
/**
384394
* This deprecated function is correct even though it only contains the @deprecated tag.
385395
*
@@ -389,4 +399,14 @@ class MethodAnnotationFixture
389399
{
390400
return false;
391401
}
402+
403+
/**
404+
* This deprecated function is correct even though it only contains the @deprecated tag.
405+
*
406+
* @deprecated WOW! This method will be removed in version 123.45.6789 without replacement
407+
*/
408+
public function alsoCorrectBecauseOfKeywordPhraseLongVersion()
409+
{
410+
return false;
411+
}
392412
}

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.1.inc

+16
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ class DeprecatedButHandler
171171

172172
}
173173

174+
/**
175+
* @deprecated This class will be removed in version 123.45.6789 without replacement
176+
*/
177+
class DeprecatedButHandlerLongVersion
178+
{
179+
180+
}
181+
174182
/**
175183
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
176184
*/
@@ -179,6 +187,14 @@ class AlsoDeprecatedButHandler
179187

180188
}
181189

190+
/**
191+
* @deprecated It's also deprecated - This class will be removed in version 123.45.6789 without replacement
192+
*/
193+
class AlsoDeprecatedButHandlerLongVersion
194+
{
195+
196+
}
197+
182198
/**
183199
* @package this tag should not be used
184200
*/

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.1.inc.fixed

+16
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ class DeprecatedButHandler
151151

152152
}
153153

154+
/**
155+
* @deprecated This class will be removed in version 123.45.6789 without replacement
156+
*/
157+
class DeprecatedButHandlerLongVersion
158+
{
159+
160+
}
161+
154162
/**
155163
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
156164
*/
@@ -159,6 +167,14 @@ class AlsoDeprecatedButHandler
159167

160168
}
161169

170+
/**
171+
* @deprecated It's also deprecated - This class will be removed in version 123.45.6789 without replacement
172+
*/
173+
class AlsoDeprecatedButHandlerLongVersion
174+
{
175+
176+
}
177+
162178
class OnlyUselessCommentContent
163179
{
164180

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.2.inc

+16
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ interface DeprecatedButHandler
171171

172172
}
173173

174+
/**
175+
* @deprecated This interface will be removed in version 123.45.6789 without replacement
176+
*/
177+
interface DeprecatedButHandlerLongVersion
178+
{
179+
180+
}
181+
174182
/**
175183
* @deprecated Yeah! This interface will be removed in version 1.0.0 without replacement
176184
*/
@@ -179,6 +187,14 @@ interface AlsoDeprecatedButHandler
179187

180188
}
181189

190+
/**
191+
* @deprecated Yeah! This interface will be removed in version 123.45.6789 without replacement
192+
*/
193+
interface AlsoDeprecatedButHandlerLongVersion
194+
{
195+
196+
}
197+
182198
/**
183199
* @package this tag should not be used
184200
*/

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.2.inc.fixed

+16
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ interface DeprecatedButHandler
151151

152152
}
153153

154+
/**
155+
* @deprecated This interface will be removed in version 123.45.6789 without replacement
156+
*/
157+
interface DeprecatedButHandlerLongVersion
158+
{
159+
160+
}
161+
154162
/**
155163
* @deprecated Yeah! This interface will be removed in version 1.0.0 without replacement
156164
*/
@@ -159,6 +167,14 @@ interface AlsoDeprecatedButHandler
159167

160168
}
161169

170+
/**
171+
* @deprecated Yeah! This interface will be removed in version 123.45.6789 without replacement
172+
*/
173+
interface AlsoDeprecatedButHandlerLongVersion
174+
{
175+
176+
}
177+
162178
interface OnlyUselessCommentContent
163179
{
164180

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
78
namespace Magento2\Tests\Commenting;
89

910
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
@@ -37,7 +38,7 @@ public function getWarningList($testFile = '')
3738
109 => 1,
3839
118 => 1,
3940
127 => 1,
40-
183 => 1,
41+
199 => 1,
4142
];
4243
}
4344
}

Magento2/Tests/Commenting/ClassPropertyPHPDocFormattingUnitTest.inc

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ class correctlyFormattedClassMemberDocBlock
201201
*/
202202
protected string $deprecatedWithKeyword;
203203

204+
/**
205+
* @var string
206+
* @deprecated This property will be removed in version 123.45.6789 without replacement
207+
*/
208+
protected string $deprecatedWithKeywordLongVersion;
209+
204210
/**
205211
* @var string
206212
*/

Magento2/Tests/Commenting/ConstantsPHPDocFormattingUnitTest.2.inc

+10
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,18 @@ class Profiler
6969
*/
7070
const KEYWORD_PHRASE = false;
7171

72+
/**
73+
* @deprecated This constant will be removed in version 123.45.6789 without replacement
74+
*/
75+
const KEYWORD_PHRASE_LONG_VERSION = false;
76+
7277
/**
7378
* @deprecated It's awesome - This constant will be removed in version 1.0.0 without replacement
7479
*/
7580
const WITH_KEYWORD_PHRASE = false;
81+
82+
/**
83+
* @deprecated It's awesome - This constant will be removed in version 123.45.6789 without replacement
84+
*/
85+
const WITH_KEYWORD_PHRASE_LONG_VERSION = false;
7686
}

0 commit comments

Comments
 (0)