Skip to content

Commit

Permalink
Merge branch 'feature/generic-closingphptag-check-short-echo-tag' of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed May 17, 2021
2 parents a1d1f03 + 92eba1c commit b3879f5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file baseinstalldir="PHP/CodeSniffer" name="CharacterBeforePHPOpeningTagUnitTest.2.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="CharacterBeforePHPOpeningTagUnitTest.3.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="CharacterBeforePHPOpeningTagUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingPHPTagUnitTest.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingPHPTagUnitTest.1.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingPHPTagUnitTest.2.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="ClosingPHPTagUnitTest.php" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DeprecatedFunctionsUnitTest.inc" role="test" />
<file baseinstalldir="PHP/CodeSniffer" name="DeprecatedFunctionsUnitTest.php" role="test" />
Expand Down
5 changes: 4 additions & 1 deletion src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class ClosingPHPTagSniff implements Sniff
*/
public function register()
{
return [T_OPEN_TAG];
return [
T_OPEN_TAG,
T_OPEN_TAG_WITH_ECHO,
];

}//end register()

Expand Down
5 changes: 5 additions & 0 deletions src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?= 'foo'; ?>
<b>Bold text</b>
<?= 'bar'; ?>
<i>Italic text</i>
<?= 'baz';
15 changes: 13 additions & 2 deletions src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ class ClosingPHPTagUnitTest extends AbstractSniffUnitTest
* The key of the array should represent the line number and the value
* should represent the number of errors that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getErrorList()
public function getErrorList($testFile='')
{
return [9 => 1];
switch ($testFile) {
case 'ClosingPHPTagUnitTest.1.inc':
return [9 => 1];
case 'ClosingPHPTagUnitTest.2.inc':
return [5 => 1];
break;
default:
return [];
break;
}

}//end getErrorList()

Expand Down

0 comments on commit b3879f5

Please sign in to comment.