Skip to content

InlineIfDeclaration: invalid error produced with UTF-8 string #951

@janedbal

Description

@janedbal

Lets have following code in UTF-8 file test.php:

rand(0, 1) ? 'ěščřžýáí' : NULL;

And following ruleset:

<?xml version="1.0"?> <ruleset> <rule ref="Squiz.ControlStructures.InlineIfDeclaration"> <exclude name="Squiz.ControlStructures.InlineIfDeclaration.NoBrackets"/> </rule> </ruleset>

It will produce:

$ vendor/bin/phpcs --standard=standards.xml --encoding=utf-8 -sp test.php E FILE: D:\codesniffer-bug\test.php ---------------------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE ---------------------------------------------------------------------- 3 | ERROR | Inline shorthand IF statement requires 1 space before ELSE; | | -7 found | | (Squiz.ControlStructures.InlineIfDeclaration.SpacingBeforeElse) ---------------------------------------------------------------------- Time: 14ms; Memory: 2.25Mb 

My observations: the condition must be some php function and the string must contain some UTF-8 chars.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions