![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/magento-coding-standard/Magento2/Sniffs/Legacy/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento2\Sniffs\Legacy; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; class DiConfigSniff implements Sniff { private const OBSOLETE_NODES = [ 'FoundObsoleteParamNode' => [ 'pattern' => '<param', 'message' => 'The <param> node is obsolete. Instead, use the <argument name="..." xsi:type="...">' ], 'FoundObsoleteInstanceNode' => [ 'pattern' => '<instance', 'message' => 'The <instance> node is obsolete. Instead, use the <argument name="..." xsi:type="object">>' ], 'FoundObsoleteArrayNode' => [ 'pattern' => '<array', 'message' => 'The <array> node is obsolete. Instead, use the <argument name="..." xsi:type="array">' ], 'FoundObsoleteItemNode' => [ 'pattern' => '<item key=', 'message' => 'The <item key="..."> node is obsolete. Instead, use the <item name="..." xsi:type="...">' ], 'FoundObsoleteValueNode' => [ 'pattern' => '<value', 'message' => 'The <value> node is obsolete. Instead, provide the actual value as a text literal' ], ]; /** * @inheritDoc */ public function register(): array { return [ T_INLINE_HTML ]; } /** * @inheritDoc */ public function process(File $phpcsFile, $stackPtr) { $lineContent = $phpcsFile->getTokensAsString($stackPtr, 1); foreach (self::OBSOLETE_NODES as $code => $data) { if (strpos($lineContent, $data['pattern']) !== false) { $phpcsFile->addWarning( $data['message'], $stackPtr, $code ); } } } }