Skip to content

Commit ddd5c03

Browse files
committed
MAGETWO-84354: Copy EQP sniffs to Magento 2 Core repo
1 parent 97add9d commit ddd5c03

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

dev/tests/static/framework/Magento/Sniffs/LanguageConstructs/GotoSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
/**
1212
* Detects GOTO usage.
13+
*
14+
* Example:
15+
* goto end;
16+
* end:
17+
* 'The End';
1318
*/
1419
class GotoSniff implements Sniff
1520
{

dev/tests/static/framework/Magento/Sniffs/LanguageConstructs/LanguageConstructsSniff.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
use PHP_CodeSniffer\Files\File;
1010

1111
/**
12-
* Detects possible usage of discouraged language constructs.
12+
* Detects possible usage of discouraged language constructs. Is not applicable to *.phtml files.
13+
*
14+
* Examples:
15+
* echo 'echo text';
16+
* print('print text');
17+
* $ = `back quotes`;
18+
* exit(1);
1319
*/
1420
class LanguageConstructsSniff implements Sniff
1521
{

dev/tests/static/framework/Magento/Sniffs/Security/ExecutableRegExSniff.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* Detects executable regular expressions.
14+
*
15+
* Example: echo preg_replace('|^(.*)$|ei', '"\1"', 'get_input');
1416
*/
1517
class ExecutableRegExSniff implements Sniff
1618
{

dev/tests/static/framework/Magento/Sniffs/Strings/StringPositionSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
/**
1212
* Detects misusing of IS_IDENTICAL operators.
13+
*
14+
* Examples:
15+
* if (!strpos($haystack, $needle)) {}
16+
* if (strpos($haystack, $needle) == false) {}
1317
*/
1418
class StringPositionSniff implements Sniff
1519
{

dev/tests/static/framework/Magento/ruleset.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@
1616
<property name="absoluteLineLimit" value="120"/>
1717
</properties>
1818
</rule>
19-
<rule ref="Magento.LanguageConstructs.LanguageConstructs.DirectOutput">
20-
<exclude-pattern>*/Framework/*</exclude-pattern>
21-
<exclude-pattern>*.phtml</exclude-pattern>
22-
</rule>
23-
<rule ref="Magento.LanguageConstructs.LanguageConstructs.ExitUsage">
24-
<exclude-pattern>*/Framework/*</exclude-pattern>
19+
<rule ref="Magento.LanguageConstructs.LanguageConstructs">
20+
<include-pattern>*/app/code/*\.(?!phtml)</include-pattern>
2521
</rule>
2622
<rule ref="Magento.LiteralNamespaces.LiteralNamespaces">
2723
<exclude-pattern>*/_files/*</exclude-pattern>

0 commit comments

Comments
 (0)