diff --git a/Magento2/Sniffs/Html/HtmlDirectiveSniff.php b/Magento2/Sniffs/Html/HtmlDirectiveSniff.php
index 6179f90f..b14ae7ba 100644
--- a/Magento2/Sniffs/Html/HtmlDirectiveSniff.php
+++ b/Magento2/Sniffs/Html/HtmlDirectiveSniff.php
@@ -8,7 +8,6 @@
namespace Magento2\Sniffs\Html;
-use Magento\Framework\Filter\Template;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;
@@ -17,6 +16,11 @@
*/
class HtmlDirectiveSniff implements Sniff
{
+ const CONSTRUCTION_DEPEND_PATTERN = '/{{depend\s*(.*?)}}(.*?){{\\/depend\s*}}/si';
+ const CONSTRUCTION_IF_PATTERN = '/{{if\s*(.*?)}}(.*?)({{else}}(.*?))?{{\\/if\s*}}/si';
+ const LOOP_PATTERN = '/{{for(?P.*? )(in)(?P.*?)}}(?P.*?){{\/for}}/si';
+ const CONSTRUCTION_PATTERN = '/{{([a-z]{0,10})(.*?)}}(?:(.*?)(?:{{\/(?:\\1)}}))?/si';
+
/**
* @var array
*/
@@ -73,7 +77,7 @@ public function process(File $phpcsFile, $stackPtr)
*/
private function processIfDirectives(string $html, File $phpcsFile): string
{
- if (preg_match_all(Template::CONSTRUCTION_IF_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
+ if (preg_match_all(self::CONSTRUCTION_IF_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
foreach ($constructions as $construction) {
// validate {{if }}
$this->validateVariableUsage($phpcsFile, $construction[1]);
@@ -93,7 +97,7 @@ private function processIfDirectives(string $html, File $phpcsFile): string
*/
private function processDependDirectives(string $html, File $phpcsFile): string
{
- if (preg_match_all(Template::CONSTRUCTION_DEPEND_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
+ if (preg_match_all(self::CONSTRUCTION_DEPEND_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
foreach ($constructions as $construction) {
// validate {{depend }}
$this->validateVariableUsage($phpcsFile, $construction[1]);
@@ -113,7 +117,7 @@ private function processDependDirectives(string $html, File $phpcsFile): string
*/
private function processForDirectives(string $html, File $phpcsFile): string
{
- if (preg_match_all(Template::LOOP_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
+ if (preg_match_all(self::LOOP_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
foreach ($constructions as $construction) {
// validate {{for in }}
$this->validateVariableUsage($phpcsFile, $construction['loopData']);
@@ -133,7 +137,7 @@ private function processForDirectives(string $html, File $phpcsFile): string
*/
private function processVarDirectivesAndParams(string $html, File $phpcsFile): string
{
- if (preg_match_all(Template::CONSTRUCTION_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
+ if (preg_match_all(self::CONSTRUCTION_PATTERN, $html, $constructions, PREG_SET_ORDER)) {
foreach ($constructions as $construction) {
if (empty($construction[2])) {
continue;