Skip to content

Commit 246c67b

Browse files
committed
Refactor: Use preg_match
1 parent 180c510 commit 246c67b

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Magento2/Helpers/Commenting/PHPDocFormattingValidator.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*/
1414
class PHPDocFormattingValidator
1515
{
16-
private const REMOVED_IN_VERSION = 'removed in version';
17-
private const WITHOUT_REPLACEMENT = 'without replacement';
18-
1916
/**
2017
* Finds matching PHPDoc for current pointer
2118
*
@@ -126,8 +123,10 @@ public function hasDeprecatedWellFormatted($commentStartPtr, $tokens)
126123
}
127124
$seePtr = $this->getTagPosition('@see', $commentStartPtr, $tokens);
128125
if ($seePtr === -1) {
129-
if (stripos($tokens[$deprecatedPtr + 2]['content'], self::REMOVED_IN_VERSION, 0) !== false &&
130-
stripos($tokens[$deprecatedPtr + 2]['content'], self::WITHOUT_REPLACEMENT, 0) !== false) {
126+
if (preg_match(
127+
"/This [a-zA-Z]* will be removed in version \d.\d.\d without replacement/",
128+
$tokens[$deprecatedPtr + 2]['content']
129+
)) {
131130
return true;
132131
}
133132
return false;

Magento2/Tests/Annotation/MethodAnnotationStructureUnitTest.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class MethodAnnotationFixture
373373
/**
374374
* This deprecated function is correct even though it only contains the @deprecated tag.
375375
*
376-
* @deprecated It will be removed in version 1.0.0 without replacement
376+
* @deprecated This method will be removed in version 1.0.0 without replacement
377377
*/
378378
public function correctBecauseOfKeywordPhrase()
379379
{
@@ -383,7 +383,7 @@ class MethodAnnotationFixture
383383
/**
384384
* This deprecated function is correct even though it only contains the @deprecated tag.
385385
*
386-
* @deprecated WOW! It will be removed in version 1.0.0 without replacement
386+
* @deprecated WOW! This method will be removed in version 1.0.0 without replacement
387387
*/
388388
public function alsoCorrectBecauseOfKeywordPhrase()
389389
{

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.1.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ class OldHandler
164164
}
165165

166166
/**
167-
* @deprecated It will be removed in version 1.0.0 without replacement
167+
* @deprecated This class will be removed in version 1.0.0 without replacement
168168
*/
169169
class DeprecatedButHandler
170170
{
171171

172172
}
173173

174174
/**
175-
* @deprecated It's also deprecated, but it will be removed in version 1.0.0 without replacement
175+
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
176176
*/
177177
class AlsoDeprecatedButHandler
178178
{

0 commit comments

Comments
 (0)