Skip to content

Commit bedbf6e

Browse files
committed
Adhere to coding standard
1 parent d1711ba commit bedbf6e

19 files changed

+108
-33
lines changed

Magento2/Sniffs/Commenting/ClassAndInterfacePHPDocFormattingSniff.php

+2
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\Sniffs\Commenting;
89

910
use Magento2\Helpers\Commenting\PHPDocFormattingValidator;
@@ -107,6 +108,7 @@ public function process(File $phpcsFile, $stackPtr)
107108
* @param File $phpcsFile
108109
* @param int $commentStartPtr
109110
* @param array $tokens
111+
*
110112
* @return bool
111113
*/
112114
private function validateTags(File $phpcsFile, $commentStartPtr, $tokens)

Magento2/Sniffs/Functions/FunctionsDeprecatedWithoutArgumentSniff.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
declare(strict_types=1);
79

810
namespace Magento2\Sniffs\Functions;
@@ -77,7 +79,7 @@ public function process(File $phpcsFile, $stackPtr): void
7779
);
7880
return;
7981
}
80-
82+
8183
$fix = $phpcsFile->addFixableWarning(
8284
sprintf(self::WARNING_MESSAGE, $functionName),
8385
$stackPtr,

Magento2/Sniffs/Html/HtmlClosingVoidTagsSniff.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
declare(strict_types=1);
79

810
namespace Magento2\Sniffs\Html;
@@ -75,6 +77,7 @@ public function process(File $phpcsFile, $stackPtr): void
7577
if ($stackPtr !== 0) {
7678
return;
7779
}
80+
7881
$html = $phpcsFile->getTokensAsString($stackPtr, count($phpcsFile->getTokens()));
7982

8083
if (empty($html)) {

Magento2/Sniffs/Legacy/ClassReferencesInConfigurationFilesSniff.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
6-
declare(strict_types = 1);
7+
8+
declare(strict_types=1);
79

810
namespace Magento2\Sniffs\Legacy;
911

@@ -72,6 +74,7 @@ private function assertNonFactoryName(File $phpcsFile, array $elements)
7274
if (stripos($element['value'], 'Magento') === false) {
7375
continue;
7476
}
77+
7578
if (preg_match('/^([A-Z][a-z\d\\\\]+)+$/', $element['value']) !== 1) {
7679
$phpcsFile->addError(
7780
self::ERROR_MESSAGE_CONFIG,
@@ -105,6 +108,7 @@ private function assertNonFactoryNameModule(File $phpcsFile, array $classes)
105108
* Format the incoming XML to avoid tags split into several lines.
106109
*
107110
* @param File $phpcsFile
111+
*
108112
* @return false|string
109113
*/
110114
private function getFormattedXML(File $phpcsFile)
@@ -119,6 +123,7 @@ private function getFormattedXML(File $phpcsFile)
119123
* Parse an XML for references to PHP class names in selected tags or attributes
120124
*
121125
* @param SimpleXMLElement $xml
126+
*
122127
* @return array
123128
*/
124129
private function collectClassesInConfig(SimpleXMLElement $xml): array
@@ -166,6 +171,7 @@ function (array $extendedNode) {
166171
*
167172
* @param SimpleXMLElement $xml
168173
* @param string $xPath
174+
*
169175
* @return array
170176
*/
171177
private function getValuesFromXmlTagContent(SimpleXMLElement $xml, string $xPath): array
@@ -174,7 +180,7 @@ private function getValuesFromXmlTagContent(SimpleXMLElement $xml, string $xPath
174180
return array_map(function ($item) {
175181
return [
176182
'value' => (string)$item,
177-
'lineNumber' => dom_import_simplexml($item)->getLineNo()-1,
183+
'lineNumber' => dom_import_simplexml($item)->getLineNo() - 1,
178184
];
179185
}, $nodes);
180186
}
@@ -184,6 +190,7 @@ private function getValuesFromXmlTagContent(SimpleXMLElement $xml, string $xPath
184190
*
185191
* @param SimpleXMLElement $xml
186192
* @param string $xPath
193+
*
187194
* @return array
188195
*/
189196
private function getValuesFromXmlTagName(SimpleXMLElement $xml, string $xPath): array
@@ -192,7 +199,7 @@ private function getValuesFromXmlTagName(SimpleXMLElement $xml, string $xPath):
192199
return array_map(function ($item) {
193200
return [
194201
'value' => $item->getName(),
195-
'lineNumber' => dom_import_simplexml($item)->getLineNo()-1,
202+
'lineNumber' => dom_import_simplexml($item)->getLineNo() - 1,
196203
];
197204
}, $nodes);
198205
}
@@ -203,6 +210,7 @@ private function getValuesFromXmlTagName(SimpleXMLElement $xml, string $xPath):
203210
* @param SimpleXMLElement $xml
204211
* @param string $xPath
205212
* @param string $attr
213+
*
206214
* @return array
207215
*/
208216
private function getValuesFromXmlTagAttribute(SimpleXMLElement $xml, string $xPath, string $attr): array
@@ -213,7 +221,7 @@ private function getValuesFromXmlTagAttribute(SimpleXMLElement $xml, string $xPa
213221
if (isset($nodeArray['@attributes'][$attr])) {
214222
return [
215223
'value' => $nodeArray['@attributes'][$attr],
216-
'lineNumber' => dom_import_simplexml($item)->getLineNo()-1,
224+
'lineNumber' => dom_import_simplexml($item)->getLineNo() - 1,
217225
];
218226
}
219227
}, $nodes);

Magento2/Sniffs/Legacy/InstallUpgradeSniff.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
6-
declare(strict_types = 1);
7+
8+
declare(strict_types=1);
79

810
namespace Magento2\Sniffs\Legacy;
911

@@ -85,7 +87,7 @@ public function process(File $phpcsFile, $stackPtr)
8587
if ($stackPtr > 0) {
8688
return;
8789
}
88-
90+
8991
$fileInfo = new SplFileInfo($phpcsFile->getFilename());
9092

9193
foreach (self::WRONG_PREFIXES as $code => $data) {

Magento2/Sniffs/Legacy/LayoutSniff.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
6-
declare(strict_types = 1);
7+
8+
declare(strict_types=1);
79

810
namespace Magento2\Sniffs\Legacy;
911

@@ -248,11 +250,12 @@ private function testObsoleteReferences(SimpleXMLElement $layout, File $phpcsFil
248250
if (!isset($this->obsoleteReferences[$handleAttribute])) {
249251
continue;
250252
}
253+
251254
foreach ($handle->xpath('//reference | //referenceContainer | //referenceBlock') as $reference) {
252255
if (in_array((string)$reference['name'], $this->obsoleteReferences[$handleAttribute]) !== false) {
253256
$phpcsFile->addError(
254257
'The block being referenced is removed.',
255-
dom_import_simplexml($reference)->getLineNo()-1,
258+
dom_import_simplexml($reference)->getLineNo() - 1,
256259
self::ERROR_CODE_OBSOLETE_BLOCK
257260
);
258261
}
@@ -264,6 +267,7 @@ private function testObsoleteReferences(SimpleXMLElement $layout, File $phpcsFil
264267
* Format the incoming XML to avoid tags split into several lines.
265268
*
266269
* @param File $phpcsFile
270+
*
267271
* @return false|string
268272
*/
269273
private function getFormattedXML(File $phpcsFile)
@@ -286,7 +290,7 @@ private function testOutputAttribute(SimpleXMLElement $layout, File $phpcsFile):
286290
if (!empty($elements)) {
287291
$phpcsFile->addError(
288292
'output="toHtml" is obsolete. Use output="1"',
289-
dom_import_simplexml($elements[0])->getLineNo()-1,
293+
dom_import_simplexml($elements[0])->getLineNo() - 1,
290294
self::ERROR_CODE_OBSOLETE_TOHTML_ATTRIBUTE
291295
);
292296
};
@@ -297,6 +301,7 @@ private function testOutputAttribute(SimpleXMLElement $layout, File $phpcsFile):
297301
*
298302
* @param SimpleXMLElement $element
299303
* @param string $name
304+
*
300305
* @return string|null
301306
*/
302307
private function getAttribute(SimpleXMLElement $element, string $name): string
@@ -317,14 +322,15 @@ private function testHelperAttribute(SimpleXMLElement $layout, File $phpcsFile):
317322
if (strpos($this->getAttribute($action, 'helper'), '/') !== false) {
318323
$phpcsFile->addError(
319324
"'helper' attribute contains '/'",
320-
dom_import_simplexml($action)->getLineNo()-1,
325+
dom_import_simplexml($action)->getLineNo() - 1,
321326
self::ERROR_CODE_HELPER_ATTRIBUTE_CHARACTER_NOT_ALLOWED
322327
);
323328
}
329+
324330
if (strpos($this->getAttribute($action, 'helper'), '::') === false) {
325331
$phpcsFile->addError(
326332
"'helper' attribute does not contain '::'",
327-
dom_import_simplexml($action)->getLineNo()-1,
333+
dom_import_simplexml($action)->getLineNo() - 1,
328334
self::ERROR_CODE_HELPER_ATTRIBUTE_CHARACTER_EXPECTED
329335
);
330336
}
@@ -344,7 +350,7 @@ private function testListText(SimpleXMLElement $layout, File $phpcsFile): void
344350
$phpcsFile->addError(
345351
'The class \Magento\Framework\View\Element\Text\ListText' .
346352
' is not supposed to be used in layout anymore.',
347-
dom_import_simplexml($elements[0])->getLineNo()-1,
353+
dom_import_simplexml($elements[0])->getLineNo() - 1,
348354
self::ERROR_CODE_OBSOLETE_CLASS
349355
);
350356
}
@@ -366,7 +372,7 @@ private function testActionNodeMethods(SimpleXMLElement $layout, File $phpcsFile
366372
'Call of method "%s" via layout instruction <action> is not allowed.',
367373
$attributes['method']
368374
),
369-
dom_import_simplexml($node)->getLineNo()-1,
375+
dom_import_simplexml($node)->getLineNo() - 1,
370376
self::ERROR_CODE_METHOD_NOT_ALLOWED
371377
);
372378
}

Magento2/Sniffs/Legacy/ModuleXMLSniff.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -59,7 +60,7 @@ public function process(File $phpcsFile, $stackPtr)
5960
foreach ($foundElements as $element) {
6061
$phpcsFile->addWarning(
6162
'The "version" attribute is obsolete. Use "setup_version" instead.',
62-
dom_import_simplexml($element)->getLineNo()-1,
63+
dom_import_simplexml($element)->getLineNo() - 1,
6364
self::WARNING_CODE
6465
);
6566
}
@@ -69,9 +70,9 @@ public function process(File $phpcsFile, $stackPtr)
6970
if ($foundElements !== false) {
7071
foreach ($foundElements as $element) {
7172
$phpcsFile->addWarning(
72-
'The "active" attribute is obsolete. The list of active modules '.
73+
'The "active" attribute is obsolete. The list of active modules ' .
7374
'is defined in deployment configuration.',
74-
dom_import_simplexml($element)->getLineNo()-1,
75+
dom_import_simplexml($element)->getLineNo() - 1,
7576
self::WARNING_CODE
7677
);
7778
}
@@ -82,6 +83,7 @@ public function process(File $phpcsFile, $stackPtr)
8283
* Format the incoming XML to avoid tags split into several lines.
8384
*
8485
* @param File $phpcsFile
86+
*
8587
* @return false|string
8688
*/
8789
private function getFormattedXML(File $phpcsFile)

Magento2/Sniffs/Legacy/ObsoleteAclSniff.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
namespace Magento2\Sniffs\Legacy;
79

810
use DOMDocument;
@@ -50,6 +52,7 @@ public function process(File $phpcsFile, $stackPtr)
5052
* Format the incoming XML to avoid tags split into several lines.
5153
*
5254
* @param File $phpcsFile
55+
*
5356
* @return false|string
5457
*/
5558
private function getFormattedXML(File $phpcsFile)

Magento2/Sniffs/Legacy/ObsoleteConfigNodesSniff.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
namespace Magento2\Sniffs\Legacy;
99

1010
use DOMDocument;
11-
use PHP_CodeSniffer\Sniffs\Sniff;
1211
use PHP_CodeSniffer\Files\File;
12+
use PHP_CodeSniffer\Sniffs\Sniff;
1313

1414
class ObsoleteConfigNodesSniff implements Sniff
1515
{
@@ -55,14 +55,15 @@ public function process(File $phpcsFile, $stackPtr)
5555
if (empty($matches)) {
5656
continue;
5757
}
58+
5859
foreach ($matches as $match) {
5960
$phpcsFile->addError(
6061
sprintf(
6162
self::ERROR_MESSAGE_CONFIG,
6263
$xpath,
6364
$suggestion
6465
),
65-
dom_import_simplexml($match)->getLineNo()-1,
66+
dom_import_simplexml($match)->getLineNo() - 1,
6667
self::ERROR_CODE_CONFIG
6768
);
6869
}
@@ -73,6 +74,7 @@ public function process(File $phpcsFile, $stackPtr)
7374
* Format the incoming XML to avoid tags split into several lines.
7475
*
7576
* @param File $phpcsFile
77+
*
7678
* @return false|string
7779
*/
7880
private function getFormattedXML(File $phpcsFile)
@@ -147,7 +149,7 @@ private function getObsoleteNodes(): array
147149
'/config/global/dev' =>
148150
'This configuration moved to Di configuration of \Magento\Framework\App\Action\Context',
149151
'/config/global/webapi' =>
150-
'This configuration moved to Di configuration of '.
152+
'This configuration moved to Di configuration of ' .
151153
' \Magento\Webapi\Controller\Request\Rest\Interpreter\Factory' .
152154
' and \Magento\Webapi\Controller\Response\Rest\Renderer\Factory',
153155
'/config/global/cms' =>
@@ -156,10 +158,10 @@ private function getObsoleteNodes(): array
156158
'/config/global/widget' =>
157159
'This configuration moved to Di configuration of \Magento\Cms\Model\Template\FilterProvider',
158160
'/config/global/catalog/product/flat/max_index_count' =>
159-
'This configuration moved to Di configuration of '.
161+
'This configuration moved to Di configuration of ' .
160162
'\Magento\Catalog\Model\ResourceModel\Product\Flat\Indexer',
161163
'/config/global/catalog/product/flat/attribute_groups' =>
162-
'This configuration moved to Di configuration of '.
164+
'This configuration moved to Di configuration of ' .
163165
'\Magento\Catalog\Model\ResourceModel\Product\Flat\Indexer',
164166
'/config/global/catalog/product/flat/add_filterable_attributes' =>
165167
'This configuration moved to Di configuration of \Magento\Catalog\Helper\Product\Flat\Indexer',

Magento2/Sniffs/Legacy/ObsoleteConnectionSniff.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
6-
declare(strict_types = 1);
7+
8+
declare(strict_types=1);
79

810
namespace Magento2\Sniffs\Legacy;
911

@@ -57,7 +59,7 @@ private function validateObsoleteMethod(File $phpcsFile, int $stackPtr)
5759
{
5860
$tokens = $phpcsFile->getTokens();
5961
$stringPos = $phpcsFile->findNext(T_STRING, $stackPtr + 1);
60-
62+
6163
foreach ($this->obsoleteMethods as $method) {
6264
if ($tokens[$stringPos]['content'] === $method) {
6365
$phpcsFile->addWarning(

0 commit comments

Comments
 (0)