Skip to content

Squiz.Arrays.ArrayDeclaration does incorrect align calculation in array with cyrillic keys #2144

Closed
@player259

Description

@player259

Seems that problem with string functions. I didn't found usage of mb_* in project, so all non-latin strings will produce issues.

    public function test()
    {
        // Produces error
        [
            'тип'  => 'авто',
            'цвет' => 'синий',
        ];

        // No error, extra 4 spaces after 'цвет', because it's 4 two-byte character string
        [
            'тип'      => 'авто',
            'цвет'     => 'синий',
        ];
    }
 15 | ERROR | [x] Array double arrow not aligned correctly; expected 3 space(s) but found -1
    |       |     (Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned)
 16 | ERROR | [x] Array double arrow not aligned correctly; expected 1 space(s) but found -3
    |       |     (Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned)

I've found this substitution list for string functions, if helps

'strlen'=>'mb_strlen',
'strpos'=>'mb_strpos',
'substr'=>'mb_substr',
'strtolower'=>'mb_strtolower',
'strtoupper'=>'mb_strtoupper',
'substr_count'=>'mb_substr_count',
'split'=>'mb_split',
'mail'=>'mb_send_mail',
'ereg'=>'mb_ereg',
'eregi'=>'mb_eregi',
'strrchr' => 'mb_strrchr',
'strichr' => 'mb_strichr',
'strchr' => 'mb_strchr',
'strrpos' => 'mb_strrpos',
'strripos' => 'mb_strripos',
'stripos' => 'mb_stripos',
'stristr' => 'mb_stristr'

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