cvs: pear /PHP_CodeSniffer CodeSniffer.php
| From: | Greg Sherwood | Date: | Tue, 18 Sep 2007 06:23:09 +0000 |
| Subject: | cvs: pear /PHP_CodeSniffer CodeSniffer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-48623@lists.php.net to get a copy of this message | ||
squiz Tue Sep 18 06:23:09 2007 UTC
Modified files:
/pear/PHP_CodeSniffer CodeSniffer.php
Log:
Added a couple of checks to make sure the config file can be written. Also muting errors from
autoload's default include to PEAR_Exception does not throw errors checking for PEAR_Error.
http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer.php?r1=1.42&r2=1.43&diff_format=u
Index: pear/PHP_CodeSniffer/CodeSniffer.php
diff -u pear/PHP_CodeSniffer/CodeSniffer.php:1.42 pear/PHP_CodeSniffer/CodeSniffer.php:1.43
--- pear/PHP_CodeSniffer/CodeSniffer.php:1.42 Tue Sep 18 00:43:22 2007
+++ pear/PHP_CodeSniffer/CodeSniffer.php Tue Sep 18 06:23:09 2007
@@ -11,7 +11,7 @@
* @author Marc McIntyre <mmcintyre@squiz.net>
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
* @license http://matrix.squiz.net/developer/tools/php_cs/licence
BSD Licence
- * @version CVS: $Id: CodeSniffer.php,v 1.42 2007/09/18 00:43:22 squiz Exp $
+ * @version CVS: $Id: CodeSniffer.php,v 1.43 2007/09/18 06:23:09 squiz Exp $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
@@ -163,7 +163,7 @@
include dirname(__FILE__).'/CodeSniffer/Standards/'.$path;
} else {
// Everything else.
- include $path;
+ @include $path;
}
}//end autoload()
@@ -235,7 +235,7 @@
$this->files = array();
if (PHP_CODESNIFFER_VERBOSITY > 0) {
- echo 'Registering sniffs... ';
+ echo "Registering sniffs in $standard standard... ";
if (PHP_CODESNIFFER_VERBOSITY > 2) {
echo PHP_EOL;
}
@@ -1332,6 +1332,7 @@
*
* @return boolean
* @see getConfigData()
+ * @throws PHP_CodeSniffer_Exception If the config file can not be written.
*/
public static function setConfigData($key, $value)
{
@@ -1340,6 +1341,14 @@
$configFile = '@data_dir@/PHP_CodeSniffer/data/CodeSniffer.conf';
}
+ if (is_file($configFile) === false) {
+ throw new PHP_CodeSniffer_Exception("Config file $configFile does not
exist");
+ }
+
+ if (is_writable($configFile) === false) {
+ throw new PHP_CodeSniffer_Exception("Config file $configFile is not
writable");
+ }
+
$phpCodeSnifferConfig = self::getAllConfigData();
$phpCodeSnifferConfig[$key] = $value;