Skip to content

Commit 2bd5232

Browse files
committed
Merge branch 'master' into report-memory-improvements
Conflicts: package.xml
2 parents 1e6555a + 1151615 commit 2bd5232

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CodeSniffer/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public function start($contents=null)
422422
// token, get them to process it.
423423
foreach ($this->_tokens as $stackPtr => $token) {
424424
// Check for ignored lines.
425-
if ($token['code'] === T_COMMENT) {
425+
if ($token['code'] === T_COMMENT || $token['code'] === T_DOC_COMMENT) {
426426
if (strpos($token['content'], '@codingStandardsIgnoreStart') !== false) {
427427
$ignoring = true;
428428
} else if (strpos($token['content'], '@codingStandardsIgnoreEnd') !== false) {

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
3939
- Fixed problem where some file content could be ignored when checking STDIN
4040
- Version information is now printed when installed via composer or run from a Git clone (request #20050)
4141
- Added Squiz DisallowBooleanStatementSniff to ban boolean operators outside of control structure conditions
42+
- Coding standard ignore comments can now appear instead doc blocks as well as inline comments
43+
-- Thanks to Stuart Langley for the patch
4244
- PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented
4345
-- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change
4446
-- Thanks to Szabolcs Sulik for the patch

tests/Core/ErrorSuppressionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ public function testSuppressFile()
148148
$this->assertEquals(0, $numWarnings);
149149
$this->assertEquals(0, count($warnings));
150150

151+
// Process with a Doc Block suppression.
152+
$content = '<?php '.PHP_EOL.'/* @codingStandardsIgnoreFile */'.PHP_EOL.'//TODO: write some code';
153+
$phpcs->processFile('suppressionTest.php', $content);
154+
155+
$files = $phpcs->getFiles();
156+
$file = $files[1];
157+
158+
$warnings = $file->getWarnings();
159+
$numWarnings = $file->getWarningCount();
160+
$this->assertEquals(0, $numWarnings);
161+
$this->assertEquals(0, count($warnings));
162+
151163
}//end testSuppressFile()
152164

153165

0 commit comments

Comments
 (0)