Commit 0a274321 authored by Klaus Purer's avatar Klaus Purer
Browse files

fix(DocComment): Implement fixer correctly for file comment short description (#3032222)

parent 2b5ae544
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -165,6 +165,10 @@ class DocCommentSniff implements Sniff
            $error = 'Doc comment short description must be on the first line';
            $fix   = $phpcsFile->addFixableError($error, $short, 'SpacingBeforeShort');
            if ($fix === true) {
                // Move file comment short description to the next line.
                if (isset($fileShort) === true && $tokens[$short]['line'] === $tokens[$start]['line']) {
                    $phpcsFile->fixer->addContentBefore($fileShort, "\n *");
                } else {
                    $phpcsFile->fixer->beginChangeset();
                    for ($i = $start; $i < $short; $i++) {
                        if ($tokens[$i]['line'] === $tokens[$start]['line']) {
@@ -179,6 +183,7 @@ class DocCommentSniff implements Sniff
                    $phpcsFile->fixer->endChangeset();
                }
            }
        }//end if

        if ($tokens[($short - 1)]['content'] !== ' '
            && strpos($tokens[($short - 1)]['content'], $phpcsFile->eolChar) === false
+7 −0
Original line number Diff line number Diff line
<?php

/**
 * @file File contains Theming functions and Node definitions.
 */

require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'example') . '/example.inc';
+8 −0
Original line number Diff line number Diff line
<?php

/**
 * @file
 * File contains Theming functions and Node definitions.
 */

require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'example') . '/example.inc';
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ class DocCommentUnitTest extends CoderSniffUnitTest
                100 => 4,
                101 => 1,
            ];

        case 'DocCommentUnitTest.3.inc':
            return [4 => 1];
        default:
            return [];
        }