Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a490fea

Browse filesBrowse files
authored
Merge pull request #30 from magento-commerce/imported-magento-magento-coding-standard-234
[Imported] Version 8 master update
2 parents 0370887 + 05c75c0 commit a490fea
Copy full SHA for a490fea
Expand file treeCollapse file tree

20 files changed

+745
-43
lines changed

‎Magento2/Sniffs/Annotation/AnnotationFormatValidator.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Annotation/AnnotationFormatValidator.php
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private function validateMultiLinesInShortDescription(
6464
&& $tokens[$shortPtrEnd]['code'] !== T_DOC_COMMENT_TAG
6565
) {
6666
$error = 'Short description should not be in multi lines';
67-
$phpcsFile->addFixableError($error, $shortPtrEnd + 1, 'MethodAnnotation');
67+
$phpcsFile->addError($error, $shortPtrEnd + 1, 'MethodAnnotation');
6868
}
6969
}
7070

@@ -95,7 +95,7 @@ private function validateSpacingBetweenShortAndLongDescriptions(
9595
&& $tokens[$shortPtrEnd]['code'] !== T_DOC_COMMENT_TAG
9696
) {
9797
$error = 'There must be exactly one blank line between lines short and long descriptions';
98-
$phpcsFile->addFixableError($error, $shortPtrEnd + 1, 'MethodAnnotation');
98+
$phpcsFile->addError($error, $shortPtrEnd + 1, 'MethodAnnotation');
9999
}
100100
if ($shortPtrEnd != $shortPtr) {
101101
$this->validateLongDescriptionFormat($phpcsFile, $shortPtrEnd, $commentEndPtr, $emptyTypeTokens);
@@ -123,16 +123,16 @@ private function validateShortDescriptionFormat(
123123
$tokens = $phpcsFile->getTokens();
124124
if ($tokens[$shortPtr]['line'] !== $tokens[$stackPtr]['line'] + 1) {
125125
$error = 'No blank lines are allowed before short description';
126-
$phpcsFile->addFixableError($error, $shortPtr, 'MethodAnnotation');
126+
$phpcsFile->addError($error, $shortPtr, 'MethodAnnotation');
127127
}
128128
if (strtolower($tokens[$shortPtr]['content']) === '{@inheritdoc}') {
129129
$error = 'If the @inheritdoc not inline it shouldn’t have braces';
130-
$phpcsFile->addFixableError($error, $shortPtr, 'MethodAnnotation');
130+
$phpcsFile->addError($error, $shortPtr, 'MethodAnnotation');
131131
}
132132
$shortPtrContent = $tokens[$shortPtr]['content'];
133133
if (preg_match('/^\p{Ll}/u', $shortPtrContent) === 1) {
134134
$error = 'Short description must start with a capital letter';
135-
$phpcsFile->addFixableError($error, $shortPtr, 'MethodAnnotation');
135+
$phpcsFile->addError($error, $shortPtr, 'MethodAnnotation');
136136
}
137137
$this->validateNoExtraNewLineBeforeShortDescription(
138138
$phpcsFile,
@@ -171,16 +171,16 @@ private function validateLongDescriptionFormat(
171171
$longPtr = $phpcsFile->findNext($emptyTypeTokens, $shortPtrEnd + 1, $commentEndPtr - 1, true);
172172
if (strtolower($tokens[$longPtr]['content']) === '@inheritdoc') {
173173
$error = '@inheritdoc imports only short description, annotation must have long description';
174-
$phpcsFile->addFixableError($error, $longPtr, 'MethodAnnotation');
174+
$phpcsFile->addError($error, $longPtr, 'MethodAnnotation');
175175
}
176176
if ($longPtr !== false && $tokens[$longPtr]['code'] === T_DOC_COMMENT_STRING) {
177177
if ($tokens[$longPtr]['line'] !== $tokens[$shortPtrEnd]['line'] + 2) {
178178
$error = 'There must be exactly one blank line between descriptions';
179-
$phpcsFile->addFixableError($error, $longPtr, 'MethodAnnotation');
179+
$phpcsFile->addError($error, $longPtr, 'MethodAnnotation');
180180
}
181181
if (preg_match('/^\p{Ll}/u', $tokens[$longPtr]['content']) === 1) {
182182
$error = 'Long description must start with a capital letter';
183-
$phpcsFile->addFixableError($error, $longPtr, 'MethodAnnotation');
183+
$phpcsFile->addError($error, $longPtr, 'MethodAnnotation');
184184
}
185185
}
186186
}
@@ -203,7 +203,7 @@ public function validateTagsSpacingFormat(File $phpcsFile, int $commentStartPtr,
203203
&& strtolower($commentTagPtrContent) !== '@inheritdoc'
204204
) {
205205
$error = 'There must be exactly one blank line before tags';
206-
$phpcsFile->addFixableError($error, $firstTagPtr, 'MethodAnnotation');
206+
$phpcsFile->addError($error, $firstTagPtr, 'MethodAnnotation');
207207
}
208208
}
209209
}
@@ -240,7 +240,7 @@ public function validateTagGroupingFormat(File $phpcsFile, int $commentStartPtr)
240240
if ($paramGroupId !== null
241241
&& $paramGroupId !== $groupId) {
242242
$error = 'Parameter tags must be grouped together';
243-
$phpcsFile->addFixableError($error, $tag, 'MethodAnnotation');
243+
$phpcsFile->addError($error, $tag, 'MethodAnnotation');
244244
}
245245
if ($paramGroupId === null) {
246246
$paramGroupId = $groupId;
@@ -273,7 +273,7 @@ public function validateTagAligningFormat(File $phpcsFile, int $commentStartPtr)
273273

274274
if (!$this->allTagsAligned($actualPositions)
275275
&& !$this->noneTagsAligned($actualPositions, $noAlignmentPositions)) {
276-
$phpcsFile->addFixableError(
276+
$phpcsFile->addError(
277277
'Tags visual alignment must be consistent',
278278
$stackPtr,
279279
'MethodArguments'
@@ -322,7 +322,7 @@ private function validateNoExtraNewLineBeforeShortDescription(
322322
$prevPtr = $phpcsFile->findPrevious($emptyTypeTokens, $commentEndPtr - 1, $commentStartPtr, true);
323323
if ($tokens[$prevPtr]['line'] < ($tokens[$commentEndPtr]['line'] - 1)) {
324324
$error = 'Additional blank lines found at end of the annotation block';
325-
$phpcsFile->addFixableError($error, $commentEndPtr, 'MethodAnnotation');
325+
$phpcsFile->addError($error, $commentEndPtr, 'MethodAnnotation');
326326
}
327327
}
328328

@@ -351,7 +351,7 @@ public function validateDescriptionFormatStructure(
351351
&& strtolower($commentTagPtrContent) !== '@inheritdoc'
352352
) {
353353
$error = 'Missing short description';
354-
$phpcsFile->addFixableError($error, $commentStartPtr, 'MethodAnnotation');
354+
$phpcsFile->addError($error, $commentStartPtr, 'MethodAnnotation');
355355
} else {
356356
$this->validateShortDescriptionFormat(
357357
$phpcsFile,

‎Magento2/Sniffs/Annotation/MethodArgumentsSniff.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Annotation/MethodArgumentsSniff.php
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,15 @@ private function validateParameterAnnotationForArgumentExists(
225225
$previousCommentClosePtr
226226
);
227227
if ($inheritdocAnnotationWithBracesExists) {
228-
$phpcsFile->addFixableError(
228+
$phpcsFile->addError(
229229
'{@inheritdoc} does not import parameter annotation',
230230
$stackPtr,
231231
'MethodArguments'
232232
);
233233
} elseif ($this->validateCommentBlockExists($phpcsFile, $previousCommentClosePtr, $stackPtr)
234234
&& !$inheritdocAnnotationWithoutBracesExists
235235
) {
236-
$phpcsFile->addFixableError(
236+
$phpcsFile->addError(
237237
'Missing @param for argument in method annotation',
238238
$stackPtr,
239239
'MethodArguments'
@@ -257,13 +257,13 @@ private function validateCommentBlockDoesnotHaveExtraParameterAnnotation(
257257
int $stackPtr
258258
): void {
259259
if ($argumentsCount < $parametersCount && $argumentsCount > 0) {
260-
$phpcsFile->addFixableError(
260+
$phpcsFile->addError(
261261
'Extra @param found in method annotation',
262262
$stackPtr,
263263
'MethodArguments'
264264
);
265265
} elseif ($argumentsCount > 0 && $argumentsCount != $parametersCount && $parametersCount != 0) {
266-
$phpcsFile->addFixableError(
266+
$phpcsFile->addError(
267267
'@param is not found for one or more params in method annotation',
268268
$stackPtr,
269269
'MethodArguments'
@@ -290,7 +290,7 @@ private function validateArgumentNameInParameterAnnotationExists(
290290
$parameterNames = $this->getMethodParameters($paramDefinitions);
291291
if (!in_array($methodArguments[$ptr], $parameterNames)) {
292292
$error = $methodArguments[$ptr] . ' parameter is missing in method annotation';
293-
$phpcsFile->addFixableError($error, $stackPtr, 'MethodArguments');
293+
$phpcsFile->addError($error, $stackPtr, 'MethodArguments');
294294
}
295295
}
296296

@@ -311,7 +311,7 @@ private function validateParameterPresentInMethodSignature(
311311
array $paramPointers
312312
): void {
313313
if (!in_array($paramDefinitionsArguments, $methodArguments)) {
314-
$phpcsFile->addFixableError(
314+
$phpcsFile->addError(
315315
$paramDefinitionsArguments . ' parameter is missing in method arguments signature',
316316
$paramPointers[$ptr],
317317
'MethodArguments'
@@ -340,7 +340,7 @@ private function validateParameterOrderIsCorrect(
340340
&& in_array($methodArguments[$ptr], $parameterNames)
341341
) {
342342
if ($methodArguments[$ptr] != $parameterNames[$ptr]) {
343-
$phpcsFile->addFixableError(
343+
$phpcsFile->addError(
344344
$methodArguments[$ptr] . ' parameter is not in order',
345345
$paramPointers[$ptr],
346346
'MethodArguments'
@@ -383,7 +383,7 @@ private function validateDuplicateAnnotationDoesnotExists(
383383
}
384384
}
385385
foreach ($duplicateParameters as $value) {
386-
$phpcsFile->addFixableError(
386+
$phpcsFile->addError(
387387
$value . ' duplicate found in method annotation',
388388
$stackPtr,
389389
'MethodArguments'
@@ -410,7 +410,7 @@ private function validateParameterAnnotationFormatIsCorrect(
410410
): void {
411411
switch (count($paramDefinitions)) {
412412
case 0:
413-
$phpcsFile->addFixableError(
413+
$phpcsFile->addError(
414414
'Missing both type and parameter',
415415
$paramPointers[$ptr],
416416
'MethodArguments'
@@ -427,7 +427,7 @@ private function validateParameterAnnotationFormatIsCorrect(
427427
break;
428428
case 2:
429429
if ($this->isInvalidType($paramDefinitions[0])) {
430-
$phpcsFile->addFixableError(
430+
$phpcsFile->addError(
431431
$paramDefinitions[0] . ' is not a valid PHP type',
432432
$paramPointers[$ptr],
433433
'MethodArguments'
@@ -449,7 +449,7 @@ private function validateParameterAnnotationFormatIsCorrect(
449449
'MethodArguments'
450450
);
451451
if ($this->isInvalidType($paramDefinitions[0])) {
452-
$phpcsFile->addFixableError(
452+
$phpcsFile->addError(
453453
$paramDefinitions[0] . ' is not a valid PHP type',
454454
$paramPointers[$ptr],
455455
'MethodArguments'
@@ -633,7 +633,7 @@ private function validateFormattingConsistency(
633633
}
634634
if (!$this->allParamsAligned($argumentPositions, $commentPositions)
635635
&& !$this->noneParamsAligned($argumentPositions, $commentPositions, $paramDefinitions)) {
636-
$phpcsFile->addFixableError(
636+
$phpcsFile->addError(
637637
'Method arguments visual alignment must be consistent',
638638
$paramPointers[0],
639639
'MethodArguments'

‎Magento2/Sniffs/Html/HtmlDirectiveSniff.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Html/HtmlDirectiveSniff.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private function validateVariableUsage(File $phpcsFile, string $body): void
200200
'Template directives may not invoke methods. Only scalar array access is allowed.' . PHP_EOL
201201
. 'Found "' . trim($body) . '"',
202202
null,
203-
'HtmlTemplates.DirectiveUsage.ProhibitedMethodCall'
203+
'HtmlTemplatesProhibitedMethodCall'
204204
);
205205
}
206206
}
@@ -224,7 +224,7 @@ private function validateDefinedVariables(File $phpcsFile, string $templateText)
224224
$phpcsFile->addError(
225225
'Template @vars comment block contains invalid JSON.',
226226
null,
227-
'HtmlTemplates.DirectiveUsage.InvalidVarsJSON'
227+
'HtmlTemplatesInvalidVarsJSON'
228228
);
229229
return;
230230
}
@@ -235,7 +235,7 @@ private function validateDefinedVariables(File $phpcsFile, string $templateText)
235235
'Template @vars comment block contains invalid label.' . PHP_EOL
236236
. 'Label for variable "' . $var . '" is empty.',
237237
null,
238-
'HtmlTemplates.DirectiveUsage.InvalidVariableLabel'
238+
'HtmlTemplatesInvalidVariableLabel'
239239
);
240240
}
241241
}
@@ -254,7 +254,7 @@ private function validateDefinedVariables(File $phpcsFile, string $templateText)
254254
'Template @vars comment block is missing a variable used in the template.' . PHP_EOL
255255
. 'Missing variable: ' . $undefinedVariable,
256256
null,
257-
'HtmlTemplates.DirectiveUsage.UndefinedVariable'
257+
'HtmlTemplatesUndefinedVariable'
258258
);
259259
}
260260
}

‎Magento2/Sniffs/Less/AvoidIdSniff.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Less/AvoidIdSniff.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class AvoidIdSniff implements Sniff
5151
T_PLUS,
5252
T_NS_SEPARATOR,
5353
T_LNUMBER,
54+
T_BITWISE_NOT
5455
];
5556

5657
/**

‎Magento2/Sniffs/Namespaces/ImportsFromTestNamespaceSniff.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Namespaces/ImportsFromTestNamespaceSniff.php
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ public function process(File $phpcsFile, $stackPtr)
5757
$closingCurly = $phpcsFile->findNext(T_CLOSE_USE_GROUP, ($next + 1));
5858
do {
5959
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
60-
$groupedAsContent = $baseUse. $tokens[$next]['content'];
61-
$next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
62-
if (strpos($groupedAsContent, $this->prohibitNamespace) !== false) {
63-
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
64-
return;
60+
if ($next !== false) {
61+
$groupedAsContent = $baseUse. $tokens[$next]['content'];
62+
$next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
63+
if (strpos($groupedAsContent, $this->prohibitNamespace) !== false) {
64+
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
65+
return;
66+
}
6567
}
6668
} while ($next !== false);
6769
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.