- Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
This sniff is broken for \e
, \1
(etc.), and for \u
all of which are valid uses for double quotes.
Also, your composer.json
states a minimum PHP of 5.1.2
and then defines \v
and \f
as allowed characters which is not the case until PHP 5.2.5
. I'm not sure how one can test that sort of thing using your current testing framework.
An example:
---------------------------------------------------------------------- 33 | ERROR | [x] String "\e[0;32mPASS\e[0m" does not require | | double quotes; use single quotes instead ----------------------------------------------------------------------
and
---------------------------------------------------------------------- 3 | ERROR | [x] String "\1" does not require double quotes; use | | single quotes instead ----------------------------------------------------------------------
Btw., \e
has been available since 5.4.4
, and \u
since 7.0.0
.
Link to the manual: http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double
Probably changing the $allowedChars
array to this:
$allowedChars = array( '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7', '\n', '\r', '\t', '\x', '\b', '\'', ); if (phpversion() >= '5.2.5') { $allowedChars[] = '\v'; $allowedChars[] = '\f'; } if (phpversion() >= '5.4.4') { $allowedChars[] = '\e'; } if (phpversion() >= '7.0.0') { $allowedChars[] = '\u'; }
is best, but then how you go about testing that on different platforms with the current test framework is as said, impossible.