Php-cs-fixer: Line exceeds 120 characters; contains 168 characters

Created on 22 May 2017  Â·  14Comments  Â·  Source: FriendsOfPHP/PHP-CS-Fixer

I think I would like to have question for this.
Do this standard can apply for phpcs code checkstyle. because when I run on Jenkins it complains that Line exceeds 120 characters; contains 168 characters and I run php-cs-fixer cannot format my code that too long character.

I am using PHPStorm 2017.1, and I do not know php-cs-fixer have option to fix length of character.

kinfeature request

Most helpful comment

wow, php tokenizer in js. js got more crazy now :D

All 14 comments

Currently we have no fixer to limit the line length. It was proposed before (https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/180 and https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/1361).
I would welcome such fixer, although it would be hard to implement (and sometimes impossible, for example if a class name is more than 120 chars. long it cannot be fixed).

Could we at the very least give an error without trying to fix it? Since fixing is impossible anyway.

no. this tool is a fixer.
if you cannot fix sth to follow the rule, then either this is not a rule or you need to make it more precise to be always applicable

Came to the conclusion going over how fixers work exactly. Will fix this another way

It should be possible with reasonable coverage. Prettier is doing it. I don't think we have to cover 100% of cases. And we can start slowly with easy ones (breaking down arguments for functions, breaking down arrays etc).

@artursvonda That sounds like something I'd use. I'm working on fixer that handles function arguments: https://github.com/Symplify/Symplify/pull/533

Are you able to do one for the arrays?

We develop https://github.com/prettier/plugin-php, any help welcome :+1:

wow, php tokenizer in js. js got more crazy now :D

@keradus you can help us :smile:

my first step would be to switch to ts actually ;)
anyway, i must admit I don't see a need for me to create/maintain 2 tools doing the same, just in different lang. not even thinking about having time for that.

@keradus we don't do the same :smile:

Prettier is an opinionated code formatter.

I would say the very base idea is pretty much the same ;)
Anyway, while curious about it, I won't find time to contribute to it on regular basis...

@keradus difference - we respect line width and indent/tabs and don't do lint tasks and transformation, it is allow easy maintain and differentiate the responsibilities of each instrument. Anyway thanks for discussion and any help welcome :+1:

we also have a lot of reformatting, simply not that particular one ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ro0NL picture ro0NL  Â·  3Comments

carusogabriel picture carusogabriel  Â·  3Comments

kcloze picture kcloze  Â·  3Comments

BackEndTea picture BackEndTea  Â·  3Comments

Bilge picture Bilge  Â·  3Comments