Skip to content

Commit bd03017

Browse files
committed
Merge branch 'feature/generic-syntax-check-short-echo-tag' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents b3879f5 + 6568bd0 commit bd03017

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

package.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
729729
<file baseinstalldir="PHP/CodeSniffer" name="RequireStrictTypesUnitTest.php" role="test" />
730730
<file baseinstalldir="PHP/CodeSniffer" name="SAPIUsageUnitTest.inc" role="test" />
731731
<file baseinstalldir="PHP/CodeSniffer" name="SAPIUsageUnitTest.php" role="test" />
732-
<file baseinstalldir="PHP/CodeSniffer" name="SyntaxUnitTest.inc" role="test" />
732+
<file baseinstalldir="PHP/CodeSniffer" name="SyntaxUnitTest.1.inc" role="test" />
733+
<file baseinstalldir="PHP/CodeSniffer" name="SyntaxUnitTest.2.inc" role="test" />
733734
<file baseinstalldir="PHP/CodeSniffer" name="SyntaxUnitTest.php" role="test" />
734735
<file baseinstalldir="PHP/CodeSniffer" name="UpperCaseConstantUnitTest.inc" role="test" />
735736
<file baseinstalldir="PHP/CodeSniffer" name="UpperCaseConstantUnitTest.inc.fixed" role="test" />

src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ class SyntaxSniff implements Sniff
3333
*/
3434
public function register()
3535
{
36-
return [T_OPEN_TAG];
36+
return [
37+
T_OPEN_TAG,
38+
T_OPEN_TAG_WITH_ECHO,
39+
];
3740

3841
}//end register()
3942

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?= 'text' ?>
2+
<div>text</div>
3+
<?= if($x) { $y = 'text'; } ?>

src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@ class SyntaxUnitTest extends AbstractSniffUnitTest
2222
* The key of the array should represent the line number and the value
2323
* should represent the number of errors that should occur on that line.
2424
*
25+
* @param string $testFile The name of the file being tested.
26+
*
2527
* @return array<int, int>
2628
*/
27-
public function getErrorList()
29+
public function getErrorList($testFile='')
2830
{
29-
return [3 => 1];
31+
switch ($testFile) {
32+
case 'SyntaxUnitTest.1.inc':
33+
case 'SyntaxUnitTest.2.inc':
34+
return [3 => 1];
35+
break;
36+
default:
37+
return [];
38+
break;
39+
}
3040

3141
}//end getErrorList()
3242

0 commit comments

Comments
 (0)