Skip to content

"Uninitialized string offset: 0" when sniffing CSS #1657

Closed
@h3xx

Description

@h3xx

Steps to reproduce

Invoke phpcs on the test code:

phpcs --standard=Squiz -s --sniffs=Squiz.CSS.DuplicateClassDefinition [FILE]

Test code

.foo /* any comment */
{ color: red; }

Produces output

FILE: test.css
---------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been aborted. The
   |       | error message was: Uninitialized string offset: 0 in
   |       | /.../git/PHP_CodeSniffer/src/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php
   |       | on line 98 (Internal.Exception)
---------------------------------------------------------------------------------

Time: 77ms; Memory: 8Mb

Expected output

No output. No duplicate class definitions should be found.

Found in phpcs version 276f561 (2017-09-15)

Note: The amount of whitespace surrounding the comment doesn't seem to affect whether this happens. Can be on the same line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions