diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index d8c79c9338f..31736bbdd91 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -238,7 +238,9 @@ public function main($command = null) { if ($this->_isValidModel($modelToCheck)) { $findCommand = "\$data = \$this->$command;"; + //@codingStandardsIgnoreStart @eval($findCommand); + //@codingStandardsIgnoreEnd if (is_array($data)) { foreach ($data as $idx => $results) { @@ -294,7 +296,9 @@ public function main($command = null) { list($foo, $data) = explode("->save", $command); $data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data); $saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));"; + //@codingStandardsIgnoreStart @eval($saveCommand); + //@codingStandardsIgnoreEnd $this->out(__d('cake_console', 'Saved record for %s', $modelToSave)); } break; @@ -304,7 +308,9 @@ public function main($command = null) { if ($this->_isValidModel($modelToCheck)) { // Get the column info for this model $fieldsCommand = "\$data = \$this->{$modelToCheck}->getColumnTypes();"; + //@codingStandardsIgnoreStart @eval($fieldsCommand); + //@codingStandardsIgnoreEnd if (is_array($data)) { foreach ($data as $field => $type) { @@ -326,7 +332,9 @@ public function main($command = null) { $this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true)); break; case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true): + //@codingStandardsIgnoreStart if ($url = eval('return array' . $tmp[1] . ';')) { + //@codingStandardsIgnoreEnd $this->out(Router::url($url)); } break; @@ -362,7 +370,9 @@ protected function _loadRoutes() { Router::reload(); extract(Router::getNamedExpressions()); + //@codingStandardsIgnoreStart if (!@include APP . 'Config' . DS . 'routes.php') { + //@codingStandardsIgnoreEnd return false; } CakePlugin::routes(); diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 74e5e033be4..bf4f1887751 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -686,7 +686,9 @@ public function createFile($path, $contents) { protected function _checkUnitTest() { if (class_exists('PHPUnit_Framework_TestCase')) { return true; + //@codingStandardsIgnoreStart } elseif (@include 'PHPUnit' . DS . 'Autoload.php') { + //@codingStandardsIgnoreEnd return true; } elseif (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) { return true; diff --git a/lib/Cake/Error/exceptions.php b/lib/Cake/Error/exceptions.php index 94952f12e4f..4f0fe984329 100644 --- a/lib/Cake/Error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -224,9 +224,11 @@ class MissingControllerException extends CakeException { protected $_messageTemplate = 'Controller class %s could not be found.'; +//@codingStandardsIgnoreStart public function __construct($message, $code = 404) { parent::__construct($message, $code); } +//@codingStandardsIgnoreEnd } @@ -240,9 +242,11 @@ class MissingActionException extends CakeException { protected $_messageTemplate = 'Action %s::%s() could not be found.'; +//@codingStandardsIgnoreStart public function __construct($message, $code = 404) { parent::__construct($message, $code); } +//@codingStandardsIgnoreEnd } @@ -256,9 +260,11 @@ class PrivateActionException extends CakeException { protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.'; +//@codingStandardsIgnoreStart public function __construct($message, $code = 404, Exception $previous = null) { parent::__construct($message, $code, $previous); } +//@codingStandardsIgnoreEnd } @@ -572,8 +578,10 @@ class NotImplementedException extends CakeException { protected $_messageTemplate = '%s is not implemented.'; +//@codingStandardsIgnoreStart public function __construct($message, $code = 501) { parent::__construct($message, $code); } +//@codingStandardsIgnoreEnd } diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index d30cc67dfdf..0990e4a3cae 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -249,7 +249,9 @@ public function column($real) { $col = strtolower(str_replace(')', '', $real)); $limit = null; - @list($col, $limit) = explode('(', $col); + if (strpos($col, '(') !== false) { + list($col, $limit) = explode('(', $col); + } if (in_array($col, array('text', 'integer', 'float', 'boolean', 'timestamp', 'date', 'datetime', 'time'))) { return $col; diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index aa0eb4fbd43..37fc02e5059 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -105,11 +105,13 @@ public function connect() { $scheme = 'ssl://'; } + //@codingStandardsIgnoreStart if ($this->config['persistent'] == true) { $this->connection = @pfsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); } else { $this->connection = @fsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); } + //@codingStandardsIgnoreEnd if (!empty($errNum) || !empty($errStr)) { $this->setLastError($errNum, $errStr); diff --git a/lib/Cake/Network/Email/MailTransport.php b/lib/Cake/Network/Email/MailTransport.php index 2b849772ac0..a037e3418fc 100644 --- a/lib/Cake/Network/Email/MailTransport.php +++ b/lib/Cake/Network/Email/MailTransport.php @@ -63,9 +63,11 @@ public function send(CakeEmail $email) { * @return void */ protected function _mail($to, $subject, $message, $headers, $params = null) { + //@codingStandardsIgnoreStart if (!@mail($to, $subject, $message, $headers, $params)) { throw new SocketException(__d('cake_dev', 'Could not send email.')); } + //@codingStandardsIgnoreEnd } } diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index 0998dfa7709..10dd24cf472 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -282,7 +282,9 @@ public function testCache() { $result = cache('basics_test'); $this->assertEquals('simple cache write', $result); - @unlink(CACHE . 'basics_test'); + if (file_exists(CACHE . 'basics_test')) { + unlink(CACHE . 'basics_test'); + } cache('basics_test', 'expired', '+1 second'); sleep(2); @@ -603,7 +605,9 @@ public function testTranslateDomainCategoryPlural() { * @return void */ public function testLogError() { - @unlink(LOGS . 'error.log'); + if (file_exists(LOGS . 'error.log')) { + unlink(LOGS . 'error.log'); + } // disable stderr output for this test if (CakeLog::stream('stderr')) { diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php index 54c225c7298..27453d84e8c 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php @@ -111,9 +111,11 @@ public function testMultipleServers() { foreach ($servers as $server) { list($host, $port) = explode(':', $server); + //@codingStandardsIgnoreStart if (!@$Memcache->connect($host, $port)) { $available = false; } + //@codingStandardsIgnoreEnd } $this->skipIf(!$available, 'Need memcache servers at ' . implode(', ', $servers) . ' to run this test.'); diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index 7351f83f199..224e7b5e954 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -383,7 +383,9 @@ public function testDump() { $result = file_get_contents(TMP . 'config_test.php'); $this->assertContains('assertContains('$config = ', $result); - @unlink(TMP . 'config_test.php'); + if (file_exists(TMP . 'config_test.php')) { + unlink(TMP . 'config_test.php'); + } } /** @@ -402,7 +404,9 @@ public function testDumpPartial() { $this->assertContains('Error', $result); $this->assertNotContains('debug', $result); - @unlink(TMP . 'config_test.php'); + if (file_exists(TMP . 'config_test.php')) { + unlink(TMP . 'config_test.php'); + } } } diff --git a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php index e4bd5790201..4945533ff5c 100644 --- a/lib/Cake/Test/Case/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Error/ErrorHandlerTest.php @@ -124,7 +124,9 @@ public function testErrorSuppressed() { $this->_restoreError = true; ob_start(); + //@codingStandardsIgnoreStart @include 'invalid.file'; + //@codingStandardsIgnoreEnd $result = ob_get_clean(); $this->assertTrue(empty($result)); } @@ -138,7 +140,7 @@ public function testHandleErrorDebugOff() { Configure::write('debug', 0); Configure::write('Error.trace', false); if (file_exists(LOGS . 'debug.log')) { - @unlink(LOGS . 'debug.log'); + unlink(LOGS . 'debug.log'); } set_error_handler('ErrorHandler::handleError'); @@ -152,7 +154,9 @@ public function testHandleErrorDebugOff() { '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (Notice|Debug): Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/', $result[0] ); - @unlink(LOGS . 'debug.log'); + if (file_exists(LOGS . 'debug.log')) { + unlink(LOGS . 'debug.log'); + } } /** @@ -164,7 +168,7 @@ public function testHandleErrorLoggingTrace() { Configure::write('debug', 0); Configure::write('Error.trace', true); if (file_exists(LOGS . 'debug.log')) { - @unlink(LOGS . 'debug.log'); + unlink(LOGS . 'debug.log'); } set_error_handler('ErrorHandler::handleError'); @@ -179,7 +183,9 @@ public function testHandleErrorLoggingTrace() { ); $this->assertRegExp('/^Trace:/', $result[1]); $this->assertRegExp('/^ErrorHandlerTest\:\:testHandleErrorLoggingTrace\(\)/', $result[2]); - @unlink(LOGS . 'debug.log'); + if (file_exists(LOGS . 'debug.log')) { + unlink(LOGS . 'debug.log'); + } } /** diff --git a/lib/Cake/Test/Case/Log/CakeLogTest.php b/lib/Cake/Test/Case/Log/CakeLogTest.php index 1226dde7eb3..13d90989f7c 100644 --- a/lib/Cake/Test/Case/Log/CakeLogTest.php +++ b/lib/Cake/Test/Case/Log/CakeLogTest.php @@ -150,7 +150,7 @@ public function testConfig() { $this->assertEquals(array('file'), $result); if (file_exists(LOGS . 'error.log')) { - @unlink(LOGS . 'error.log'); + unlink(LOGS . 'error.log'); } CakeLog::write(LOG_WARNING, 'Test warning'); $this->assertTrue(file_exists(LOGS . 'error.log')); diff --git a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php index 47833e0859c..53b8cce9708 100644 --- a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php @@ -29,7 +29,9 @@ class JsEncodingObject { protected $_title = 'Old thing'; + //@codingStandardsIgnoreStart private $__noshow = 'Never ever'; + //@codingStandardsIgnoreEnd } @@ -366,7 +368,9 @@ public function testWriteScriptsInFile() { $this->assertTrue(file_exists(WWW_ROOT . $filename[1])); $contents = file_get_contents(WWW_ROOT . $filename[1]); $this->assertRegExp('/one\s=\s1;\ntwo\s=\s2;/', $contents); - @unlink(WWW_ROOT . $filename[1]); + if (file_exists(WWW_ROOT . $filename[1])) { + unlink(WWW_ROOT . $filename[1]); + } Configure::write('Cache.disable', true); $this->Js->buffer('one = 1;'); diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index 75875349d7d..ffcbb3ef96b 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -1101,7 +1101,9 @@ public function testRenderCache() { $this->assertRegExp('/^some cacheText/', $result); - @unlink($path); + if (file_exists($path)) { + unlink($path); + } } /** diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 6d410ec7979..f655c7fda76 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -82,7 +82,9 @@ public function run(array $argv, $exit = true) { $result = $skeleton->generate(true); if (!$result['incomplete']) { + //@codingStandardsIgnoreStart eval(str_replace(array(''), '', $result['code'])); + //@codingStandardsIgnoreEnd $suite = new PHPUnit_Framework_TestSuite( $this->arguments['test'] . 'Test' ); diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index d989553f7e8..fd44b8cb5be 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -173,7 +173,7 @@ abstract class ControllerTestCase extends CakeTestCase { * * @var boolean */ - private $__dirtyController = false; + protected $_dirtyController = false; /** * Used to enable calling ControllerTestCase::testAction() without the testing @@ -252,7 +252,7 @@ protected function _testAction($url = '', $options = array()) { $this->headers = Router::currentRoute()->response->header(); return; } - if ($this->__dirtyController) { + if ($this->_dirtyController) { $this->controller = null; } @@ -275,7 +275,7 @@ protected function _testAction($url = '', $options = array()) { if (isset($this->controller->View)) { $this->view = $this->controller->View->fetch('__view_no_layout__'); } - $this->__dirtyController = true; + $this->_dirtyController = true; $this->headers = $Dispatch->response->header(); $_GET = $restore['get']; @@ -371,7 +371,7 @@ public function generate($controller, $mocks = array()) { } $_controller->constructClasses(); - $this->__dirtyController = false; + $this->_dirtyController = false; $this->controller = $_controller; return $this->controller; diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 7c6b2ba1221..0fe8a384b29 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -395,7 +395,10 @@ public static function excerpt($file, $line, $context = 2) { if (!file_exists($file)) { return array(); } - $data = @explode("\n", file_get_contents($file)); + $data = file_get_contents($file); + if (!empty($data) && strpos($data, "\n") !== false) { + $data = explode("\n", $data); + } if (empty($data) || !isset($data[$line])) { return; diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index bda4858695d..c673177abea 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -354,7 +354,9 @@ public function chmod($path, $mode = false, $recursive = true, $exceptions = arr } if ($recursive === false && is_dir($path)) { + //@codingStandardsIgnoreStart if (@chmod($path, intval($mode, 8))) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $path, $mode); return true; } @@ -375,7 +377,9 @@ public function chmod($path, $mode = false, $recursive = true, $exceptions = arr continue; } + //@codingStandardsIgnoreStart if (@chmod($fullpath, intval($mode, 8))) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s changed to %s', $fullpath, $mode); } else { $this->_errors[] = __d('cake_dev', '%s NOT changed to %s', $fullpath, $mode); @@ -559,13 +563,17 @@ public function delete($path = null) { foreach ($iterator as $item) { $filePath = $item->getPathname(); if ($item->isFile() || $item->isLink()) { + //@codingStandardsIgnoreStart if (@unlink($filePath)) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s removed', $filePath); } else { $this->_errors[] = __d('cake_dev', '%s NOT removed', $filePath); } } elseif ($item->isDir() && !$item->isDot()) { + //@codingStandardsIgnoreStart if (@rmdir($filePath)) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s removed', $filePath); } else { $this->_errors[] = __d('cake_dev', '%s NOT removed', $filePath); @@ -575,7 +583,9 @@ public function delete($path = null) { } $path = rtrim($path, DS); + //@codingStandardsIgnoreStart if (@rmdir($path)) { + //@codingStandardsIgnoreEnd $this->_messages[] = __d('cake_dev', '%s removed', $path); } else { $this->_errors[] = __d('cake_dev', '%s NOT removed', $path); @@ -629,7 +639,9 @@ public function copy($options = array()) { } $exceptions = array_merge(array('.', '..', '.svn'), $options['skip']); + //@codingStandardsIgnoreStart if ($handle = @opendir($fromDir)) { + //@codingStandardsIgnoreEnd while (false !== ($item = readdir($handle))) { if (!in_array($item, $exceptions)) { $from = Folder::addPathElement($fromDir, $item); diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index bb16ec6d583..1ab88dad609 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -340,20 +340,26 @@ public function assetTimestamp($path) { $filepath = preg_replace('/^' . preg_quote($this->request->webroot, '/') . '/', '', $path); $webrootPath = WWW_ROOT . str_replace('/', DS, $filepath); if (file_exists($webrootPath)) { + //@codingStandardsIgnoreStart return $path . '?' . @filemtime($webrootPath); + //@codingStandardsIgnoreEnd } $segments = explode('/', ltrim($filepath, '/')); if ($segments[0] === 'theme') { $theme = $segments[1]; unset($segments[0], $segments[1]); $themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments); + //@codingStandardsIgnoreStart return $path . '?' . @filemtime($themePath); + //@codingStandardsIgnoreEnd } else { $plugin = Inflector::camelize($segments[0]); if (CakePlugin::loaded($plugin)) { unset($segments[0]); $pluginPath = CakePlugin::path($plugin) . 'webroot' . DS . implode(DS, $segments); + //@codingStandardsIgnoreStart return $path . '?' . @filemtime($pluginPath); + //@codingStandardsIgnoreEnd } } } diff --git a/lib/Cake/View/MediaView.php b/lib/Cake/View/MediaView.php index 9dec162f05b..8ed331837c5 100644 --- a/lib/Cake/View/MediaView.php +++ b/lib/Cake/View/MediaView.php @@ -101,7 +101,9 @@ public function render($view = null, $layout = null) { if ($this->_isActive()) { $extension = strtolower($extension); + //@codingStandardsIgnoreStart $fileSize = @filesize($path); + //@codingStandardsIgnoreEnd $handle = fopen($path, 'rb'); if ($handle === false) { @@ -220,7 +222,9 @@ protected function _isActive() { * @return boolean */ protected function _clearBuffer() { + //@codingStandardsIgnoreStart return @ob_end_clean(); + //@codingStandardsIgnoreEnd } /** @@ -229,8 +233,10 @@ protected function _clearBuffer() { * @return void */ protected function _flushBuffer() { + //@codingStandardsIgnoreStart @flush(); @ob_flush(); + //@codingStandardsIgnoreEnd } } diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index aedddd90f97..881f2485b0e 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -562,7 +562,9 @@ public function renderCache($filename, $timeStart) { if (preg_match('/^/', $out, $match)) { if (time() >= $match['1']) { + //@codingStandardsIgnoreStart @unlink($filename); + //@codingStandardsIgnoreEnd unset ($out); return false; } else { diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 1dc81245e83..4f7c945f6c5 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -397,19 +397,27 @@ function cache($path, $data = null, $expires = '+1 day', $target = 'cache') { $filetime = false; if (file_exists($filename)) { + //@codingStandardsIgnoreStart $filetime = @filemtime($filename); + //@codingStandardsIgnoreEnd } if ($data === null) { if (file_exists($filename) && $filetime !== false) { if ($filetime + $timediff < $now) { + //@codingStandardsIgnoreStart @unlink($filename); + //@codingStandardsIgnoreEnd } else { + //@codingStandardsIgnoreStart $data = @file_get_contents($filename); + //@codingStandardsIgnoreEnd } } } elseif (is_writable(dirname($filename))) { + //@codingStandardsIgnoreStart @file_put_contents($filename, $data, LOCK_EX); + //@codingStandardsIgnoreEnd } return $data; } @@ -430,7 +438,9 @@ function clearCache($params = null, $type = 'views', $ext = '.php') { $cache = CACHE . $type . DS . $params; if (is_file($cache . $ext)) { + //@codingStandardsIgnoreStart @unlink($cache . $ext); + //@codingStandardsIgnoreEnd return true; } elseif (is_dir($cache)) { $files = glob($cache . '*'); @@ -441,7 +451,9 @@ function clearCache($params = null, $type = 'views', $ext = '.php') { foreach ($files as $file) { if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { + //@codingStandardsIgnoreStart @unlink($file); + //@codingStandardsIgnoreEnd } } return true; @@ -462,7 +474,9 @@ function clearCache($params = null, $type = 'views', $ext = '.php') { } foreach ($files as $file) { if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) { + //@codingStandardsIgnoreStart @unlink($file); + //@codingStandardsIgnoreEnd } } return true;