Skip to content

Commit

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

}//end register()

Expand Down
3 changes: 3 additions & 0 deletions src/Standards/Generic/Tests/PHP/SyntaxUnitTest.2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?= 'text' ?>
<div>text</div>
<?= if($x) { $y = 'text'; } ?>
14 changes: 12 additions & 2 deletions src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@ class SyntaxUnitTest 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 [3 => 1];
switch ($testFile) {
case 'SyntaxUnitTest.1.inc':
case 'SyntaxUnitTest.2.inc':
return [3 => 1];
break;
default:
return [];
break;
}

}//end getErrorList()

Expand Down

0 comments on commit bd03017

Please sign in to comment.