Commit 9dc15a30 authored by Klaus Purer's avatar Klaus Purer
Browse files

fix(FileComment): Fixer for file comment should ignore simple comments (#2956065 by klausi, kenorb)

parent 070c7279
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
@@ -85,6 +85,9 @@ class FileCommentSniff implements Sniff
                && $secondOopKeyword === false
                && $namespace !== false
            ) {
                if ($tokens[$commentStart]['code'] === T_COMMENT) {
                    $phpcsFile->addError('Namespaced classes, interfaces and traits should not begin with a file doc comment', $commentStart, 'NamespaceNoFileDoc');
                } else {
                    $fix = $phpcsFile->addFixableError('Namespaced classes, interfaces and traits should not begin with a file doc comment', $commentStart, 'NamespaceNoFileDoc');
                    if ($fix === true) {
                        $phpcsFile->fixer->beginChangeset();
@@ -102,6 +105,7 @@ class FileCommentSniff implements Sniff
                        $phpcsFile->fixer->endChangeset();
                    }
                }
            }//end if

            if ($namespace !== false) {
                return ($phpcsFile->numTokens + 1);
+18 −0
Original line number Diff line number Diff line
<?php
/*
 * @file
 *   Some misformatted file comment
 *
 *   @todo
 *     - some list
 *     - and more
 */
namespace Drupal\Example\Something;
/*
 * @todo: Perhaps move these annotations down to the instance classes and tests.
 *
 * @runTestsInSeparateProcess
 * @preserveGlobalState disabled
 */
abstract class TestCase extends \PHPUnit\Framework\TestCase {
}
+18 −0
Original line number Diff line number Diff line
<?php
/*
 * @file
 *   Some misformatted file comment
 *
 *   @todo
 *     - some list
 *     - and more
 */
namespace Drupal\Example\Something;
/*
 * @todo: Perhaps move these annotations down to the instance classes and tests.
 *
 * @runTestsInSeparateProcess
 * @preserveGlobalState disabled
 */
abstract class TestCase extends \PHPUnit\Framework\TestCase {
}
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ class FileCommentUnitTest extends CoderSniffUnitTest
            return [4 => 1];
        case 'FileCommentUnitTest.11.inc':
            return [4 => 1];
        case 'FileCommentUnitTest.12.inc':
            return [2 => 1];
        }//end switch

    }//end getErrorList()