|
3 | 3 | * Copyright © Magento, Inc. All rights reserved. |
4 | 4 | * See COPYING.txt for license details. |
5 | 5 | */ |
| 6 | +declare(strict_types = 1); |
6 | 7 |
|
7 | 8 | namespace Magento2\Sniffs\Legacy; |
8 | 9 |
|
@@ -60,9 +61,6 @@ public function process(File $phpcsFile, $stackPtr) |
60 | 61 |
|
61 | 62 | $layouts = $this->collectClassesInLayout($xml); |
62 | 63 | $this->assertNonFactoryName($phpcsFile, $layouts); |
63 | | - |
64 | | - $layoutTabs = $this->collectClassesInLayoutTabs($xml); |
65 | | - $this->assertNonFactoryNameTab($phpcsFile, $layoutTabs); |
66 | 64 | } |
67 | 65 |
|
68 | 66 | /** |
@@ -106,25 +104,6 @@ private function assertNonFactoryNameModule(File $phpcsFile, array $classes) |
106 | 104 | } |
107 | 105 | } |
108 | 106 |
|
109 | | - /** |
110 | | - * Check whether specified class names in layout tabs are right according PSR-1 Standard. |
111 | | - * |
112 | | - * @param File $phpcsFile |
113 | | - * @param array $elements |
114 | | - */ |
115 | | - private function assertNonFactoryNameTab(File $phpcsFile, array $elements) |
116 | | - { |
117 | | - foreach ($elements as $element) { |
118 | | - if (preg_match('/\//', $element['value']) !== false) { |
119 | | - $phpcsFile->addError( |
120 | | - self::ERROR_MESSAGE_CONFIG, |
121 | | - $element['lineNumber'], |
122 | | - self::ERROR_CODE_CONFIG, |
123 | | - ); |
124 | | - } |
125 | | - } |
126 | | - } |
127 | | - |
128 | 107 | /** |
129 | 108 | * Format the incoming XML to avoid tags split into several lines. |
130 | 109 | * |
@@ -198,41 +177,10 @@ function (array $extendedNode) { |
198 | 177 | */ |
199 | 178 | private function collectClassesInLayout(SimpleXMLElement $xml): array |
200 | 179 | { |
201 | | - $classes = $this->getValuesFromXmlTagAttribute( |
202 | | - $xml, |
203 | | - '/layout//@helper', |
204 | | - 'helper' |
205 | | - ); |
206 | | - $classes = array_map( |
207 | | - function (array $extendedNode) { |
208 | | - $extendedNode['value'] = explode('::', trim($extendedNode['value']))[0]; |
209 | | - return $extendedNode; |
210 | | - }, |
211 | | - $classes |
212 | | - ); |
213 | | - $classes = array_merge( |
214 | | - $classes, |
215 | | - $this->getValuesFromXmlTagAttribute( |
216 | | - $xml, |
217 | | - '/layout//@module', |
218 | | - 'module' |
219 | | - ) |
220 | | - ); |
221 | | - |
222 | | - return $classes; |
223 | | - } |
224 | | - |
225 | | - /** |
226 | | - * Extract class references from layout tabs |
227 | | - * |
228 | | - * @param SimpleXMLElement $xml |
229 | | - * @return array |
230 | | - */ |
231 | | - private function collectClassesInLayoutTabs(SimpleXMLElement $xml): array |
232 | | - { |
233 | | - return $this->getValuesFromXmlTagContent( |
| 180 | + return $this->getValuesFromXmlTagAttribute( |
234 | 181 | $xml, |
235 | | - '/layout//action[@method="addTab"]/block', |
| 182 | + '/layout//@module', |
| 183 | + 'module' |
236 | 184 | ); |
237 | 185 | } |
238 | 186 |
|
|
0 commit comments