Skip to content
Snippets Groups Projects
Unverified Commit 6689a211 authored by Klaus Purer's avatar Klaus Purer Committed by GitHub
Browse files

fix(DocComment): Fix undefined string index on short comments (#3307937)

parent e4e05ca7
Branches
Tags
No related merge requests found
......@@ -224,7 +224,8 @@ class DocCommentSniff implements Sniff
// Remove any trailing white spaces which are detected by other sniffs.
$shortContent = trim($shortContent);
if (preg_match('|\p{Lu}|u', $shortContent[0]) === 0
if ($shortContent !== ''
&& preg_match('|\p{Lu}|u', $shortContent[0]) === 0
// Allow both variants of inheritdoc comments.
&& $shortContent !== '{@inheritdoc}'
&& $shortContent !== '{@inheritDoc}'
......
......@@ -27,6 +27,11 @@ class BadUnitTest extends CoderSniffUnitTest
protected function getErrorList(string $testFile): array
{
switch ($testFile) {
case 'bad_crlf.inc':
return [
1 => 2,
8 => 1,
];
case 'bad.css':
return [
1 => 1,
......
<?php
namespace Drupal\example\Controller;
/**
* Foo.
*/
class ExampleController
{
}
<?php
namespace Drupal\example\Controller;
/**
* Foo.
*/
class ExampleController {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment