Skip to content

Commit 6e5f03a

Browse files
authored
Merge pull request #66 from magento-commerce/imported-magento-magento-coding-standard-272
[Imported] Version 10 master update
2 parents 64fe3cd + ec62c5c commit 6e5f03a

File tree

130 files changed

+812
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+812
-125
lines changed

Magento2/Helpers/Commenting/PHPDocFormattingValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* Copyright © Magento. All rights reserved.
4+
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
77
namespace Magento2\Helpers\Commenting;

Magento2/Sniffs/Classes/AbstractApiSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Classes;

Magento2/Sniffs/Classes/DiscouragedDependenciesSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Classes;

Magento2/Sniffs/CodeAnalysis/EmptyBlockSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\CodeAnalysis;

Magento2/Sniffs/Commenting/ClassAndInterfacePHPDocFormattingSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* Copyright © Magento. All rights reserved.
4+
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
77
namespace Magento2\Sniffs\Commenting;

Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
26
namespace Magento2\Sniffs\Commenting;
37

48
use PHP_CodeSniffer\Files\File;
@@ -108,10 +112,11 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
108112
if ($varParts[1]) {
109113
return;
110114
}
111-
$error = 'Short description duplicates class property name.';
112-
$phpcsFile->addWarning($error, $isShortDescriptionAfterVar, 'AlreadyHaveMeaningFulNameVar');
115+
$error = 'Short description must be before @var tag.';
116+
$phpcsFile->addWarning($error, $isShortDescriptionAfterVar, 'ShortDescriptionAfterVar');
113117
return;
114118
}
119+
115120
// Check if class has already have meaningful description before @var tag
116121
$isShortDescriptionPreviousVar = $phpcsFile->findPrevious(
117122
T_DOC_COMMENT_STRING,
@@ -121,23 +126,37 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
121126
null,
122127
false
123128
);
124-
if ($this->PHPDocFormattingValidator->providesMeaning(
125-
$isShortDescriptionPreviousVar,
126-
$commentStart,
127-
$tokens
128-
) !== true) {
129-
preg_match(
130-
'`^((?:\|?(?:array\([^\)]*\)|[\\\\\[\]]+))*)( .*)?`i',
131-
$tokens[($foundVar + 2)]['content'],
132-
$varParts
133-
);
134-
if ($varParts[1]) {
135-
return;
136-
}
129+
130+
if ($isShortDescriptionPreviousVar === false) {
131+
return;
132+
}
133+
134+
$propertyNamePosition = $phpcsFile->findNext(
135+
T_VARIABLE,
136+
$foundVar,
137+
null,
138+
false,
139+
null,
140+
false
141+
);
142+
if ($propertyNamePosition === false) {
143+
return;
144+
};
145+
$propertyName = trim($tokens[$propertyNamePosition]['content'], '$');
146+
$shortDescription = strtolower($tokens[$isShortDescriptionPreviousVar]['content']);
147+
148+
if ($shortDescription === strtolower($propertyName)) {
137149
$error = 'Short description duplicates class property name.';
138-
$phpcsFile->addWarning($error, $isShortDescriptionPreviousVar, 'AlreadyHaveMeaningFulNameVar');
150+
$phpcsFile->addWarning($error, $isShortDescriptionPreviousVar, 'AlreadyHaveMeaningfulNameVar');
139151
return;
140152
}
153+
154+
$propertyNameParts = array_filter(preg_split('/(?=[A-Z])/', $propertyName));
155+
156+
if ($shortDescription === strtolower(implode(' ', $propertyNameParts))) {
157+
$error = 'Short description duplicates class property name.';
158+
$phpcsFile->addWarning($error, $isShortDescriptionPreviousVar, 'AlreadyHaveMeaningfulNameVar');
159+
}
141160
}
142161

143162
/**

Magento2/Sniffs/Commenting/ConstantsPHPDocFormattingSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Commenting;

Magento2/Sniffs/Exceptions/DirectThrowSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Exceptions;

Magento2/Sniffs/Exceptions/ThrowCatchSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66

Magento2/Sniffs/Exceptions/TryProcessSystemResourcesSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © Magento. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
namespace Magento2\Sniffs\Exceptions;

0 commit comments

Comments
 (0)