Skip to content

Commit 56225bc

Browse files
committed
fix all warnings except TODO warnings
1 parent ac087ec commit 56225bc

File tree

21 files changed

+110
-17
lines changed

21 files changed

+110
-17
lines changed

lib/Cake/Console/Command/ConsoleShell.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ public function main($command = null) {
238238

239239
if ($this->_isValidModel($modelToCheck)) {
240240
$findCommand = "\$data = \$this->$command;";
241+
//@codingStandardsIgnoreStart
241242
@eval($findCommand);
243+
//@codingStandardsIgnoreEnd
242244

243245
if (is_array($data)) {
244246
foreach ($data as $idx => $results) {
@@ -294,7 +296,9 @@ public function main($command = null) {
294296
list($foo, $data) = explode("->save", $command);
295297
$data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data);
296298
$saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));";
299+
//@codingStandardsIgnoreStart
297300
@eval($saveCommand);
301+
//@codingStandardsIgnoreEnd
298302
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
299303
}
300304
break;
@@ -304,7 +308,9 @@ public function main($command = null) {
304308
if ($this->_isValidModel($modelToCheck)) {
305309
// Get the column info for this model
306310
$fieldsCommand = "\$data = \$this->{$modelToCheck}->getColumnTypes();";
311+
//@codingStandardsIgnoreStart
307312
@eval($fieldsCommand);
313+
//@codingStandardsIgnoreEnd
308314

309315
if (is_array($data)) {
310316
foreach ($data as $field => $type) {
@@ -326,7 +332,9 @@ public function main($command = null) {
326332
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
327333
break;
328334
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
335+
//@codingStandardsIgnoreStart
329336
if ($url = eval('return array' . $tmp[1] . ';')) {
337+
//@codingStandardsIgnoreEnd
330338
$this->out(Router::url($url));
331339
}
332340
break;
@@ -362,7 +370,9 @@ protected function _loadRoutes() {
362370
Router::reload();
363371
extract(Router::getNamedExpressions());
364372

373+
//@codingStandardsIgnoreStart
365374
if (!@include APP . 'Config' . DS . 'routes.php') {
375+
//@codingStandardsIgnoreEnd
366376
return false;
367377
}
368378
CakePlugin::routes();

lib/Cake/Console/Shell.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,9 @@ public function createFile($path, $contents) {
686686
protected function _checkUnitTest() {
687687
if (class_exists('PHPUnit_Framework_TestCase')) {
688688
return true;
689+
//@codingStandardsIgnoreStart
689690
} elseif (@include 'PHPUnit' . DS . 'Autoload.php') {
691+
//@codingStandardsIgnoreEnd
690692
return true;
691693
} elseif (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) {
692694
return true;

lib/Cake/Error/exceptions.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,11 @@ class MissingControllerException extends CakeException {
224224

225225
protected $_messageTemplate = 'Controller class %s could not be found.';
226226

227+
//@codingStandardsIgnoreStart
227228
public function __construct($message, $code = 404) {
228229
parent::__construct($message, $code);
229230
}
231+
//@codingStandardsIgnoreEnd
230232

231233
}
232234

@@ -240,9 +242,11 @@ class MissingActionException extends CakeException {
240242

241243
protected $_messageTemplate = 'Action %s::%s() could not be found.';
242244

245+
//@codingStandardsIgnoreStart
243246
public function __construct($message, $code = 404) {
244247
parent::__construct($message, $code);
245248
}
249+
//@codingStandardsIgnoreEnd
246250

247251
}
248252

@@ -256,9 +260,11 @@ class PrivateActionException extends CakeException {
256260

257261
protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
258262

263+
//@codingStandardsIgnoreStart
259264
public function __construct($message, $code = 404, Exception $previous = null) {
260265
parent::__construct($message, $code, $previous);
261266
}
267+
//@codingStandardsIgnoreEnd
262268

263269
}
264270

@@ -572,8 +578,10 @@ class NotImplementedException extends CakeException {
572578

573579
protected $_messageTemplate = '%s is not implemented.';
574580

581+
//@codingStandardsIgnoreStart
575582
public function __construct($message, $code = 501) {
576583
parent::__construct($message, $code);
577584
}
585+
//@codingStandardsIgnoreEnd
578586

579587
}

lib/Cake/Model/Datasource/Database/Sqlite.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ public function column($real) {
249249

250250
$col = strtolower(str_replace(')', '', $real));
251251
$limit = null;
252-
@list($col, $limit) = explode('(', $col);
252+
if (strpos($col, '(') !== false) {
253+
list($col, $limit) = explode('(', $col);
254+
}
253255

254256
if (in_array($col, array('text', 'integer', 'float', 'boolean', 'timestamp', 'date', 'datetime', 'time'))) {
255257
return $col;

lib/Cake/Network/CakeSocket.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ public function connect() {
105105
$scheme = 'ssl://';
106106
}
107107

108+
//@codingStandardsIgnoreStart
108109
if ($this->config['persistent'] == true) {
109110
$this->connection = @pfsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
110111
} else {
111112
$this->connection = @fsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
112113
}
114+
//@codingStandardsIgnoreEnd
113115

114116
if (!empty($errNum) || !empty($errStr)) {
115117
$this->setLastError($errNum, $errStr);

lib/Cake/Network/Email/MailTransport.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ public function send(CakeEmail $email) {
6363
* @return void
6464
*/
6565
protected function _mail($to, $subject, $message, $headers, $params = null) {
66+
//@codingStandardsIgnoreStart
6667
if (!@mail($to, $subject, $message, $headers, $params)) {
6768
throw new SocketException(__d('cake_dev', 'Could not send email.'));
6869
}
70+
//@codingStandardsIgnoreEnd
6971
}
7072

7173
}

lib/Cake/Test/Case/BasicsTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ public function testCache() {
282282

283283
$result = cache('basics_test');
284284
$this->assertEquals('simple cache write', $result);
285-
@unlink(CACHE . 'basics_test');
285+
if (file_exists(CACHE . 'basics_test')) {
286+
unlink(CACHE . 'basics_test');
287+
}
286288

287289
cache('basics_test', 'expired', '+1 second');
288290
sleep(2);
@@ -603,7 +605,9 @@ public function testTranslateDomainCategoryPlural() {
603605
* @return void
604606
*/
605607
public function testLogError() {
606-
@unlink(LOGS . 'error.log');
608+
if (file_exists(LOGS . 'error.log')) {
609+
unlink(LOGS . 'error.log');
610+
}
607611

608612
// disable stderr output for this test
609613
if (CakeLog::stream('stderr')) {

lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ public function testMultipleServers() {
111111

112112
foreach ($servers as $server) {
113113
list($host, $port) = explode(':', $server);
114+
//@codingStandardsIgnoreStart
114115
if (!@$Memcache->connect($host, $port)) {
115116
$available = false;
116117
}
118+
//@codingStandardsIgnoreEnd
117119
}
118120

119121
$this->skipIf(!$available, 'Need memcache servers at ' . implode(', ', $servers) . ' to run this test.');

lib/Cake/Test/Case/Core/ConfigureTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ public function testDump() {
383383
$result = file_get_contents(TMP . 'config_test.php');
384384
$this->assertContains('<?php', $result);
385385
$this->assertContains('$config = ', $result);
386-
@unlink(TMP . 'config_test.php');
386+
if (file_exists(TMP . 'config_test.php')) {
387+
unlink(TMP . 'config_test.php');
388+
}
387389
}
388390

389391
/**
@@ -402,7 +404,9 @@ public function testDumpPartial() {
402404
$this->assertContains('Error', $result);
403405
$this->assertNotContains('debug', $result);
404406

405-
@unlink(TMP . 'config_test.php');
407+
if (file_exists(TMP . 'config_test.php')) {
408+
unlink(TMP . 'config_test.php');
409+
}
406410
}
407411

408412
}

lib/Cake/Test/Case/Error/ErrorHandlerTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ public function testErrorSuppressed() {
124124
$this->_restoreError = true;
125125

126126
ob_start();
127+
//@codingStandardsIgnoreStart
127128
@include 'invalid.file';
129+
//@codingStandardsIgnoreEnd
128130
$result = ob_get_clean();
129131
$this->assertTrue(empty($result));
130132
}
@@ -138,7 +140,7 @@ public function testHandleErrorDebugOff() {
138140
Configure::write('debug', 0);
139141
Configure::write('Error.trace', false);
140142
if (file_exists(LOGS . 'debug.log')) {
141-
@unlink(LOGS . 'debug.log');
143+
unlink(LOGS . 'debug.log');
142144
}
143145

144146
set_error_handler('ErrorHandler::handleError');
@@ -152,7 +154,9 @@ public function testHandleErrorDebugOff() {
152154
'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (Notice|Debug): Notice \(8\): Undefined variable:\s+out in \[.+ line \d+\]$/',
153155
$result[0]
154156
);
155-
@unlink(LOGS . 'debug.log');
157+
if (file_exists(LOGS . 'debug.log')) {
158+
unlink(LOGS . 'debug.log');
159+
}
156160
}
157161

158162
/**
@@ -164,7 +168,7 @@ public function testHandleErrorLoggingTrace() {
164168
Configure::write('debug', 0);
165169
Configure::write('Error.trace', true);
166170
if (file_exists(LOGS . 'debug.log')) {
167-
@unlink(LOGS . 'debug.log');
171+
unlink(LOGS . 'debug.log');
168172
}
169173

170174
set_error_handler('ErrorHandler::handleError');
@@ -179,7 +183,9 @@ public function testHandleErrorLoggingTrace() {
179183
);
180184
$this->assertRegExp('/^Trace:/', $result[1]);
181185
$this->assertRegExp('/^ErrorHandlerTest\:\:testHandleErrorLoggingTrace\(\)/', $result[2]);
182-
@unlink(LOGS . 'debug.log');
186+
if (file_exists(LOGS . 'debug.log')) {
187+
unlink(LOGS . 'debug.log');
188+
}
183189
}
184190

185191
/**

lib/Cake/Test/Case/Log/CakeLogTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testConfig() {
150150
$this->assertEquals(array('file'), $result);
151151

152152
if (file_exists(LOGS . 'error.log')) {
153-
@unlink(LOGS . 'error.log');
153+
unlink(LOGS . 'error.log');
154154
}
155155
CakeLog::write(LOG_WARNING, 'Test warning');
156156
$this->assertTrue(file_exists(LOGS . 'error.log'));

lib/Cake/Test/Case/View/Helper/JsHelperTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ class JsEncodingObject {
2929

3030
protected $_title = 'Old thing';
3131

32+
//@codingStandardsIgnoreStart
3233
private $__noshow = 'Never ever';
34+
//@codingStandardsIgnoreEnd
3335

3436
}
3537

@@ -366,7 +368,9 @@ public function testWriteScriptsInFile() {
366368
$this->assertTrue(file_exists(WWW_ROOT . $filename[1]));
367369
$contents = file_get_contents(WWW_ROOT . $filename[1]);
368370
$this->assertRegExp('/one\s=\s1;\ntwo\s=\s2;/', $contents);
369-
@unlink(WWW_ROOT . $filename[1]);
371+
if (file_exists(WWW_ROOT . $filename[1])) {
372+
unlink(WWW_ROOT . $filename[1]);
373+
}
370374

371375
Configure::write('Cache.disable', true);
372376
$this->Js->buffer('one = 1;');

lib/Cake/Test/Case/View/ViewTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,9 @@ public function testRenderCache() {
11011101

11021102
$this->assertRegExp('/^some cacheText/', $result);
11031103

1104-
@unlink($path);
1104+
if (file_exists($path)) {
1105+
unlink($path);
1106+
}
11051107
}
11061108

11071109
/**

lib/Cake/TestSuite/CakeTestSuiteCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ public function run(array $argv, $exit = true) {
8282
$result = $skeleton->generate(true);
8383

8484
if (!$result['incomplete']) {
85+
//@codingStandardsIgnoreStart
8586
eval(str_replace(array('<?php', '?>'), '', $result['code']));
87+
//@codingStandardsIgnoreEnd
8688
$suite = new PHPUnit_Framework_TestSuite(
8789
$this->arguments['test'] . 'Test'
8890
);

lib/Cake/TestSuite/ControllerTestCase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ abstract class ControllerTestCase extends CakeTestCase {
173173
*
174174
* @var boolean
175175
*/
176-
private $__dirtyController = false;
176+
protected $_dirtyController = false;
177177

178178
/**
179179
* Used to enable calling ControllerTestCase::testAction() without the testing
@@ -252,7 +252,7 @@ protected function _testAction($url = '', $options = array()) {
252252
$this->headers = Router::currentRoute()->response->header();
253253
return;
254254
}
255-
if ($this->__dirtyController) {
255+
if ($this->_dirtyController) {
256256
$this->controller = null;
257257
}
258258

@@ -275,7 +275,7 @@ protected function _testAction($url = '', $options = array()) {
275275
if (isset($this->controller->View)) {
276276
$this->view = $this->controller->View->fetch('__view_no_layout__');
277277
}
278-
$this->__dirtyController = true;
278+
$this->_dirtyController = true;
279279
$this->headers = $Dispatch->response->header();
280280

281281
$_GET = $restore['get'];
@@ -371,7 +371,7 @@ public function generate($controller, $mocks = array()) {
371371
}
372372

373373
$_controller->constructClasses();
374-
$this->__dirtyController = false;
374+
$this->_dirtyController = false;
375375

376376
$this->controller = $_controller;
377377
return $this->controller;

lib/Cake/Utility/Debugger.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,10 @@ public static function excerpt($file, $line, $context = 2) {
395395
if (!file_exists($file)) {
396396
return array();
397397
}
398-
$data = @explode("\n", file_get_contents($file));
398+
$data = file_get_contents($file);
399+
if (!empty($data) && strpos($data, "\n") !== false) {
400+
$data = explode("\n", $data);
401+
}
399402

400403
if (empty($data) || !isset($data[$line])) {
401404
return;

0 commit comments

Comments
 (0)