Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.1

Request #20314 Throw exception, when iconv module is absent
Submitted: 2014-06-26 03:10 UTC
From: aik099 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.3)
PHP Version: 5.4.20 OS: Linux
Roadmaps: (Not assigned)    

 [2014-06-26 03:10 UTC] aik099 (Alexander Obuhovich)
Description: ------------ The "LineLengthSniff.php" sniff is using "iconv_strlen" function, which isn't available when iconv module was disabled during PHP compilation. I propose that we add a check in that sniff constructor (or at file top) and throw an exception when iconv module is disabled. Optionally we can fallback to "mb_strlen" (when present).


 [2014-07-02 07:49 UTC] squiz (Greg Sherwood)
-Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: squiz
Firstly, the only time the iconv module is used is when encoding has been specified on the command line. Just want to be clear in case anyone is reading this and thinks it is a core requirement. The way I typically handle these sort of error cases is to inject warnings into the error reports so they are also seem when using automated tools or text editor plugins. So I've done the same thing this time. Hopefully this is clear enough: FILE: CodeSniffer.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 1 | WARNING | Line length could not be checked in this file as the iconv | | module has been disabled in PHP -------------------------------------------------------------------------------- Commit is here: 1b280160534b0a631
 [2014-07-02 07:49 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed