Skip to content

Commit 9d325fe

Browse files
committed
Fixing most coding standard issues in Utility/
1 parent acccdcd commit 9d325fe

File tree

13 files changed

+58
-65
lines changed

13 files changed

+58
-65
lines changed

lib/Cake/Utility/CakeNumber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ public static function currency($number, $currency = 'USD', $options = array())
206206
}
207207
}
208208

209-
$position = $options[$symbolKey.'Position'] != 'after' ? 'before' : 'after';
210-
$options[$position] = $options[$symbolKey.'Symbol'];
209+
$position = $options[$symbolKey . 'Position'] != 'after' ? 'before' : 'after';
210+
$options[$position] = $options[$symbolKey . 'Symbol'];
211211

212212
$abs = abs($number);
213213
$result = self::format($abs, $options);
214214

215215
if ($number < 0 ) {
216216
if ($options['negative'] == '()') {
217-
$result = '(' . $result .')';
217+
$result = '(' . $result . ')';
218218
} else {
219219
$result = $options['negative'] . $result;
220220
}

lib/Cake/Utility/CakeTime.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ class CakeTime {
5252
*/
5353
public function __set($name, $value) {
5454
switch ($name) {
55-
case 'niceFormat':
56-
self::${$name} = $value;
57-
break;
58-
default:
59-
break;
55+
case 'niceFormat':
56+
self::${$name} = $value;
57+
break;
58+
default:
59+
break;
6060
}
6161
}
6262

@@ -67,12 +67,12 @@ public function __set($name, $value) {
6767
*/
6868
public function __get($name) {
6969
switch ($name) {
70-
case 'niceFormat':
71-
return self::${$name};
72-
break;
73-
default:
74-
return null;
75-
break;
70+
case 'niceFormat':
71+
return self::${$name};
72+
break;
73+
default:
74+
return null;
75+
break;
7676
}
7777
}
7878

@@ -140,13 +140,13 @@ protected static function _translateSpecifier($specifier) {
140140
case 'h':
141141
$months = __dc('cake', 'abmon', 5);
142142
if (is_array($months)) {
143-
return $months[date('n', self::$_time) -1];
143+
return $months[date('n', self::$_time) - 1];
144144
}
145145
return '%b';
146146
case 'B':
147147
$months = __dc('cake', 'mon', 5);
148148
if (is_array($months)) {
149-
return $months[date('n', self::$_time) -1];
149+
return $months[date('n', self::$_time) - 1];
150150
}
151151
break;
152152
case 'n':
@@ -202,7 +202,7 @@ protected static function _translateSpecifier($specifier) {
202202
public static function convert($serverTime, $userOffset) {
203203
$serverOffset = self::serverOffset();
204204
$gmtTime = $serverTime - $serverOffset;
205-
$userTime = $gmtTime + $userOffset * (60*60);
205+
$userTime = $gmtTime + $userOffset * (60 * 60);
206206
return $userTime;
207207
}
208208

@@ -378,7 +378,7 @@ public static function isThisMonth($dateString, $userOffset = null) {
378378
*/
379379
public static function isThisYear($dateString, $userOffset = null) {
380380
$date = self::fromString($dateString, $userOffset);
381-
return date('Y', $date) == date('Y', time());
381+
return date('Y', $date) == date('Y', time());
382382
}
383383

384384
/**
@@ -429,16 +429,16 @@ public static function toQuarter($dateString, $range = false) {
429429

430430
switch ($date) {
431431
case 1:
432-
$date = array($year.'-01-01', $year.'-03-31');
432+
$date = array($year . '-01-01', $year . '-03-31');
433433
break;
434434
case 2:
435-
$date = array($year.'-04-01', $year.'-06-30');
435+
$date = array($year . '-04-01', $year . '-06-30');
436436
break;
437437
case 3:
438-
$date = array($year.'-07-01', $year.'-09-30');
438+
$date = array($year . '-07-01', $year . '-09-30');
439439
break;
440440
case 4:
441-
$date = array($year.'-10-01', $year.'-12-31');
441+
$date = array($year . '-10-01', $year . '-12-31');
442442
break;
443443
}
444444
}
@@ -485,8 +485,8 @@ public static function toRSS($dateString, $userOffset = null) {
485485
if ($userOffset == 0) {
486486
$timezone = '+0000';
487487
} else {
488-
$hours = (int) floor(abs($userOffset));
489-
$minutes = (int) (fmod(abs($userOffset), $hours) * 60);
488+
$hours = (int)floor(abs($userOffset));
489+
$minutes = (int)(fmod(abs($userOffset), $hours) * 60);
490490
$timezone = ($userOffset < 0 ? '-' : '+') . str_pad($hours, 2, '0', STR_PAD_LEFT) . str_pad($minutes, 2, '0', STR_PAD_LEFT);
491491
}
492492
return date('D, d M Y H:i:s', $date) . ' ' . $timezone;
@@ -795,4 +795,5 @@ protected static function _strftime($format, $date) {
795795
}
796796
return $format;
797797
}
798+
798799
}

lib/Cake/Utility/ClassRegistry.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<?php
22
/**
3-
* Class collections.
4-
*
5-
* A repository for class objects, each registered with a key.
6-
*
7-
* PHP 5
8-
*
93
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
104
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
115
*
@@ -370,4 +364,5 @@ public static function flush() {
370364
$_this->_objects = array();
371365
$_this->_map = array();
372366
}
367+
373368
}

lib/Cake/Utility/Debugger.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public static function log($var, $level = LOG_DEBUG) {
203203
* @deprecated This function is superseded by Debugger::outputError()
204204
*/
205205
public static function showError($code, $description, $file = null, $line = null, $context = null) {
206-
$_this = Debugger::getInstance();
206+
$self = Debugger::getInstance();
207207

208208
if (empty($file)) {
209209
$file = '[internal]';
@@ -214,8 +214,8 @@ public static function showError($code, $description, $file = null, $line = null
214214
$path = self::trimPath($file);
215215

216216
$info = compact('code', 'description', 'file', 'line');
217-
if (!in_array($info, $_this->errors)) {
218-
$_this->errors[] = $info;
217+
if (!in_array($info, $self->errors)) {
218+
$self->errors[] = $info;
219219
} else {
220220
return;
221221
}
@@ -254,7 +254,7 @@ public static function showError($code, $description, $file = null, $line = null
254254
$data = compact(
255255
'level', 'error', 'code', 'description', 'file', 'path', 'line', 'context'
256256
);
257-
echo $_this->outputError($data);
257+
echo $self->outputError($data);
258258

259259
if ($error == 'Fatal Error') {
260260
exit();
@@ -279,10 +279,10 @@ public static function showError($code, $description, $file = null, $line = null
279279
* @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::trace
280280
*/
281281
public static function trace($options = array()) {
282-
$_this = Debugger::getInstance();
282+
$self = Debugger::getInstance();
283283
$defaults = array(
284284
'depth' => 999,
285-
'format' => $_this->_outputFormat,
285+
'format' => $self->_outputFormat,
286286
'args' => false,
287287
'start' => 0,
288288
'scope' => null,
@@ -330,10 +330,10 @@ public static function trace($options = array()) {
330330
} elseif ($options['format'] == 'array') {
331331
$back[] = $trace;
332332
} else {
333-
if (isset($_this->_templates[$options['format']]['traceLine'])) {
334-
$tpl = $_this->_templates[$options['format']]['traceLine'];
333+
if (isset($self->_templates[$options['format']]['traceLine'])) {
334+
$tpl = $self->_templates[$options['format']]['traceLine'];
335335
} else {
336-
$tpl = $_this->_templates['base']['traceLine'];
336+
$tpl = $self->_templates['base']['traceLine'];
337337
}
338338
$trace['path'] = self::trimPath($trace['file']);
339339
$trace['reference'] = $reference;
@@ -665,7 +665,7 @@ public static function addFormat($format, array $strings) {
665665
* in 3.0
666666
*/
667667
public function output($format = null, $strings = array()) {
668-
$_this = Debugger::getInstance();
668+
$self = Debugger::getInstance();
669669
$data = null;
670670

671671
if (is_null($format)) {
@@ -676,9 +676,9 @@ public function output($format = null, $strings = array()) {
676676
return Debugger::addFormat($format, $strings);
677677
}
678678

679-
if ($format === true && !empty($_this->_data)) {
680-
$data = $_this->_data;
681-
$_this->_data = array();
679+
if ($format === true && !empty($self->_data)) {
680+
$data = $self->_data;
681+
$self->_data = array();
682682
$format = false;
683683
}
684684
Debugger::outputAs($format);
@@ -810,4 +810,5 @@ public static function checkSecurityKeys() {
810810
trigger_error(__d('cake_dev', 'Please change the value of \'Security.cipherSeed\' in app/Config/core.php to a numeric (digits only) seed value specific to your application'), E_USER_NOTICE);
811811
}
812812
}
813+
813814
}

lib/Cake/Utility/File.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public function lastChange() {
528528
* @return Folder Current folder
529529
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::Folder
530530
*/
531-
public function &Folder() {
531+
public function &folder() {
532532
return $this->Folder;
533533
}
534534

@@ -566,5 +566,5 @@ public function mime() {
566566
}
567567
return false;
568568
}
569-
569+
570570
}

lib/Cake/Utility/Folder.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22
/**
3-
* Convenience class for handling directories.
4-
*
5-
* PHP 5
6-
*
73
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
84
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
95
*
@@ -192,7 +188,7 @@ public function read($sort = true, $exceptions = false, $fullPath = false) {
192188
*/
193189
public function find($regexpPattern = '.*', $sort = false) {
194190
list($dirs, $files) = $this->read($sort);
195-
return array_values(preg_grep('/^' . $regexpPattern . '$/i', $files)); ;
191+
return array_values(preg_grep('/^' . $regexpPattern . '$/i', $files));
196192
}
197193

198194
/**
@@ -750,7 +746,7 @@ public function realpath($path) {
750746
$newpath = DS;
751747
}
752748

753-
while (($part = array_shift($parts)) !== NULL) {
749+
while (($part = array_shift($parts)) !== null) {
754750
if ($part === '.' || $part === '') {
755751
continue;
756752
}
@@ -780,4 +776,5 @@ public static function isSlashTerm($path) {
780776
$lastChar = $path[strlen($path) - 1];
781777
return $lastChar === '/' || $lastChar === '\\';
782778
}
779+
783780
}

lib/Cake/Utility/Inflector.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<?php
22
/**
3-
* Pluralize and singularize English words.
4-
*
5-
* Used by Cake's naming conventions throughout the framework.
6-
*
7-
* PHP 5
8-
*
93
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
104
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
115
*
@@ -350,7 +344,6 @@ public static function rules($type, $rules, $reset = false) {
350344
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::pluralize
351345
*/
352346
public static function pluralize($word) {
353-
354347
if (isset(self::$_cache['pluralize'][$word])) {
355348
return self::$_cache['pluralize'][$word];
356349
}
@@ -394,7 +387,6 @@ public static function pluralize($word) {
394387
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::singularize
395388
*/
396389
public static function singularize($word) {
397-
398390
if (isset(self::$_cache['singularize'][$word])) {
399391
return self::$_cache['singularize'][$word];
400392
}
@@ -552,6 +544,7 @@ public static function slug($string, $replacement = '_') {
552544
$map = self::$_transliteration + $merge;
553545
return preg_replace(array_keys($map), array_values($map), $string);
554546
}
547+
555548
}
556549

557550
// Store the initial state

lib/Cake/Utility/ObjectCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,5 @@ public static function normalizeObjectArray($objects) {
322322
}
323323
return $normal;
324324
}
325+
325326
}

lib/Cake/Utility/Sanitize.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,5 @@ public static function clean($data, $options = array()) {
260260
return $data;
261261
}
262262
}
263+
263264
}

lib/Cake/Utility/Security.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,5 @@ public static function cipher($text, $key) {
154154
srand();
155155
return $out;
156156
}
157+
157158
}

0 commit comments

Comments
 (0)