Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Utf8 support for LineLengthFixer #17

Open
avdeev-ms opened this issue Feb 7, 2023 · 3 comments
Open

Add Utf8 support for LineLengthFixer #17

avdeev-ms opened this issue Feb 7, 2023 · 3 comments

Comments

@avdeev-ms
Copy link

No utf8 support for LineLengthFixer.
The length of the strings is not correctly calculated, because of this, an extra line break is set, where it is not necessary.

The solution would be \Symplify\CodingStandard\TokenRunner\Transformer\FixerTransformer\FirstLineLengthResolver class to use the mb_strlen function instead of strlen, or be able to configure this behavior

@TomasVotruba
Copy link
Member

Could you share exact code of where current behavior fails?

@avdeev-ms
Copy link
Author

Setting LineLengthFixer in ecs config (no inline_short_lines, default line length: 120):

$services->set(LineLengthFixer::class)->call(
    'configure',
    [
        [
            'inline_short_lines' => false,
        ],
    ]
);

Run ecs on code example

class Example
{
    public function decline()
    {
        //a line break will be inserted here
        $this->getDefaultHttpException('Извините, произошла ошибка. Попробуйте позже.');
        //no line break will be inserted here
        $this->getDefaultHttpException('Sorry, an unexpected error occurred. Please try later.');
    }
}

The result will be

         //a line break will be inserted here
-        $this->getDefaultHttpException('Извините, произошла ошибка. Попробуйте позже.');
+        $this->getDefaultHttpException(
+            'Извините, произошла ошибка. Попробуйте позже.',
+        );
         //no line break will be inserted here
         $this->getDefaultHttpException('Sorry, an unexpected error occurred. Please try later.');

@TomasVotruba
Copy link
Member

I see, it seems valid. Feel free to add this feature with the test fixture you've provided 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants