diff --git a/Magento2/Sniffs/Legacy/PhtmlTemplateSniff.php b/Magento2/Sniffs/Legacy/PhtmlTemplateSniff.php
index fa5eb70e..1f897d38 100644
--- a/Magento2/Sniffs/Legacy/PhtmlTemplateSniff.php
+++ b/Magento2/Sniffs/Legacy/PhtmlTemplateSniff.php
@@ -14,7 +14,7 @@ class PhtmlTemplateSniff implements Sniff
{
private const WARNING_CODE_TEXT_JAVASCRIPT = 'TextJavascriptTypeFound';
private const WARNING_CODE_PROTECTED_PRIVATE_BLOCK_ACCESS = 'ProtectedPrivateBlockAccess';
-
+
/**
* @inheritdoc
*/
@@ -40,7 +40,7 @@ public function process(File $phpcsFile, $stackPtr)
$this->checkHtml($phpcsFile, $stackPtr);
}
}
-
+
/**
* Check access to protected and private members of Block
*
@@ -74,13 +74,19 @@ private function checkBlockVariable(File $phpcsFile, int $stackPtr, array $token
private function checkHtml(File $phpcsFile, int $stackPtr): void
{
$content = $phpcsFile->getTokensAsString($stackPtr, 1);
-
- if (preg_match('/type="text\/javascript"/', $content)) {
- $phpcsFile->addWarning(
+ $pattern = '_(
+
+
+_getTestFunction();
+$block->getTestFunction();
+$_something = $this->something();
+$block->_getTest();
+$block = _testing();
+?>
+_getTestAnotherFunction();
+?>
+
+helper();
+?>
+
+
+
This sniff should remove the any type="text/javascript"
attributes from <script> tags, but not from elsewhere in the document.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/base/templates/PhtmlTemplateUnitTest.1.phtml b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/base/templates/PhtmlTemplateUnitTest.1.phtml
index 772783c9..bba83c89 100644
--- a/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/base/templates/PhtmlTemplateUnitTest.1.phtml
+++ b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/base/templates/PhtmlTemplateUnitTest.1.phtml
@@ -38,3 +38,18 @@ $this->helper();
?>
+
+
This sniff should remove the any type="text/javascript"
attributes from <script> tags, but not from elsewhere in the document.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/base/templates/PhtmlTemplateUnitTest.1.phtml.fixed b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/base/templates/PhtmlTemplateUnitTest.1.phtml.fixed
new file mode 100644
index 00000000..272b1668
--- /dev/null
+++ b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/base/templates/PhtmlTemplateUnitTest.1.phtml.fixed
@@ -0,0 +1,55 @@
+
+
+
+
+_getTestFunction();
+$block->getTestFunction();
+$_something = $this->something();
+$block->_getTest();
+$block = _testing();
+?>
+_getTestAnotherFunction();
+?>
+
+helper();
+?>
+
+
+
This sniff should remove the any type="text/javascript"
attributes from <script> tags, but not from elsewhere in the document.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/frontend/templates/PhtmlTemplateUnitTest.2.phtml b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/frontend/templates/PhtmlTemplateUnitTest.2.phtml
index 772783c9..bba83c89 100644
--- a/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/frontend/templates/PhtmlTemplateUnitTest.2.phtml
+++ b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/frontend/templates/PhtmlTemplateUnitTest.2.phtml
@@ -38,3 +38,18 @@ $this->helper();
?>
+
+
This sniff should remove the any type="text/javascript"
attributes from <script> tags, but not from elsewhere in the document.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/frontend/templates/PhtmlTemplateUnitTest.2.phtml.fixed b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/frontend/templates/PhtmlTemplateUnitTest.2.phtml.fixed
new file mode 100644
index 00000000..272b1668
--- /dev/null
+++ b/Magento2/Tests/Legacy/_files/PhtmlTemplateUnitTest/view/frontend/templates/PhtmlTemplateUnitTest.2.phtml.fixed
@@ -0,0 +1,55 @@
+
+
+
+
+_getTestFunction();
+$block->getTestFunction();
+$_something = $this->something();
+$block->_getTest();
+$block = _testing();
+?>
+_getTestAnotherFunction();
+?>
+
+helper();
+?>
+
+
+
This sniff should remove the any type="text/javascript"
attributes from <script> tags, but not from elsewhere in the document.
+
+
+
+
+
+
+
+
+
+
+