Skip to content

AC-681: Create phpcs static check for PhtmlTemplateTest #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
AC-681: Create phpcs static check for PhtmlTemplateTest
  • Loading branch information
eliseacornejo committed Oct 5, 2021
commit 203e8af1e3aa67fe196e3c661911efae30652420
15 changes: 11 additions & 4 deletions Magento2/Sniffs/Legacy/PhtmlTemplateSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class PhtmlTemplateSniff implements Sniff
private const WARNING_CODE = 'PhtmlTemplateObsolete';

private const OBSOLETE_REGEX_IN_SPECIFIC_PHTML_TEMPLATES = [
'/(["\'])jquery\/ui\1/' => 'Please do not use "jquery/ui" library in templates. Use needed jquery ' .
'/(["\'])jquery\/ui\1/' => 'Please do not use "jquery/ui" library in templates. Use needed jquery ' .
'ui widget instead.',
'/data-mage-init=(?:\'|")(?!\s*{\s*"[^"]+")/' => 'Please do not initialize JS component in php. Do ' .
'/data-mage-init=(?:\'|")(?!\s*{\s*"[^"]+")/' => 'Please do not initialize JS component in php. Do ' .
'it in template.',
'@x-magento-init.>(?!\s*+{\s*"[^"]+"\s*:\s*{\s*"[\w/-]+")@i' => 'Please do not initialize JS component ' .
'@x-magento-init.>(?!\s*+{\s*"[^"]+"\s*:\s*{\s*"[\w/-]+")@i' => 'Please do not initialize JS component ' .
'in php. Do it in template.',
];

Expand Down Expand Up @@ -54,6 +54,8 @@ public function process(File $phpcsFile, $stackPtr)
}

/**
* Check access to protected and private members of Block
*
* @param File $phpcsFile
* @param int $stackPtr
* @param array $tokens
Expand All @@ -76,6 +78,8 @@ private function checkBlockVariable(File $phpcsFile, int $stackPtr, array $token
}

/**
* Check access to members and methods of Block class through $this
*
* @param File $phpcsFile
* @param int $stackPtr
* @param array $tokens
Expand All @@ -98,6 +102,8 @@ private function checkThisVariable(File $phpcsFile, int $stackPtr, array $tokens
}

/**
* Check use of "text/javascript" type
*
* @param File $phpcsFile
* @param int $stackPtr
*/
Expand All @@ -115,6 +121,8 @@ private function checkHtml(File $phpcsFile, int $stackPtr): void
}

/**
* Check of some obsoletes uses in specific files
*
* @param File $phpcsFile
* @param int $stackPtr
*/
Expand All @@ -132,5 +140,4 @@ private function checkHtmlSpecificFiles(File $phpcsFile, int $stackPtr): void
}
}
}

}