Skip to content

Commit

Permalink
Generic/LineEndings: 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 002e4cc
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ scripts/ export-ignore
# Declare files that should always have CRLF line endings on checkout.
*WinTest.inc text eol=crlf
*WinTest.php text eol=crlf
src/Standards/Generic/Tests/Files/LineEndingsUnitTest*.inc text eol=crlf
6 changes: 4 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="InlineHTMLUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.css" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.css.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.1.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.1.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.2.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.2.inc.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.js" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.js.fixed" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="LineEndingsUnitTest.php" role="test" />
Expand Down
5 changes: 4 additions & 1 deletion src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class LineEndingsSniff 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
@@ -1,18 +1,18 @@

<?php
echo 'hi';
?>

<?php
echo 'hi';
?>

<?php
function foo()
{
$query->group('a.id,
uc.name,
ag.title,
ua.name'
);
}

<?php
echo 'hi';
?>

<?php
echo 'hi';
?>

<?php
function foo()
{
$query->group('a.id,
uc.name,
ag.title,
ua.name'
);
}
5 changes: 5 additions & 0 deletions src/Standards/Generic/Tests/Files/LineEndingsUnitTest.2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<?= 'hi'; ?>

<div>...more HTML...</div>
<?= 'hi'; ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

<?= 'hi'; ?>

<div>...more HTML...</div>
<?= 'hi'; ?>

0 comments on commit 002e4cc

Please sign in to comment.