Skip to content

Commit

Permalink
Generic/DisallowTabIndent: check files using only short open echo tag
Browse files Browse the repository at this point in the history
Includes unit tests.
  • Loading branch information
jrfnl committed Apr 22, 2021
1 parent ae4f33b commit 551cdf7
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 5 deletions.
6 changes: 4 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.css" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.css.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.1.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.1.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.2.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.2.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.js" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.js.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowTabIndentUnitTest.php" role="test" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class DisallowTabIndentSniff implements Sniff
*/
public function register()
{
return [T_OPEN_TAG];
return [
T_OPEN_TAG,
T_OPEN_TAG_WITH_ECHO,
];

}//end register()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?=
"$hello $there";
?>
<html>
<head>
<title>Foo</title>
</head>
<body>
<div>
<div>
<div>
</div>
</div>
</div>
</body>
</html>

<?=
"$hello $there";
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?=
"$hello $there";
?>
<html>
<head>
<title>Foo</title>
</head>
<body>
<div>
<div>
<div>
</div>
</div>
</div>
</body>
</html>

<?=
"$hello $there";
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public function setCliValues($testFile, $config)
*
* @return array<int, int>
*/
public function getErrorList($testFile='DisallowTabIndentUnitTest.inc')
public function getErrorList($testFile='')
{
switch ($testFile) {
case 'DisallowTabIndentUnitTest.inc':
case 'DisallowTabIndentUnitTest.1.inc':
return [
5 => 2,
9 => 1,
Expand Down Expand Up @@ -84,6 +84,19 @@ public function getErrorList($testFile='DisallowTabIndentUnitTest.inc')
93 => 1,
];
break;
case 'DisallowTabIndentUnitTest.2.inc':
return [
6 => 1,
7 => 1,
8 => 1,
9 => 1,
10 => 1,
11 => 1,
12 => 1,
13 => 1,
19 => 1,
];
break;
case 'DisallowTabIndentUnitTest.js':
return [
3 => 1,
Expand Down

0 comments on commit 551cdf7

Please sign in to comment.