PHPCSExtra icon indicating copy to clipboard operation
PHPCSExtra copied to clipboard

Sniff to detect the irregular whitespace characters

Open dingo-d opened this issue 2 years ago • 3 comments
trafficstars

Originally created in the WPCS repo

Motivation

The motivation behind the sniff was that I got errors in my php code, and I couldn't see where the errors were coming from, unless I highlighted the code in the editor (Sublime), where I could see that there is not a dot in my space.

So this sniff would detect these irregular white spaces in the code and warn the user not to use them.

dingo-d avatar Dec 09 '22 15:12 dingo-d

For this ticket to be actionable, it will need a list of what is considered an "irregular whitespace character".

Without that, there's nothing which can be done.

jrfnl avatar Jan 09 '23 16:01 jrfnl

The inspiration for the sniff comes from ESLint: https://eslint.org/docs/latest/rules/no-irregular-whitespace

There's also the following list: https://invisible-characters.com/

I have copied some of the characters in a test file and ran it through the phpcsdebug standard and I get things like

image image

dingo-d avatar Jan 09 '23 19:01 dingo-d

Thanks for adding that additional info!

jrfnl avatar Jan 09 '23 21:01 jrfnl