Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6b3b7a5

Browse files
committedSep 26, 2023
Merge remote-tracking branch 'upstream/develop' into deprecated-version-range
2 parents a957d87 + d1711ba commit 6b3b7a5

15 files changed

+784
-20
lines changed
 

Diff for: ‎Magento2/Sniffs/Commenting/ClassAndInterfacePHPDocFormattingSniff.php

+40-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,29 @@ public function process(File $phpcsFile, $stackPtr)
6363
return;
6464
}
6565

66+
$commentCloserPtr = $tokens[$commentStartPtr]['comment_closer'];
67+
6668
if ($this->PHPDocFormattingValidator->providesMeaning($namePtr, $commentStartPtr, $tokens) !== true) {
67-
$phpcsFile->addWarning(
69+
$fix = $phpcsFile->addFixableWarning(
6870
sprintf(
6971
'%s description must contain meaningful information beyond what its name provides or be removed.',
7072
ucfirst($tokens[$stackPtr]['content'])
7173
),
7274
$stackPtr,
7375
'InvalidDescription'
7476
);
77+
78+
if ($fix) {
79+
for ($i = $commentStartPtr; $i <= $commentCloserPtr; $i++) {
80+
$phpcsFile->fixer->replaceToken($i, '');
81+
}
82+
83+
if ($tokens[$commentStartPtr - 1]['code'] === T_WHITESPACE
84+
&& $tokens[$commentCloserPtr + 1]['code'] === T_WHITESPACE
85+
) {
86+
$phpcsFile->fixer->replaceToken($commentCloserPtr + 1, '');
87+
}
88+
}
7589
}
7690

7791
if ($this->PHPDocFormattingValidator->hasDeprecatedWellFormatted($commentStartPtr, $tokens) !== true) {
@@ -105,11 +119,35 @@ private function validateTags(File $phpcsFile, $commentStartPtr, $tokens)
105119
}
106120

107121
if (in_array($tokens[$i]['content'], $this->forbiddenTags) === true) {
108-
$phpcsFile->addWarning(
122+
$fix = $phpcsFile->addFixableWarning(
109123
sprintf('Tag %s MUST NOT be used.', $tokens[$i]['content']),
110124
$i,
111125
'ForbiddenTags'
112126
);
127+
128+
if ($fix) {
129+
for ($j = $i - 1; $j > $commentStartPtr; $j--) {
130+
if (!in_array($tokens[$j]['code'], [T_DOC_COMMENT_STAR, T_DOC_COMMENT_WHITESPACE], true)) {
131+
break;
132+
}
133+
134+
if ($tokens[$j]['code'] === T_DOC_COMMENT_WHITESPACE && $tokens[$j]['content'] === "\n") {
135+
break;
136+
}
137+
138+
$phpcsFile->fixer->replaceToken($j, '');
139+
}
140+
141+
$phpcsFile->fixer->replaceToken($i, '');
142+
143+
for ($j = $i + 1; $j < $commentCloserPtr; $j++) {
144+
$phpcsFile->fixer->replaceToken($j, '');
145+
146+
if ($tokens[$j]['code'] === T_DOC_COMMENT_WHITESPACE && $tokens[$j]['content'] === "\n") {
147+
break;
148+
}
149+
}
150+
}
113151
}
114152
}
115153

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Magento2\Sniffs\Legacy;
11+
12+
use PHP_CodeSniffer\Files\File;
13+
use PHP_CodeSniffer\Sniffs\Sniff;
14+
use PHP_CodeSniffer\Util\Tokens;
15+
16+
class EscapeMethodsOnBlockClassSniff implements Sniff
17+
{
18+
private const ESCAPER_METHODS = [
19+
'escapeCss' => true,
20+
'escapeHtml' => true,
21+
'escapeHtmlAttr' => true,
22+
'escapeJs' => true,
23+
'escapeJsQuote' => true,
24+
'escapeQuote' => true,
25+
'escapeUrl' => true,
26+
'escapeXssInUrl' => true,
27+
];
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
public function register()
33+
{
34+
return [
35+
T_OBJECT_OPERATOR,
36+
];
37+
}
38+
39+
/**
40+
* @inheritDoc
41+
*/
42+
public function process(File $phpcsFile, $stackPtr)
43+
{
44+
$tokens = $phpcsFile->getTokens();
45+
46+
if ($stackPtr <= 1 || !isset($tokens[$stackPtr + 2])) {
47+
return;
48+
}
49+
50+
$objectPtr = $stackPtr - 1;
51+
if ($tokens[$objectPtr]['code'] !== T_VARIABLE) {
52+
$objectPtr = $phpcsFile->findPrevious(Tokens::$emptyTokens, $objectPtr, null, true);
53+
54+
if (!$objectPtr) {
55+
return;
56+
}
57+
}
58+
59+
if ($tokens[$objectPtr]['code'] !== T_VARIABLE
60+
|| $tokens[$objectPtr]['content'] !== '$block'
61+
) {
62+
return;
63+
}
64+
65+
$methodPtr = $stackPtr + 1;
66+
if ($tokens[$methodPtr]['code'] !== T_STRING) {
67+
$methodPtr = $phpcsFile->findNext(Tokens::$emptyTokens, $methodPtr, null, true);
68+
69+
if (!$methodPtr) {
70+
return;
71+
}
72+
}
73+
74+
if ($tokens[$methodPtr]['code'] !== T_STRING
75+
|| !isset(self::ESCAPER_METHODS[$tokens[$methodPtr]['content']])
76+
) {
77+
return;
78+
}
79+
80+
$openParenPtr = $methodPtr + 1;
81+
if ($tokens[$openParenPtr]['code'] !== T_OPEN_PARENTHESIS) {
82+
$openParenPtr = $phpcsFile->findNext(Tokens::$emptyTokens, $openParenPtr, null, true);
83+
84+
if (!$openParenPtr) {
85+
return;
86+
}
87+
}
88+
89+
if ($tokens[$openParenPtr]['code'] !== T_OPEN_PARENTHESIS) {
90+
return;
91+
}
92+
93+
$fix = $phpcsFile->addFixableWarning(
94+
'Using %s on $block is deprecated. Please use equivalent method on $escaper',
95+
$methodPtr,
96+
'Found',
97+
[
98+
$tokens[$methodPtr]['content'], // method name
99+
]
100+
);
101+
102+
if ($fix) {
103+
$phpcsFile->fixer->replaceToken($objectPtr, '$escaper');
104+
}
105+
}
106+
}

Diff for: ‎Magento2/Sniffs/Security/XssTemplateSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ public function process(File $phpcsFile, $stackPtr)
147147
private function findSpecialAnnotation($stackPtr)
148148
{
149149
if ($this->tokens[$stackPtr]['code'] === T_ECHO) {
150-
$startOfStatement = $this->file->findPrevious(T_OPEN_TAG, $stackPtr);
150+
$startOfStatement = $this->file->findPrevious([T_OPEN_TAG, T_SEMICOLON], $stackPtr);
151151
return $this->file->findPrevious(T_COMMENT, $stackPtr, $startOfStatement);
152152
}
153153
if ($this->tokens[$stackPtr]['code'] === T_OPEN_TAG_WITH_ECHO) {
154-
$endOfStatement = $this->file->findNext(T_CLOSE_TAG, $stackPtr);
154+
$endOfStatement = $this->file->findNext([T_CLOSE_TAG, T_SEMICOLON], $stackPtr);
155155
return $this->file->findNext(T_COMMENT, $stackPtr, $endOfStatement);
156156
}
157157
return false;

Diff for: ‎Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.1.inc

+8
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,11 @@ class AlsoDeprecatedButHandlerLongVersion
194194
{
195195

196196
}
197+
198+
/**
199+
* @package this tag should not be used
200+
*/
201+
class OnlyUselessCommentContent
202+
{
203+
204+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<?php
2+
3+
/**
4+
* Handler for PHP errors/warnings/notices that converts them to exceptions.
5+
*/
6+
class ErrorHandler
7+
{
8+
9+
}
10+
11+
class NotAnErrorHandler
12+
{
13+
14+
}
15+
16+
class FaultyHandler
17+
{
18+
19+
}
20+
21+
class SomeHandler
22+
{
23+
24+
}
25+
26+
class YetAnotherHandler
27+
{
28+
29+
}
30+
31+
class GreenHandler
32+
{
33+
34+
}
35+
36+
class EmptyHandler
37+
{
38+
39+
}
40+
41+
/**
42+
* Handler for PHP errors/warnings/notices that converts them to exceptions.
43+
*
44+
* @api is ok here
45+
* @deprecated can be used in this context
46+
* @see is ok here
47+
*/
48+
class ExampleHandler
49+
{
50+
51+
}
52+
53+
/**
54+
* @api
55+
* @since 100.0.2
56+
*/
57+
class ApiHandler
58+
{
59+
60+
}
61+
62+
/**
63+
* @api
64+
*/
65+
class AsyncApiHandler
66+
{
67+
68+
}
69+
70+
/**
71+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
72+
*/
73+
class GroupRepositoryHandler
74+
{
75+
76+
}
77+
78+
/**
79+
* @deprecated
80+
*/
81+
class DeprecatedHandler
82+
{
83+
84+
}
85+
86+
/**
87+
* @deprecated Should not be used
88+
*/
89+
class AncientHandler
90+
{
91+
92+
}
93+
94+
/**
95+
* @deprecated
96+
* @see
97+
*/
98+
class AgedHandler
99+
{
100+
101+
}
102+
103+
/**
104+
* @deprecated Should not be used
105+
* @see
106+
*/
107+
class ArhaicHandler
108+
{
109+
110+
}
111+
112+
/**
113+
* @deprecated Should not be used
114+
* @see Magento\Framework\NewHandler
115+
*/
116+
class OldHandler
117+
{
118+
119+
}
120+
121+
/**
122+
* @see Magento\Framework\NewHandler
123+
*/
124+
class SomethingHandler
125+
{
126+
127+
}
128+
129+
/**
130+
* @see
131+
*/
132+
class DoNotCareHandler
133+
{
134+
135+
}
136+
137+
/**
138+
* @deprecated
139+
* @see Magento\Framework\NewHandler
140+
*/
141+
class OldHandler
142+
{
143+
144+
}
145+
146+
/**
147+
* @deprecated This class will be removed in version 1.0.0 without replacement
148+
*/
149+
class DeprecatedButHandler
150+
{
151+
152+
}
153+
154+
/**
155+
* @deprecated This class will be removed in version 123.45.6789 without replacement
156+
*/
157+
class DeprecatedButHandlerLongVersion
158+
{
159+
160+
}
161+
162+
/**
163+
* @deprecated It's also deprecated - This class will be removed in version 1.0.0 without replacement
164+
*/
165+
class AlsoDeprecatedButHandler
166+
{
167+
168+
}
169+
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+
178+
class OnlyUselessCommentContent
179+
{
180+
181+
}

Diff for: ‎Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.2.inc

+17
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ interface DoNotCareHandler
154154

155155
}
156156

157+
/**
158+
* @deprecated
159+
* @see Magento\Framework\NewHandler
160+
*/
161+
interface OldHandler
162+
{
163+
164+
}
165+
157166
/**
158167
* @deprecated This interface will be removed in version 1.0.0 without replacement
159168
*/
@@ -185,3 +194,11 @@ interface AlsoDeprecatedButHandlerLongVersion
185194
{
186195

187196
}
197+
198+
/**
199+
* @package this tag should not be used
200+
*/
201+
interface OnlyUselessCommentContent
202+
{
203+
204+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<?php
2+
3+
/**
4+
* Handler for PHP errors/warnings/notices that converts them to exceptions.
5+
*/
6+
interface ErrorHandler
7+
{
8+
9+
}
10+
11+
interface NotAnErrorHandler
12+
{
13+
14+
}
15+
16+
interface FaultyHandler
17+
{
18+
19+
}
20+
21+
interface SomeHandler
22+
{
23+
24+
}
25+
26+
interface YetAnotherHandler
27+
{
28+
29+
}
30+
31+
interface GreenHandler
32+
{
33+
34+
}
35+
36+
interface EmptyHandler
37+
{
38+
39+
}
40+
41+
/**
42+
* Handler for PHP errors/warnings/notices that converts them to exceptions.
43+
*
44+
* @api is ok here
45+
* @deprecated can be used in this context
46+
* @see is ok here
47+
*/
48+
interface ExampleHandler
49+
{
50+
51+
}
52+
53+
/**
54+
* @api
55+
* @since 100.0.2
56+
*/
57+
interface ApiHandler
58+
{
59+
60+
}
61+
62+
/**
63+
* @api
64+
*/
65+
interface AsyncApiHandler
66+
{
67+
68+
}
69+
70+
/**
71+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
72+
*/
73+
interface GroupRepositoryHandler
74+
{
75+
76+
}
77+
78+
/**
79+
* @deprecated
80+
*/
81+
interface DeprecatedHandler
82+
{
83+
84+
}
85+
86+
/**
87+
* @deprecated Should not be used
88+
*/
89+
interface AncientHandler
90+
{
91+
92+
}
93+
94+
/**
95+
* @deprecated
96+
* @see
97+
*/
98+
interface AgedHandler
99+
{
100+
101+
}
102+
103+
/**
104+
* @deprecated Should not be used
105+
* @see
106+
*/
107+
interface ArhaicHandler
108+
{
109+
110+
}
111+
112+
/**
113+
* @deprecated Should not be used
114+
* @see Magento\Framework\NewHandler
115+
*/
116+
interface OldHandler
117+
{
118+
119+
}
120+
121+
/**
122+
* @see Magento\Framework\NewHandler
123+
*/
124+
interface SomethingHandler
125+
{
126+
127+
}
128+
129+
/**
130+
* @see
131+
*/
132+
interface DoNotCareHandler
133+
{
134+
135+
}
136+
137+
/**
138+
* @deprecated
139+
* @see Magento\Framework\NewHandler
140+
*/
141+
interface OldHandler
142+
{
143+
144+
}
145+
146+
/**
147+
* @deprecated This interface will be removed in version 1.0.0 without replacement
148+
*/
149+
interface DeprecatedButHandler
150+
{
151+
152+
}
153+
154+
/**
155+
* @deprecated This interface will be removed in version 123.45.6789 without replacement
156+
*/
157+
interface DeprecatedButHandlerLongVersion
158+
{
159+
160+
}
161+
162+
/**
163+
* @deprecated Yeah! This interface will be removed in version 1.0.0 without replacement
164+
*/
165+
interface AlsoDeprecatedButHandler
166+
{
167+
168+
}
169+
170+
/**
171+
* @deprecated Yeah! This interface will be removed in version 123.45.6789 without replacement
172+
*/
173+
interface AlsoDeprecatedButHandlerLongVersion
174+
{
175+
176+
}
177+
178+
interface OnlyUselessCommentContent
179+
{
180+
181+
}

Diff for: ‎Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.php

+3-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;
@@ -36,7 +37,8 @@ public function getWarningList($testFile = '')
3637
101 => 1,
3738
109 => 1,
3839
118 => 1,
39-
127 => 1
40+
127 => 1,
41+
199 => 1,
4042
];
4143
}
4244
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/** @var Magento\Framework\View\Element\Template $block */
3+
/** @var Magento\Framework\Escaper $escaper */
4+
?>
5+
6+
<section>
7+
<h1>This unescaped output is fine here; other sniffs will complain about it though.</h1>
8+
9+
<?php echo $block->getSomeString(); ?>
10+
<?= $block->getSomeString(); ?>
11+
<?= /** @noEscape */ $block->getSomeString(); ?>
12+
<?= /** @escapeNotVerified */ $block->getSomeString(); ?>
13+
</section>
14+
15+
<section>
16+
<h1>These should be using equivalent methods on the `$escaper` class, not the `$block` class.</h1>
17+
18+
Note that I couldn't find any use of this method in any templates within Magento.
19+
<?= $block->escapeCss($block->getSomeString()); ?>
20+
21+
<?= $block->escapeHtml(__($block->getSomeString())) ?>
22+
<?= $block->escapeHtml(__($block->getSomeString())); ?>
23+
<?= $block->escapeHtml(__($block->getSomeString()), ['strong', 'em', 'span']) ?>
24+
25+
<div class="<?= $block->escapeHtmlAttr($block->getSomeString()) ?>"></div>
26+
<div class="<?= $block->escapeHtmlAttr($block->getSomeString(), true) ?>"></div>
27+
<div class="<?= $block->escapeHtmlAttr($block->getSomeString(), false); ?>"></div>
28+
29+
<script type="text/x-magento-init">
30+
{
31+
"#chart_<?= $block->escapeJs($block->getData('html_id')) ?>_period": {
32+
"Magento_Backend/js/dashboard/chart": {}
33+
}
34+
}
35+
</script>
36+
37+
The only example of this method being used was in a block class, rather than a template.
38+
<?php
39+
foreach ($block->getItems() as $item) {
40+
$item['sku'] = $block->escapeJsQuote($item['sku']);
41+
}
42+
?>
43+
44+
The only example of this method being used was in a block class, rather than a template.
45+
<?= $block->escapeQuote(__($block->getData('welcome'))); ?>
46+
47+
<a href="<?= $block->escapeUrl($block->getUrl('adminhtml/notification/index')) ?>"> link text </a>
48+
49+
Note that I couldn't find any use of this method in any templates within Magento.
50+
<?= $block->escapeXssInUrl($block->getSomeString()); ?>
51+
</section>
52+
53+
<section>
54+
<h1>These are edge cases for formatting differences</h1>
55+
56+
<?php
57+
$block->escapeHtml('');
58+
$block ->escapeHtml('');
59+
$block-> escapeHtml('');
60+
$block
61+
->escapeHtml('');
62+
$block
63+
64+
->escapeHtml('');
65+
$block->
66+
escapeHtml('');
67+
$block-> // comment
68+
escapeHtml('');
69+
$block /* comment */
70+
->escapeHtml('');
71+
72+
$block /* comment */ -> /* comment */ escapeHtml('');
73+
?>
74+
</section>
75+
76+
<section>
77+
<h1>These close-matches shouldn't be flagged by this sniff.</h1>
78+
79+
<?= $block->escapeHTML(__($block->getSomeString())) ?>
80+
<?= $block->escapeHtmlString(__($block->getSomeString())) ?>
81+
<?= $block->escapeHtmlAttribute($block->getSomeString()) ?>
82+
<?= $block->escapeCSS($block->getSomeString()); ?>
83+
<?= $block->escapeJS($block->getData('html_id')) ?>
84+
<?= $block->escapeJavaScript($block->getData('html_id')) ?>
85+
<?= $block->escapeQuotes(__($block->getData('welcome'))); ?>
86+
<?= $block->escapeURL($block->getUrl('adminhtml/notification/index')) ?>
87+
</section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/** @var Magento\Framework\View\Element\Template $block */
3+
/** @var Magento\Framework\Escaper $escaper */
4+
?>
5+
6+
<section>
7+
<h1>This unescaped output is fine here; other sniffs will complain about it though.</h1>
8+
9+
<?php echo $block->getSomeString(); ?>
10+
<?= $block->getSomeString(); ?>
11+
<?= /** @noEscape */ $block->getSomeString(); ?>
12+
<?= /** @escapeNotVerified */ $block->getSomeString(); ?>
13+
</section>
14+
15+
<section>
16+
<h1>These should be using equivalent methods on the `$escaper` class, not the `$block` class.</h1>
17+
18+
Note that I couldn't find any use of this method in any templates within Magento.
19+
<?= $escaper->escapeCss($block->getSomeString()); ?>
20+
21+
<?= $escaper->escapeHtml(__($block->getSomeString())) ?>
22+
<?= $escaper->escapeHtml(__($block->getSomeString())); ?>
23+
<?= $escaper->escapeHtml(__($block->getSomeString()), ['strong', 'em', 'span']) ?>
24+
25+
<div class="<?= $escaper->escapeHtmlAttr($block->getSomeString()) ?>"></div>
26+
<div class="<?= $escaper->escapeHtmlAttr($block->getSomeString(), true) ?>"></div>
27+
<div class="<?= $escaper->escapeHtmlAttr($block->getSomeString(), false); ?>"></div>
28+
29+
<script type="text/x-magento-init">
30+
{
31+
"#chart_<?= $escaper->escapeJs($block->getData('html_id')) ?>_period": {
32+
"Magento_Backend/js/dashboard/chart": {}
33+
}
34+
}
35+
</script>
36+
37+
The only example of this method being used was in a block class, rather than a template.
38+
<?php
39+
foreach ($block->getItems() as $item) {
40+
$item['sku'] = $escaper->escapeJsQuote($item['sku']);
41+
}
42+
?>
43+
44+
The only example of this method being used was in a block class, rather than a template.
45+
<?= $escaper->escapeQuote(__($block->getData('welcome'))); ?>
46+
47+
<a href="<?= $escaper->escapeUrl($block->getUrl('adminhtml/notification/index')) ?>"> link text </a>
48+
49+
Note that I couldn't find any use of this method in any templates within Magento.
50+
<?= $escaper->escapeXssInUrl($block->getSomeString()); ?>
51+
</section>
52+
53+
<section>
54+
<h1>These are edge cases for formatting differences</h1>
55+
56+
<?php
57+
$escaper->escapeHtml('');
58+
$escaper ->escapeHtml('');
59+
$escaper-> escapeHtml('');
60+
$escaper
61+
->escapeHtml('');
62+
$escaper
63+
64+
->escapeHtml('');
65+
$escaper->
66+
escapeHtml('');
67+
$escaper-> // comment
68+
escapeHtml('');
69+
$escaper /* comment */
70+
->escapeHtml('');
71+
72+
$escaper /* comment */ -> /* comment */ escapeHtml('');
73+
?>
74+
</section>
75+
76+
<section>
77+
<h1>These close-matches shouldn't be flagged by this sniff.</h1>
78+
79+
<?= $block->escapeHTML(__($block->getSomeString())) ?>
80+
<?= $block->escapeHtmlString(__($block->getSomeString())) ?>
81+
<?= $block->escapeHtmlAttribute($block->getSomeString()) ?>
82+
<?= $block->escapeCSS($block->getSomeString()); ?>
83+
<?= $block->escapeJS($block->getData('html_id')) ?>
84+
<?= $block->escapeJavaScript($block->getData('html_id')) ?>
85+
<?= $block->escapeQuotes(__($block->getData('welcome'))); ?>
86+
<?= $block->escapeURL($block->getUrl('adminhtml/notification/index')) ?>
87+
</section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
namespace Magento2\Tests\Legacy;
9+
10+
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
11+
12+
class EscapeMethodsOnBlockClassUnitTest extends AbstractSniffUnitTest
13+
{
14+
protected function getErrorList()
15+
{
16+
return [];
17+
}
18+
19+
protected function getWarningList()
20+
{
21+
return [
22+
19 => 1,
23+
21 => 1,
24+
22 => 1,
25+
23 => 1,
26+
25 => 1,
27+
26 => 1,
28+
27 => 1,
29+
31 => 1,
30+
40 => 1,
31+
45 => 1,
32+
47 => 1,
33+
50 => 1,
34+
57 => 1,
35+
58 => 1,
36+
59 => 1,
37+
61 => 1,
38+
64 => 1,
39+
66 => 1,
40+
68 => 1,
41+
70 => 1,
42+
72 => 1,
43+
];
44+
}
45+
}

Diff for: ‎Magento2/ruleset.xml

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
<severity>10</severity>
9595
<type>error</type>
9696
</rule>
97+
<rule ref="Magento2.Security.XssTemplate.FoundUnescaped">
98+
<severity>10</severity>
99+
<type>error</type>
100+
</rule>
97101
<rule ref="PSR1.Classes.ClassDeclaration">
98102
<severity>10</severity>
99103
<type>error</type>

Diff for: ‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ npm run eslint -- path/to/analyze
113113
```
114114

115115
### RECTOR PHP
116-
From `magento-condign-standard` project, you can execute rector php as follows:
116+
From `magento-coding-standard` project, you can execute rector php as follows:
117117
```bash
118118
vendor/bin/rector process Magento2 Magento2Framework PHP_CodeSniffer --dry-run --autoload-file vendor/squizlabs/php_codesniffer/autoload.php
119119
```

Diff for: ‎eslint/.eslintrc-magento

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"eol-last": 2,
1919
"eqeqeq": [2, "smart"],
2020
"guard-for-in": 2,
21-
"keyword-spacing": [2, {}],
21+
"indent": [2, 4],
22+
"keyword-spacing": [2, {"after": true, "before": true}],
2223
"lines-around-comment": [
2324
2,
2425
{
@@ -50,6 +51,7 @@
5051
"no-fallthrough": 2,
5152
"no-floating-decimal": 2,
5253
"no-func-assign": 2,
54+
"no-global-assign": 2,
5355
"no-implied-eval": 2,
5456
"no-inner-declarations": 2,
5557
"no-invalid-regexp": 2,
@@ -81,10 +83,16 @@
8183
}
8284
],
8385
"no-use-before-define": 2,
86+
"no-useless-call": 2,
87+
"no-useless-computed-key": 2,
88+
"no-useless-constructor": 2,
89+
"no-useless-escape": 2,
90+
"no-useless-rename": 2,
91+
"no-useless-return": 2,
8492
"no-with": 2,
8593
"one-var": [2, "always"],
8694
"operator-assignment": [2, "always"],
87-
"quotes": [2, "single"],
95+
"quotes": [2, "single", {"allowTemplateLiterals": true}],
8896
"radix": 2,
8997
"semi": [2, "always"],
9098
"semi-spacing": 2,

Diff for: ‎eslint/rules/utils.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ function getExpressionId(node) {
7575

7676
while (node) {
7777
switch (node.type) {
78-
case 'CallExpression':
79-
node = node.callee;
80-
break;
81-
82-
case 'MemberExpression':
83-
node = node.object;
84-
break;
85-
86-
case 'Identifier':
87-
return node;
88-
default:
89-
return null;
78+
case 'CallExpression':
79+
node = node.callee;
80+
break;
81+
82+
case 'MemberExpression':
83+
node = node.object;
84+
break;
85+
86+
case 'Identifier':
87+
return node;
88+
default:
89+
return null;
9090
}
9191
}
9292
}

0 commit comments

Comments
 (0)
Please sign in to comment.