Skip to content

Commit

Permalink
Generic/DisallowSpaceIndent: 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 3fb8a2d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.1.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.2.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.2.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.3.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.3.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.js" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.js.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DisallowSpaceIndentUnitTest.php" role="test" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class DisallowSpaceIndentSniff 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 @@ -86,6 +86,17 @@ public function getErrorList($testFile='DisallowSpaceIndentUnitTest.1.inc')
118 => 1,
];
break;
case 'DisallowSpaceIndentUnitTest.3.inc':
return [
2 => 1,
5 => 1,
10 => 1,
12 => 1,
13 => 1,
14 => 1,
15 => 1,
];
break;
case 'DisallowSpaceIndentUnitTest.js':
return [3 => 1];
break;
Expand Down

0 comments on commit 3fb8a2d

Please sign in to comment.