@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * the method will get the settings from L10n::_setLanguage(); |
| 345 | 345 | * |
| 346 | 346 | * @param string $language Language (if null will use DEFAULT_LANGUAGE if defined) |
| 347 | - * @return mixed |
|
| 347 | + * @return string|null |
|
| 348 | 348 | */ |
| 349 | 349 | public function get($language = null) { |
| 350 | 350 | if ($language !== null) { |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * If $language is null it will use the L10n::$default if defined |
| 363 | 363 | * |
| 364 | 364 | * @param string $language Language (if null will use L10n::$default if defined) |
| 365 | - * @return mixed |
|
| 365 | + * @return string|null |
|
| 366 | 366 | */ |
| 367 | 367 | protected function _setLanguage($language = null) { |
| 368 | 368 | $catalog = false; |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | return $this->_setLanguage($language); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if (!$this->_autoLanguage()) { |
|
| 354 | + if ( ! $this->_autoLanguage()) { |
|
| 355 | 355 | $this->_setLanguage(); |
| 356 | 356 | } |
| 357 | 357 | return $this->lang; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | $catalog = $this->catalog($language); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if (!$catalog && $this->default) { |
|
| 373 | + if ( ! $catalog && $this->default) { |
|
| 374 | 374 | $language = $this->default; |
| 375 | 375 | $catalog = $this->catalog($language); |
| 376 | 376 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | if ($this->default && $language !== $this->default) { |
| 394 | 394 | $catalog = $this->catalog($this->default); |
| 395 | 395 | $fallback = $catalog['localeFallback']; |
| 396 | - if (!in_array($fallback, $this->languagePath)) { |
|
| 396 | + if ( ! in_array($fallback, $this->languagePath)) { |
|
| 397 | 397 | $this->languagePath[] = $fallback; |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. |
| 136 | 136 | * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, |
| 137 | 137 | * Default value is false. |
| 138 | - * @return integer|boolean The portion of $haystack, or false if $needle is not found. |
|
| 138 | + * @return string|false The portion of $haystack, or false if $needle is not found. |
|
| 139 | 139 | */ |
| 140 | 140 | public static function stristr($haystack, $needle, $part = false) { |
| 141 | 141 | $php = (PHP_VERSION < 5.3); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. |
| 254 | 254 | * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, |
| 255 | 255 | * Default value is false. |
| 256 | - * @return string|boolean The portion of $haystack. or false if $needle is not found. |
|
| 256 | + * @return string|false The portion of $haystack. or false if $needle is not found. |
|
| 257 | 257 | */ |
| 258 | 258 | public static function strrchr($haystack, $needle, $part = false) { |
| 259 | 259 | $check = Multibyte::utf8($haystack); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. |
| 314 | 314 | * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, |
| 315 | 315 | * Default value is false. |
| 316 | - * @return string|boolean The portion of $haystack. or false if $needle is not found. |
|
| 316 | + * @return string|false The portion of $haystack. or false if $needle is not found. |
|
| 317 | 317 | */ |
| 318 | 318 | public static function strrichr($haystack, $needle, $part = false) { |
| 319 | 319 | $check = Multibyte::strtoupper($haystack); |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. |
| 476 | 476 | * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, |
| 477 | 477 | * Default value is FALSE. |
| 478 | - * @return string|boolean The portion of $haystack, or true if $needle is not found. |
|
| 478 | + * @return string|false The portion of $haystack, or true if $needle is not found. |
|
| 479 | 479 | */ |
| 480 | 480 | public static function strstr($haystack, $needle, $part = false) { |
| 481 | 481 | $php = (PHP_VERSION < 5.3); |
@@ -166,22 +166,22 @@ discard block |
||
| 166 | 166 | $found = true; |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | - if (!$found) { |
|
| 169 | + if ( ! $found) { |
|
| 170 | 170 | $parts[] = $haystack[$position]; |
| 171 | 171 | unset($haystack[$position]); |
| 172 | 172 | } |
| 173 | 173 | $position++; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ($found && $part && !empty($parts)) { |
|
| 176 | + if ($found && $part && ! empty($parts)) { |
|
| 177 | 177 | return Multibyte::ascii($parts); |
| 178 | - } elseif ($found && !empty($haystack)) { |
|
| 178 | + } elseif ($found && ! empty($haystack)) { |
|
| 179 | 179 | return Multibyte::ascii($haystack); |
| 180 | 180 | } |
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if (!$php) { |
|
| 184 | + if ( ! $php) { |
|
| 185 | 185 | return stristr($haystack, $needle, $part); |
| 186 | 186 | } |
| 187 | 187 | return stristr($haystack, $needle); |
@@ -289,16 +289,16 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if (!$found && isset($haystack[$position])) { |
|
| 292 | + if ( ! $found && isset($haystack[$position])) { |
|
| 293 | 293 | $parts[] = $haystack[$position]; |
| 294 | 294 | unset($haystack[$position]); |
| 295 | 295 | } |
| 296 | 296 | $position++; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if ($found && $part && !empty($parts)) { |
|
| 299 | + if ($found && $part && ! empty($parts)) { |
|
| 300 | 300 | return Multibyte::ascii($parts); |
| 301 | - } elseif ($found && !empty($haystack)) { |
|
| 301 | + } elseif ($found && ! empty($haystack)) { |
|
| 302 | 302 | return Multibyte::ascii($haystack); |
| 303 | 303 | } |
| 304 | 304 | return false; |
@@ -351,16 +351,16 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if (!$found && isset($haystack[$position])) { |
|
| 354 | + if ( ! $found && isset($haystack[$position])) { |
|
| 355 | 355 | $parts[] = $haystack[$position]; |
| 356 | 356 | unset($haystack[$position]); |
| 357 | 357 | } |
| 358 | 358 | $position++; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if ($found && $part && !empty($parts)) { |
|
| 361 | + if ($found && $part && ! empty($parts)) { |
|
| 362 | 362 | return Multibyte::ascii($parts); |
| 363 | - } elseif ($found && !empty($haystack)) { |
|
| 363 | + } elseif ($found && ! empty($haystack)) { |
|
| 364 | 364 | return Multibyte::ascii($haystack); |
| 365 | 365 | } |
| 366 | 366 | return false; |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
| 405 | + if ( ! $offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
| 406 | 406 | $matches[$needle[0]] = $matches[$needle[0]] - 1; |
| 407 | 407 | } elseif ($i === $needleCount) { |
| 408 | 408 | $found = true; |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
| 455 | + if ( ! $offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
| 456 | 456 | $matches[$needle[0]] = $matches[$needle[0]] - 1; |
| 457 | 457 | } elseif ($i === $needleCount) { |
| 458 | 458 | $found = true; |
@@ -504,22 +504,22 @@ discard block |
||
| 504 | 504 | $found = true; |
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | - if (!$found) { |
|
| 507 | + if ( ! $found) { |
|
| 508 | 508 | $parts[] = $haystack[$position]; |
| 509 | 509 | unset($haystack[$position]); |
| 510 | 510 | } |
| 511 | 511 | $position++; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if ($found && $part && !empty($parts)) { |
|
| 514 | + if ($found && $part && ! empty($parts)) { |
|
| 515 | 515 | return Multibyte::ascii($parts); |
| 516 | - } elseif ($found && !empty($haystack)) { |
|
| 516 | + } elseif ($found && ! empty($haystack)) { |
|
| 517 | 517 | return Multibyte::ascii($haystack); |
| 518 | 518 | } |
| 519 | 519 | return false; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - if (!$php) { |
|
| 522 | + if ( ! $php) { |
|
| 523 | 523 | return strstr($haystack, $needle, $part); |
| 524 | 524 | } |
| 525 | 525 | return strstr($haystack, $needle); |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | $matched = false; |
| 553 | 553 | $keys = self::_find($char, 'upper'); |
| 554 | 554 | |
| 555 | - if (!empty($keys)) { |
|
| 555 | + if ( ! empty($keys)) { |
|
| 556 | 556 | foreach ($keys as $key => $value) { |
| 557 | 557 | if ($keys[$key]['upper'] == $char && count($keys[$key]['lower'][0]) === 1) { |
| 558 | 558 | $lowerCase[] = $keys[$key]['lower'][0]; |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | $keys = self::_find($char); |
| 600 | 600 | $keyCount = count($keys); |
| 601 | 601 | |
| 602 | - if (!empty($keys)) { |
|
| 602 | + if ( ! empty($keys)) { |
|
| 603 | 603 | foreach ($keys as $key => $value) { |
| 604 | 604 | $matched = false; |
| 605 | 605 | $replace = 0; |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | - if ($matched === false && !in_array($char, $replaced, true)) { |
|
| 653 | + if ($matched === false && ! in_array($char, $replaced, true)) { |
|
| 654 | 654 | $upperCase[] = $char; |
| 655 | 655 | } |
| 656 | 656 | } |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | * @return string |
| 733 | 733 | */ |
| 734 | 734 | public static function mimeEncode($string, $charset = null, $newline = "\r\n") { |
| 735 | - if (!Multibyte::checkMultibyte($string) && strlen($string) < 75) { |
|
| 735 | + if ( ! Multibyte::checkMultibyte($string) && strlen($string) < 75) { |
|
| 736 | 736 | return $string; |
| 737 | 737 | } |
| 738 | 738 | |
@@ -741,9 +741,9 @@ discard block |
||
| 741 | 741 | } |
| 742 | 742 | $charset = strtoupper($charset); |
| 743 | 743 | |
| 744 | - $start = '=?' . $charset . '?B?'; |
|
| 744 | + $start = '=?'.$charset.'?B?'; |
|
| 745 | 745 | $end = '?='; |
| 746 | - $spacer = $end . $newline . ' ' . $start; |
|
| 746 | + $spacer = $end.$newline.' '.$start; |
|
| 747 | 747 | |
| 748 | 748 | $length = 75 - strlen($start) - strlen($end); |
| 749 | 749 | $length = $length - ($length % 4); |
@@ -752,7 +752,7 @@ discard block |
||
| 752 | 752 | $maxchars = floor(($length * 3) / 4); |
| 753 | 753 | $stringLength = strlen($string); |
| 754 | 754 | while ($stringLength > $maxchars) { |
| 755 | - $i = (int)$maxchars; |
|
| 755 | + $i = (int) $maxchars; |
|
| 756 | 756 | $test = ord($string[$i]); |
| 757 | 757 | while ($test >= 128 && $test <= 191) { |
| 758 | 758 | $i--; |
@@ -766,9 +766,9 @@ discard block |
||
| 766 | 766 | $string = implode($spacer, $parts); |
| 767 | 767 | } else { |
| 768 | 768 | $string = chunk_split(base64_encode($string), $length, $spacer); |
| 769 | - $string = preg_replace('/' . preg_quote($spacer) . '$/', '', $string); |
|
| 769 | + $string = preg_replace('/'.preg_quote($spacer).'$/', '', $string); |
|
| 770 | 770 | } |
| 771 | - return $start . $string . $end; |
|
| 771 | + return $start.$string.$end; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | /** |
@@ -828,21 +828,21 @@ discard block |
||
| 828 | 828 | */ |
| 829 | 829 | protected static function _find($char, $type = 'lower') { |
| 830 | 830 | $found = array(); |
| 831 | - if (!isset(self::$_codeRange[$char])) { |
|
| 831 | + if ( ! isset(self::$_codeRange[$char])) { |
|
| 832 | 832 | $range = self::_codepoint($char); |
| 833 | 833 | if ($range === false) { |
| 834 | 834 | return null; |
| 835 | 835 | } |
| 836 | - if (!Configure::configured('_cake_core_')) { |
|
| 836 | + if ( ! Configure::configured('_cake_core_')) { |
|
| 837 | 837 | App::uses('PhpReader', 'Configure'); |
| 838 | - Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS)); |
|
| 838 | + Configure::config('_cake_core_', new PhpReader(CAKE.'Config'.DS)); |
|
| 839 | 839 | } |
| 840 | - Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); |
|
| 840 | + Configure::load('unicode'.DS.'casefolding'.DS.$range, '_cake_core_'); |
|
| 841 | 841 | self::$_caseFold[$range] = Configure::read($range); |
| 842 | 842 | Configure::delete($range); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if (!self::$_codeRange[$char]) { |
|
| 845 | + if ( ! self::$_codeRange[$char]) { |
|
| 846 | 846 | return null; |
| 847 | 847 | } |
| 848 | 848 | self::$_table = self::$_codeRange[$char]; |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | * Convenience method to log error messages |
| 501 | 501 | * |
| 502 | 502 | * @param string $message log message |
| 503 | - * @param string|array $scope The scope(s) a log message is being created in. |
|
| 503 | + * @param string $scope The scope(s) a log message is being created in. |
|
| 504 | 504 | * See CakeLog::config() for more information on logging scopes. |
| 505 | 505 | * @return boolean Success |
| 506 | 506 | */ |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | * Convenience method to log warning messages |
| 513 | 513 | * |
| 514 | 514 | * @param string $message log message |
| 515 | - * @param string|array $scope The scope(s) a log message is being created in. |
|
| 515 | + * @param string $scope The scope(s) a log message is being created in. |
|
| 516 | 516 | * See CakeLog::config() for more information on logging scopes. |
| 517 | 517 | * @return boolean Success |
| 518 | 518 | */ |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * Convenience method to log info messages |
| 549 | 549 | * |
| 550 | 550 | * @param string $message log message |
| 551 | - * @param string|array $scope The scope(s) a log message is being created in. |
|
| 551 | + * @param string $scope The scope(s) a log message is being created in. |
|
| 552 | 552 | * See CakeLog::config() for more information on logging scopes. |
| 553 | 553 | * @return boolean Success |
| 554 | 554 | */ |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @throws CakeLogException |
| 187 | 187 | */ |
| 188 | 188 | public static function config($key, $config) { |
| 189 | - if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $key)) { |
|
| 189 | + if ( ! preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/', $key)) { |
|
| 190 | 190 | throw new CakeLogException(__d('cake_dev', 'Invalid key name')); |
| 191 | 191 | } |
| 192 | 192 | if (empty($config['engine'])) { |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | if (empty(self::$_Collection)) { |
| 311 | 311 | self::_init(); |
| 312 | 312 | } |
| 313 | - if (!isset(self::$_Collection->{$streamName})) { |
|
| 313 | + if ( ! isset(self::$_Collection->{$streamName})) { |
|
| 314 | 314 | throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); |
| 315 | 315 | } |
| 316 | 316 | return self::$_Collection->enabled($streamName); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | if (empty(self::$_Collection)) { |
| 329 | 329 | self::_init(); |
| 330 | 330 | } |
| 331 | - if (!isset(self::$_Collection->{$streamName})) { |
|
| 331 | + if ( ! isset(self::$_Collection->{$streamName})) { |
|
| 332 | 332 | throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); |
| 333 | 333 | } |
| 334 | 334 | self::$_Collection->enable($streamName); |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | if (empty(self::$_Collection)) { |
| 348 | 348 | self::_init(); |
| 349 | 349 | } |
| 350 | - if (!isset(self::$_Collection->{$streamName})) { |
|
| 350 | + if ( ! isset(self::$_Collection->{$streamName})) { |
|
| 351 | 351 | throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); |
| 352 | 352 | } |
| 353 | 353 | self::$_Collection->disable($streamName); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | if (empty(self::$_Collection)) { |
| 365 | 365 | self::_init(); |
| 366 | 366 | } |
| 367 | - if (!empty(self::$_Collection->{$streamName})) { |
|
| 367 | + if ( ! empty(self::$_Collection->{$streamName})) { |
|
| 368 | 368 | return self::$_Collection->{$streamName}; |
| 369 | 369 | } |
| 370 | 370 | return false; |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | if (is_int($type) && isset(self::$_levels[$type])) { |
| 421 | 421 | $type = self::$_levels[$type]; |
| 422 | 422 | } |
| 423 | - if (is_string($type) && empty($scope) && !in_array($type, self::$_levels)) { |
|
| 423 | + if (is_string($type) && empty($scope) && ! in_array($type, self::$_levels)) { |
|
| 424 | 424 | $scope = $type; |
| 425 | 425 | } |
| 426 | 426 | $logged = false; |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | if (isset($config['scopes'])) { |
| 437 | 437 | $scopes = $config['scopes']; |
| 438 | 438 | } |
| 439 | - $inScope = (count(array_intersect((array)$scope, $scopes)) > 0); |
|
| 439 | + $inScope = (count(array_intersect((array) $scope, $scopes)) > 0); |
|
| 440 | 440 | $correctLevel = in_array($type, $types); |
| 441 | 441 | |
| 442 | 442 | if ( |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | $logged = true; |
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | - if (!$logged) { |
|
| 456 | + if ( ! $logged) { |
|
| 457 | 457 | self::_autoConfig(); |
| 458 | 458 | self::stream('default')->write($type, $message); |
| 459 | 459 | } |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | * |
| 76 | 76 | * @param string $type The type of log you are making. |
| 77 | 77 | * @param string $message The message you want to log. |
| 78 | - * @return boolean success of write. |
|
| 78 | + * @return integer success of write. |
|
| 79 | 79 | */ |
| 80 | 80 | public function write($type, $message) { |
| 81 | 81 | $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function __construct($config = array()) { |
| 50 | 50 | parent::__construct($config); |
| 51 | - if (DS === '\\' && !(bool)env('ANSICON')) { |
|
| 51 | + if (DS === '\\' && ! (bool) env('ANSICON')) { |
|
| 52 | 52 | $outputAs = ConsoleOutput::PLAIN; |
| 53 | 53 | } else { |
| 54 | 54 | $outputAs = ConsoleOutput::COLOR; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return boolean success of write. |
| 79 | 79 | */ |
| 80 | 80 | public function write($type, $message) { |
| 81 | - $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; |
|
| 81 | + $output = date('Y-m-d H:i:s').' '.ucfirst($type).': '.$message."\n"; |
|
| 82 | 82 | return $this->_output->write(sprintf('<%s>%s</%s>', $type, $output, $type), false); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -83,7 +83,6 @@ discard block |
||
| 83 | 83 | * - `mask` A mask is applied when log files are created. Left empty no chmod |
| 84 | 84 | * is made. |
| 85 | 85 | * |
| 86 | - * @param array $options Options for the FileLog, see above. |
|
| 87 | 86 | */ |
| 88 | 87 | public function __construct($config = array()) { |
| 89 | 88 | $config = Hash::merge($this->_defaults, $config); |
@@ -94,7 +93,7 @@ discard block |
||
| 94 | 93 | * Sets protected properties based on config provided |
| 95 | 94 | * |
| 96 | 95 | * @param array $config Engine configuration |
| 97 | - * @return array |
|
| 96 | + * @return string |
|
| 98 | 97 | */ |
| 99 | 98 | public function config($config = array()) { |
| 100 | 99 | parent::config($config); |
@@ -128,7 +127,7 @@ discard block |
||
| 128 | 127 | * |
| 129 | 128 | * @param string $type The type of log you are making. |
| 130 | 129 | * @param string $message The message you want to log. |
| 131 | - * @return boolean success of write. |
|
| 130 | + * @return integer success of write. |
|
| 132 | 131 | */ |
| 133 | 132 | public function write($type, $message) { |
| 134 | 133 | $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; |
@@ -181,7 +180,7 @@ discard block |
||
| 181 | 180 | * Also if `rotate` count is reached oldest file is removed. |
| 182 | 181 | * |
| 183 | 182 | * @param string $filename Log file name |
| 184 | - * @return mixed True if rotated successfully or false in case of error. |
|
| 183 | + * @return null|boolean True if rotated successfully or false in case of error. |
|
| 185 | 184 | * Void if file doesn't need to be rotated. |
| 186 | 185 | */ |
| 187 | 186 | protected function _rotateFile($filename) { |
@@ -99,22 +99,22 @@ discard block |
||
| 99 | 99 | public function config($config = array()) { |
| 100 | 100 | parent::config($config); |
| 101 | 101 | |
| 102 | - if (!empty($config['path'])) { |
|
| 102 | + if ( ! empty($config['path'])) { |
|
| 103 | 103 | $this->_path = $config['path']; |
| 104 | 104 | } |
| 105 | - if (Configure::read('debug') && !is_dir($this->_path)) { |
|
| 105 | + if (Configure::read('debug') && ! is_dir($this->_path)) { |
|
| 106 | 106 | mkdir($this->_path, 0775, true); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if (!empty($config['file'])) { |
|
| 109 | + if ( ! empty($config['file'])) { |
|
| 110 | 110 | $this->_file = $config['file']; |
| 111 | 111 | if (substr($this->_file, -4) !== '.log') { |
| 112 | 112 | $this->_file .= '.log'; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | - if (!empty($config['size'])) { |
|
| 115 | + if ( ! empty($config['size'])) { |
|
| 116 | 116 | if (is_numeric($config['size'])) { |
| 117 | - $this->_size = (int)$config['size']; |
|
| 117 | + $this->_size = (int) $config['size']; |
|
| 118 | 118 | } else { |
| 119 | 119 | $this->_size = CakeNumber::fromReadableSize($config['size']); |
| 120 | 120 | } |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | * @return boolean success of write. |
| 132 | 132 | */ |
| 133 | 133 | public function write($type, $message) { |
| 134 | - $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; |
|
| 134 | + $output = date('Y-m-d H:i:s').' '.ucfirst($type).': '.$message."\n"; |
|
| 135 | 135 | $filename = $this->_getFilename($type); |
| 136 | - if (!empty($this->_size)) { |
|
| 136 | + if ( ! empty($this->_size)) { |
|
| 137 | 137 | $this->_rotateFile($filename); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $pathname = $this->_path . $filename; |
|
| 140 | + $pathname = $this->_path.$filename; |
|
| 141 | 141 | if (empty($this->_config['mask'])) { |
| 142 | 142 | return file_put_contents($pathname, $output, FILE_APPEND); |
| 143 | 143 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $exists = file_exists($pathname); |
| 146 | 146 | $result = file_put_contents($pathname, $output, FILE_APPEND); |
| 147 | 147 | static $selfError = false; |
| 148 | - if (!$selfError && !$exists && !chmod($pathname, (int)$this->_config['mask'])) { |
|
| 148 | + if ( ! $selfError && ! $exists && ! chmod($pathname, (int) $this->_config['mask'])) { |
|
| 149 | 149 | $selfError = true; |
| 150 | 150 | trigger_error(__d( |
| 151 | 151 | 'cake_dev', 'Could not apply permission mask "%s" on log file "%s"', |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | protected function _getFilename($type) { |
| 164 | 164 | $debugTypes = array('notice', 'info', 'debug'); |
| 165 | 165 | |
| 166 | - if (!empty($this->_file)) { |
|
| 166 | + if ( ! empty($this->_file)) { |
|
| 167 | 167 | $filename = $this->_file; |
| 168 | 168 | } elseif ($type === 'error' || $type === 'warning') { |
| 169 | 169 | $filename = 'error.log'; |
| 170 | 170 | } elseif (in_array($type, $debugTypes)) { |
| 171 | 171 | $filename = 'debug.log'; |
| 172 | 172 | } else { |
| 173 | - $filename = $type . '.log'; |
|
| 173 | + $filename = $type.'.log'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | return $filename; |
@@ -185,14 +185,14 @@ discard block |
||
| 185 | 185 | * Void if file doesn't need to be rotated. |
| 186 | 186 | */ |
| 187 | 187 | protected function _rotateFile($filename) { |
| 188 | - $filepath = $this->_path . $filename; |
|
| 188 | + $filepath = $this->_path.$filename; |
|
| 189 | 189 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
| 190 | 190 | clearstatcache(true, $filepath); |
| 191 | 191 | } else { |
| 192 | 192 | clearstatcache(); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if (!file_exists($filepath) || |
|
| 195 | + if ( ! file_exists($filepath) || |
|
| 196 | 196 | filesize($filepath) < $this->_size |
| 197 | 197 | ) { |
| 198 | 198 | return; |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | if ($this->_config['rotate'] === 0) { |
| 202 | 202 | $result = unlink($filepath); |
| 203 | 203 | } else { |
| 204 | - $result = rename($filepath, $filepath . '.' . time()); |
|
| 204 | + $result = rename($filepath, $filepath.'.'.time()); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $files = glob($filepath . '.*'); |
|
| 207 | + $files = glob($filepath.'.*'); |
|
| 208 | 208 | if ($files) { |
| 209 | 209 | $filesToDelete = count($files) - $this->_config['rotate']; |
| 210 | 210 | while ($filesToDelete > 0) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @param Model $Model Model the behavior is being attached to. |
| 64 | 64 | * @param array $config Array of configuration information. |
| 65 | - * @return mixed |
|
| 65 | + * @return boolean |
|
| 66 | 66 | */ |
| 67 | 67 | public function setup(Model $Model, $config = array()) { |
| 68 | 68 | $db = ConnectionManager::getDataSource($Model->useDbConfig); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * is disabled. |
| 369 | 369 | * |
| 370 | 370 | * @param Model $Model |
| 371 | - * @return void |
|
| 371 | + * @return boolean|null |
|
| 372 | 372 | */ |
| 373 | 373 | protected function _setRuntimeData(Model $Model) { |
| 374 | 374 | $locale = $this->_getLocale($Model); |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | * Restores model data to the original data. |
| 401 | 401 | * This solves issues with saveAssociated and validate = first. |
| 402 | 402 | * |
| 403 | - * @param Model $model |
|
| 404 | - * @return void |
|
| 403 | + * @param Model $Model |
|
| 404 | + * @return boolean |
|
| 405 | 405 | */ |
| 406 | 406 | public function afterValidate(Model $Model) { |
| 407 | 407 | $Model->data[$Model->alias] = array_merge( |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | * @param Model $Model Model the callback is called on |
| 418 | 418 | * @param boolean $created Whether or not the save created a record. |
| 419 | 419 | * @param array $options Options passed from Model::save(). |
| 420 | - * @return void |
|
| 420 | + * @return boolean|null |
|
| 421 | 421 | */ |
| 422 | 422 | public function afterSave(Model $Model, $created, $options = array()) { |
| 423 | 423 | if (!isset($this->runtime[$Model->alias]['beforeValidate']) && !isset($this->runtime[$Model->alias]['beforeSave'])) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function setup(Model $Model, $config = array()) { |
| 68 | 68 | $db = ConnectionManager::getDataSource($Model->useDbConfig); |
| 69 | - if (!$db->connected) { |
|
| 69 | + if ( ! $db->connected) { |
|
| 70 | 70 | trigger_error( |
| 71 | 71 | __d('cake_dev', 'Datasource %s for TranslateBehavior of model %s is not connected', $Model->useDbConfig, $Model->alias), |
| 72 | 72 | E_USER_ERROR |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $db = $Model->getDataSource(); |
| 109 | 109 | $RuntimeModel = $this->translateModel($Model); |
| 110 | 110 | |
| 111 | - if (!empty($RuntimeModel->tablePrefix)) { |
|
| 111 | + if ( ! empty($RuntimeModel->tablePrefix)) { |
|
| 112 | 112 | $tablePrefix = $RuntimeModel->tablePrefix; |
| 113 | 113 | } else { |
| 114 | 114 | $tablePrefix = $db->config['prefix']; |
@@ -152,14 +152,14 @@ discard block |
||
| 152 | 152 | $addFields = $fields; |
| 153 | 153 | } elseif (is_array($query['fields'])) { |
| 154 | 154 | $isAllFields = ( |
| 155 | - in_array($Model->alias . '.' . '*', $query['fields']) || |
|
| 155 | + in_array($Model->alias.'.'.'*', $query['fields']) || |
|
| 156 | 156 | in_array($Model->escapeField('*'), $query['fields']) |
| 157 | 157 | ); |
| 158 | 158 | foreach ($fields as $key => $value) { |
| 159 | 159 | $field = (is_numeric($key)) ? $value : $key; |
| 160 | 160 | if ( |
| 161 | 161 | $isAllFields || |
| 162 | - in_array($Model->alias . '.' . $field, $query['fields']) || |
|
| 162 | + in_array($Model->alias.'.'.$field, $query['fields']) || |
|
| 163 | 163 | in_array($field, $query['fields']) |
| 164 | 164 | ) { |
| 165 | 165 | $addFields[] = $field; |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | foreach ($addFields as $_f => $field) { |
| 173 | 173 | $aliasField = is_numeric($_f) ? $field : $_f; |
| 174 | 174 | |
| 175 | - foreach (array($aliasField, $Model->alias . '.' . $aliasField) as $_field) { |
|
| 176 | - $key = array_search($_field, (array)$query['fields']); |
|
| 175 | + foreach (array($aliasField, $Model->alias.'.'.$aliasField) as $_field) { |
|
| 176 | + $key = array_search($_field, (array) $query['fields']); |
|
| 177 | 177 | |
| 178 | 178 | if ($key !== false) { |
| 179 | 179 | unset($query['fields'][$key]); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function _checkConditions(Model $Model, $query) { |
| 199 | 199 | $conditionFields = array(); |
| 200 | - if (empty($query['conditions']) || (!empty($query['conditions']) && !is_array($query['conditions']))) { |
|
| 200 | + if (empty($query['conditions']) || ( ! empty($query['conditions']) && ! is_array($query['conditions']))) { |
|
| 201 | 201 | return $conditionFields; |
| 202 | 202 | } |
| 203 | 203 | foreach ($query['conditions'] as $col => $val) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $aliasVirtualLocale = "{$aliasVirtual}_{$_locale}"; |
| 235 | 235 | $aliasLocale = "{$alias}__{$_locale}"; |
| 236 | 236 | $Model->virtualFields[$aliasVirtualLocale] = "{$aliasLocale}.content"; |
| 237 | - if (!empty($query['fields']) && is_array($query['fields'])) { |
|
| 237 | + if ( ! empty($query['fields']) && is_array($query['fields'])) { |
|
| 238 | 238 | $query['fields'][] = $aliasVirtualLocale; |
| 239 | 239 | } |
| 240 | 240 | $query['joins'][] = array( |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | } |
| 252 | 252 | } else { |
| 253 | 253 | $Model->virtualFields[$aliasVirtual] = "{$alias}.content"; |
| 254 | - if (!empty($query['fields']) && is_array($query['fields'])) { |
|
| 254 | + if ( ! empty($query['fields']) && is_array($query['fields'])) { |
|
| 255 | 255 | $query['fields'][] = $aliasVirtual; |
| 256 | 256 | } |
| 257 | 257 | $query['joins'][] = array( |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $Model->virtualFields = $this->runtime[$Model->alias]['virtualFields']; |
| 282 | 282 | |
| 283 | 283 | $this->runtime[$Model->alias]['virtualFields'] = $this->runtime[$Model->alias]['fields'] = array(); |
| 284 | - if (!empty($this->runtime[$Model->alias]['restoreFields'])) { |
|
| 284 | + if ( ! empty($this->runtime[$Model->alias]['restoreFields'])) { |
|
| 285 | 285 | $this->runtime[$Model->alias]['fields'] = $this->runtime[$Model->alias]['restoreFields']; |
| 286 | 286 | unset($this->runtime[$Model->alias]['restoreFields']); |
| 287 | 287 | } |
@@ -301,14 +301,14 @@ discard block |
||
| 301 | 301 | if (is_array($locale)) { |
| 302 | 302 | foreach ($locale as $_locale) { |
| 303 | 303 | $aliasVirtualLocale = "{$aliasVirtual}_{$_locale}"; |
| 304 | - if (!isset($row[$Model->alias][$aliasField]) && !empty($row[$Model->alias][$aliasVirtualLocale])) { |
|
| 304 | + if ( ! isset($row[$Model->alias][$aliasField]) && ! empty($row[$Model->alias][$aliasVirtualLocale])) { |
|
| 305 | 305 | $row[$Model->alias][$aliasField] = $row[$Model->alias][$aliasVirtualLocale]; |
| 306 | 306 | $row[$Model->alias]['locale'] = $_locale; |
| 307 | 307 | } |
| 308 | 308 | unset($row[$Model->alias][$aliasVirtualLocale]); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if (!isset($row[$Model->alias][$aliasField])) { |
|
| 311 | + if ( ! isset($row[$Model->alias][$aliasField])) { |
|
| 312 | 312 | $row[$Model->alias][$aliasField] = ''; |
| 313 | 313 | } |
| 314 | 314 | } else { |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @see Model::save() |
| 351 | 351 | */ |
| 352 | 352 | public function beforeSave(Model $Model, $options = array()) { |
| 353 | - if (isset($options['validate']) && !$options['validate']) { |
|
| 353 | + if (isset($options['validate']) && ! $options['validate']) { |
|
| 354 | 354 | unset($this->runtime[$Model->alias]['beforeSave']); |
| 355 | 355 | } |
| 356 | 356 | if (isset($this->runtime[$Model->alias]['beforeSave'])) { |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | if (isset($Model->data[$Model->alias][$field])) { |
| 385 | 385 | $tempData[$field] = $Model->data[$Model->alias][$field]; |
| 386 | 386 | if (is_array($Model->data[$Model->alias][$field])) { |
| 387 | - if (is_string($locale) && !empty($Model->data[$Model->alias][$field][$locale])) { |
|
| 387 | + if (is_string($locale) && ! empty($Model->data[$Model->alias][$field][$locale])) { |
|
| 388 | 388 | $Model->data[$Model->alias][$field] = $Model->data[$Model->alias][$field][$locale]; |
| 389 | 389 | } else { |
| 390 | 390 | $values = array_values($Model->data[$Model->alias][$field]); |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * @return void |
| 421 | 421 | */ |
| 422 | 422 | public function afterSave(Model $Model, $created, $options = array()) { |
| 423 | - if (!isset($this->runtime[$Model->alias]['beforeValidate']) && !isset($this->runtime[$Model->alias]['beforeSave'])) { |
|
| 423 | + if ( ! isset($this->runtime[$Model->alias]['beforeValidate']) && ! isset($this->runtime[$Model->alias]['beforeSave'])) { |
|
| 424 | 424 | return true; |
| 425 | 425 | } |
| 426 | 426 | if (isset($this->runtime[$Model->alias]['beforeValidate'])) { |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | $translations = $RuntimeModel->find('list', array( |
| 455 | 455 | 'conditions' => $conditions, |
| 456 | 456 | 'fields' => array( |
| 457 | - $RuntimeModel->alias . '.locale', |
|
| 458 | - $RuntimeModel->alias . '.id' |
|
| 457 | + $RuntimeModel->alias.'.locale', |
|
| 458 | + $RuntimeModel->alias.'.id' |
|
| 459 | 459 | ) |
| 460 | 460 | )); |
| 461 | 461 | foreach ($value as $_locale => $_value) { |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | $hasLocales = count($locales) > 0; |
| 496 | 496 | |
| 497 | 497 | foreach ($fields as $key => $field) { |
| 498 | - if (!is_numeric($key)) { |
|
| 498 | + if ( ! is_numeric($key)) { |
|
| 499 | 499 | $field = $key; |
| 500 | 500 | } |
| 501 | - if ($hasLocales && !isset($data[$field])) { |
|
| 501 | + if ($hasLocales && ! isset($data[$field])) { |
|
| 502 | 502 | $data[$field] = array_fill_keys($locales, ''); |
| 503 | - } elseif (!isset($data[$field])) { |
|
| 503 | + } elseif ( ! isset($data[$field])) { |
|
| 504 | 504 | $data[$field] = ''; |
| 505 | 505 | } |
| 506 | 506 | } |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | * @return mixed string or false |
| 527 | 527 | */ |
| 528 | 528 | protected function _getLocale(Model $Model) { |
| 529 | - if (!isset($Model->locale) || $Model->locale === null) { |
|
| 529 | + if ( ! isset($Model->locale) || $Model->locale === null) { |
|
| 530 | 530 | $I18n = I18n::getInstance(); |
| 531 | 531 | $I18n->l10n->get(Configure::read('Config.language')); |
| 532 | 532 | $Model->locale = $I18n->l10n->locale; |
@@ -545,8 +545,8 @@ discard block |
||
| 545 | 545 | * @return Model |
| 546 | 546 | */ |
| 547 | 547 | public function translateModel(Model $Model) { |
| 548 | - if (!isset($this->runtime[$Model->alias]['model'])) { |
|
| 549 | - if (!isset($Model->translateModel) || empty($Model->translateModel)) { |
|
| 548 | + if ( ! isset($this->runtime[$Model->alias]['model'])) { |
|
| 549 | + if ( ! isset($Model->translateModel) || empty($Model->translateModel)) { |
|
| 550 | 550 | $className = 'I18nModel'; |
| 551 | 551 | } else { |
| 552 | 552 | $className = $Model->translateModel; |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | $this->runtime[$Model->alias]['model'] = ClassRegistry::init($className); |
| 556 | 556 | } |
| 557 | - if (!empty($Model->translateTable) && $Model->translateTable !== $this->runtime[$Model->alias]['model']->useTable) { |
|
| 557 | + if ( ! empty($Model->translateTable) && $Model->translateTable !== $this->runtime[$Model->alias]['model']->useTable) { |
|
| 558 | 558 | $this->runtime[$Model->alias]['model']->setSource($Model->translateTable); |
| 559 | 559 | } elseif (empty($Model->translateTable) && empty($Model->translateModel)) { |
| 560 | 560 | $this->runtime[$Model->alias]['model']->setSource('i18n'); |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - if (!empty($associations)) { |
|
| 636 | + if ( ! empty($associations)) { |
|
| 637 | 637 | $Model->bindModel(array('hasMany' => $associations), $reset); |
| 638 | 638 | } |
| 639 | 639 | return true; |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - if (!empty($associations)) { |
|
| 701 | + if ( ! empty($associations)) { |
|
| 702 | 702 | $Model->unbindModel(array('hasMany' => $associations), false); |
| 703 | 703 | } |
| 704 | 704 | return true; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param Model $Model Model instance. |
| 88 | 88 | * @param boolean $created indicates whether the node just saved was created or updated |
| 89 | 89 | * @param array $options Options passed from Model::save(). |
| 90 | - * @return boolean true on success, false on failure |
|
| 90 | + * @return boolean|null true on success, false on failure |
|
| 91 | 91 | */ |
| 92 | 92 | public function afterSave(Model $Model, $created, $options = array()) { |
| 93 | 93 | extract($this->settings[$Model->alias]); |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @param Model $Model Model instance |
| 482 | 482 | * @param integer|string $id The ID of the record to move |
| 483 | - * @param integer|boolean $number how many places to move the node or true to move to last position |
|
| 483 | + * @param integer $number how many places to move the node or true to move to last position |
|
| 484 | 484 | * @return boolean true on success, false on failure |
| 485 | 485 | * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveDown |
| 486 | 486 | */ |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * |
| 539 | 539 | * @param Model $Model Model instance |
| 540 | 540 | * @param integer|string $id The ID of the record to move |
| 541 | - * @param integer|boolean $number how many places to move the node, or true to move to first position |
|
| 541 | + * @param integer $number how many places to move the node, or true to move to first position |
|
| 542 | 542 | * @return boolean true on success, false on failure |
| 543 | 543 | * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveUp |
| 544 | 544 | */ |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | * @param Model $Model |
| 1045 | 1045 | * @param integer $shift |
| 1046 | 1046 | * @param string $dir |
| 1047 | - * @param array $conditions |
|
| 1047 | + * @param string $conditions |
|
| 1048 | 1048 | * @param boolean $created |
| 1049 | 1049 | * @param string $field |
| 1050 | 1050 | * @return void |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | if (in_array($settings['scope'], $Model->getAssociated('belongsTo'))) { |
| 73 | 73 | $data = $Model->getAssociated($settings['scope']); |
| 74 | 74 | $Parent = $Model->{$settings['scope']}; |
| 75 | - $settings['scope'] = $Model->escapeField($data['foreignKey']) . ' = ' . $Parent->escapeField(); |
|
| 75 | + $settings['scope'] = $Model->escapeField($data['foreignKey']).' = '.$Parent->escapeField(); |
|
| 76 | 76 | $settings['recursive'] = 0; |
| 77 | 77 | } |
| 78 | 78 | $this->settings[$Model->alias] = $settings; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @return array |
| 110 | 110 | */ |
| 111 | 111 | public function beforeFind(Model $Model, $query) { |
| 112 | - if ($Model->findQueryType === 'threaded' && !isset($query['parent'])) { |
|
| 112 | + if ($Model->findQueryType === 'threaded' && ! isset($query['parent'])) { |
|
| 113 | 113 | $query['parent'] = $this->settings[$Model->alias]['parent']; |
| 114 | 114 | } |
| 115 | 115 | return $query; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $data = $this->_deletedRow[$Model->alias]; |
| 150 | 150 | $this->_deletedRow[$Model->alias] = null; |
| 151 | 151 | |
| 152 | - if (!$data[$right] || !$data[$left]) { |
|
| 152 | + if ( ! $data[$right] || ! $data[$left]) { |
|
| 153 | 153 | return true; |
| 154 | 154 | } |
| 155 | 155 | $diff = $data[$right] - $data[$left] + 1; |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | if (is_string($scope)) { |
| 159 | 159 | $scope = array($scope); |
| 160 | 160 | } |
| 161 | - $scope[][$Model->escapeField($left) . " BETWEEN ? AND ?"] = array($data[$left] + 1, $data[$right] - 1); |
|
| 161 | + $scope[][$Model->escapeField($left)." BETWEEN ? AND ?"] = array($data[$left] + 1, $data[$right] - 1); |
|
| 162 | 162 | $Model->deleteAll($scope); |
| 163 | 163 | } |
| 164 | - $this->_sync($Model, $diff, '-', '> ' . $data[$right]); |
|
| 164 | + $this->_sync($Model, $diff, '-', '> '.$data[$right]); |
|
| 165 | 165 | return true; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | extract($this->settings[$Model->alias]); |
| 183 | 183 | |
| 184 | 184 | $this->_addToWhitelist($Model, array($left, $right)); |
| 185 | - if (!$Model->id || !$Model->exists()) { |
|
| 185 | + if ( ! $Model->id || ! $Model->exists()) { |
|
| 186 | 186 | if (array_key_exists($parent, $Model->data[$Model->alias]) && $Model->data[$Model->alias][$parent]) { |
| 187 | 187 | $parentNode = $Model->find('first', array( |
| 188 | 188 | 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), |
| 189 | 189 | 'fields' => array($Model->primaryKey, $right), 'recursive' => $recursive |
| 190 | 190 | )); |
| 191 | - if (!$parentNode) { |
|
| 191 | + if ( ! $parentNode) { |
|
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | list($parentNode) = array_values($parentNode); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | if ($Model->data[$Model->alias][$parent] != $Model->field($parent)) { |
| 204 | 204 | $this->settings[$Model->alias]['__parentChange'] = true; |
| 205 | 205 | } |
| 206 | - if (!$Model->data[$Model->alias][$parent]) { |
|
| 206 | + if ( ! $Model->data[$Model->alias][$parent]) { |
|
| 207 | 207 | $Model->data[$Model->alias][$parent] = null; |
| 208 | 208 | $this->_addToWhitelist($Model, $parent); |
| 209 | 209 | } else { |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | 'conditions' => array($scope, $Model->escapeField() => $Model->data[$Model->alias][$parent]), |
| 222 | 222 | 'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive |
| 223 | 223 | )); |
| 224 | - if (!$parentNode) { |
|
| 224 | + if ( ! $parentNode) { |
|
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | list($parentNode) = array_values($parentNode); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | if ($id === null && $Model->id) { |
| 257 | 257 | $id = $Model->id; |
| 258 | - } elseif (!$id) { |
|
| 258 | + } elseif ( ! $id) { |
|
| 259 | 259 | $id = null; |
| 260 | 260 | } |
| 261 | 261 | extract($this->settings[$Model->alias]); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $data = $Model->data[$Model->alias]; |
| 271 | 271 | } else { |
| 272 | 272 | $data = $Model->find('first', array('conditions' => array($scope, $Model->escapeField() => $id), 'recursive' => $recursive)); |
| 273 | - if (!$data) { |
|
| 273 | + if ( ! $data) { |
|
| 274 | 274 | return 0; |
| 275 | 275 | } |
| 276 | 276 | $data = $data[$Model->alias]; |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | if ($id === null && $Model->id) { |
| 305 | 305 | $id = $Model->id; |
| 306 | - } elseif (!$id) { |
|
| 306 | + } elseif ( ! $id) { |
|
| 307 | 307 | $id = null; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -312,29 +312,29 @@ discard block |
||
| 312 | 312 | if ($overrideRecursive !== null) { |
| 313 | 313 | $recursive = $overrideRecursive; |
| 314 | 314 | } |
| 315 | - if (!$order) { |
|
| 316 | - $order = $Model->escapeField($left) . " asc"; |
|
| 315 | + if ( ! $order) { |
|
| 316 | + $order = $Model->escapeField($left)." asc"; |
|
| 317 | 317 | } |
| 318 | 318 | if ($direct) { |
| 319 | 319 | $conditions = array($scope, $Model->escapeField($parent) => $id); |
| 320 | 320 | return $Model->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive')); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if (!$id) { |
|
| 323 | + if ( ! $id) { |
|
| 324 | 324 | $conditions = $scope; |
| 325 | 325 | } else { |
| 326 | - $result = array_values((array)$Model->find('first', array( |
|
| 326 | + $result = array_values((array) $Model->find('first', array( |
|
| 327 | 327 | 'conditions' => array($scope, $Model->escapeField() => $id), |
| 328 | 328 | 'fields' => array($left, $right), |
| 329 | 329 | 'recursive' => $recursive |
| 330 | 330 | ))); |
| 331 | 331 | |
| 332 | - if (empty($result) || !isset($result[0])) { |
|
| 332 | + if (empty($result) || ! isset($result[0])) { |
|
| 333 | 333 | return array(); |
| 334 | 334 | } |
| 335 | 335 | $conditions = array($scope, |
| 336 | - $Model->escapeField($right) . ' <' => $result[0][$right], |
|
| 337 | - $Model->escapeField($left) . ' >' => $result[0][$left] |
|
| 336 | + $Model->escapeField($right).' <' => $result[0][$right], |
|
| 337 | + $Model->escapeField($left).' >' => $result[0][$left] |
|
| 338 | 338 | ); |
| 339 | 339 | } |
| 340 | 340 | return $Model->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive')); |
@@ -360,30 +360,30 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | $fields = null; |
| 363 | - if (!$keyPath && !$valuePath && $Model->hasField($Model->displayField)) { |
|
| 363 | + if ( ! $keyPath && ! $valuePath && $Model->hasField($Model->displayField)) { |
|
| 364 | 364 | $fields = array($Model->primaryKey, $Model->displayField, $left, $right); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if (!$keyPath) { |
|
| 368 | - $keyPath = '{n}.' . $Model->alias . '.' . $Model->primaryKey; |
|
| 367 | + if ( ! $keyPath) { |
|
| 368 | + $keyPath = '{n}.'.$Model->alias.'.'.$Model->primaryKey; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if (!$valuePath) { |
|
| 372 | - $valuePath = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField); |
|
| 371 | + if ( ! $valuePath) { |
|
| 372 | + $valuePath = array('%s%s', '{n}.tree_prefix', '{n}.'.$Model->alias.'.'.$Model->displayField); |
|
| 373 | 373 | |
| 374 | 374 | } elseif (is_string($valuePath)) { |
| 375 | 375 | $valuePath = array('%s%s', '{n}.tree_prefix', $valuePath); |
| 376 | 376 | |
| 377 | 377 | } else { |
| 378 | - array_unshift($valuePath, '%s' . $valuePath[0], '{n}.tree_prefix'); |
|
| 378 | + array_unshift($valuePath, '%s'.$valuePath[0], '{n}.tree_prefix'); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $conditions = (array)$conditions; |
|
| 381 | + $conditions = (array) $conditions; |
|
| 382 | 382 | if ($scope) { |
| 383 | 383 | $conditions[] = $scope; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - $order = $Model->escapeField($left) . " asc"; |
|
| 386 | + $order = $Model->escapeField($left)." asc"; |
|
| 387 | 387 | $results = $Model->find('all', compact('conditions', 'fields', 'order', 'recursive')); |
| 388 | 388 | $stack = array(); |
| 389 | 389 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | $item = $result[0]; |
| 469 | 469 | $results = $Model->find('all', array( |
| 470 | - 'conditions' => array($scope, $Model->escapeField($left) . ' <=' => $item[$left], $Model->escapeField($right) . ' >=' => $item[$right]), |
|
| 470 | + 'conditions' => array($scope, $Model->escapeField($left).' <=' => $item[$left], $Model->escapeField($right).' >=' => $item[$right]), |
|
| 471 | 471 | 'fields' => $fields, 'order' => array($Model->escapeField($left) => 'asc'), 'recursive' => $recursive |
| 472 | 472 | )); |
| 473 | 473 | return $results; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | if (is_array($id)) { |
| 489 | 489 | extract(array_merge(array('id' => null), $id)); |
| 490 | 490 | } |
| 491 | - if (!$number) { |
|
| 491 | + if ( ! $number) { |
|
| 492 | 492 | return false; |
| 493 | 493 | } |
| 494 | 494 | if (empty($id)) { |
@@ -518,9 +518,9 @@ discard block |
||
| 518 | 518 | return false; |
| 519 | 519 | } |
| 520 | 520 | $edge = $this->_getMax($Model, $scope, $right, $recursive); |
| 521 | - $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right]); |
|
| 522 | - $this->_sync($Model, $nextNode[$left] - $node[$left], '-', 'BETWEEN ' . $nextNode[$left] . ' AND ' . $nextNode[$right]); |
|
| 523 | - $this->_sync($Model, $edge - $node[$left] - ($nextNode[$right] - $nextNode[$left]), '-', '> ' . $edge); |
|
| 521 | + $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN '.$node[$left].' AND '.$node[$right]); |
|
| 522 | + $this->_sync($Model, $nextNode[$left] - $node[$left], '-', 'BETWEEN '.$nextNode[$left].' AND '.$nextNode[$right]); |
|
| 523 | + $this->_sync($Model, $edge - $node[$left] - ($nextNode[$right] - $nextNode[$left]), '-', '> '.$edge); |
|
| 524 | 524 | |
| 525 | 525 | if (is_int($number)) { |
| 526 | 526 | $number--; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | if (is_array($id)) { |
| 547 | 547 | extract(array_merge(array('id' => null), $id)); |
| 548 | 548 | } |
| 549 | - if (!$number) { |
|
| 549 | + if ( ! $number) { |
|
| 550 | 550 | return false; |
| 551 | 551 | } |
| 552 | 552 | if (empty($id)) { |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | return false; |
| 579 | 579 | } |
| 580 | 580 | $edge = $this->_getMax($Model, $scope, $right, $recursive); |
| 581 | - $this->_sync($Model, $edge - $previousNode[$left] + 1, '+', 'BETWEEN ' . $previousNode[$left] . ' AND ' . $previousNode[$right]); |
|
| 582 | - $this->_sync($Model, $node[$left] - $previousNode[$left], '-', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right]); |
|
| 583 | - $this->_sync($Model, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> ' . $edge); |
|
| 581 | + $this->_sync($Model, $edge - $previousNode[$left] + 1, '+', 'BETWEEN '.$previousNode[$left].' AND '.$previousNode[$right]); |
|
| 582 | + $this->_sync($Model, $node[$left] - $previousNode[$left], '-', 'BETWEEN '.$node[$left].' AND '.$node[$right]); |
|
| 583 | + $this->_sync($Model, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> '.$edge); |
|
| 584 | 584 | if (is_int($number)) { |
| 585 | 585 | $number--; |
| 586 | 586 | } |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | if ($missingParents) { |
| 628 | 628 | if ($missingParentAction === 'return') { |
| 629 | 629 | foreach ($missingParents as $id => $display) { |
| 630 | - $this->errors[] = 'cannot find the parent for ' . $Model->alias . ' with id ' . $id . '(' . $display . ')'; |
|
| 630 | + $this->errors[] = 'cannot find the parent for '.$Model->alias.' with id '.$id.'('.$display.')'; |
|
| 631 | 631 | } |
| 632 | 632 | return false; |
| 633 | 633 | } elseif ($missingParentAction === 'delete') { |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | $children = $Model->find('all', $params); |
| 682 | - $hasChildren = (bool)$children; |
|
| 682 | + $hasChildren = (bool) $children; |
|
| 683 | 683 | |
| 684 | 684 | if ($parentId !== null) { |
| 685 | 685 | if ($hasChildren) { |
@@ -746,13 +746,13 @@ discard block |
||
| 746 | 746 | public function reorder(Model $Model, $options = array()) { |
| 747 | 747 | $options = array_merge(array('id' => null, 'field' => $Model->displayField, 'order' => 'ASC', 'verify' => true), $options); |
| 748 | 748 | extract($options); |
| 749 | - if ($verify && !$this->verify($Model)) { |
|
| 749 | + if ($verify && ! $this->verify($Model)) { |
|
| 750 | 750 | return false; |
| 751 | 751 | } |
| 752 | 752 | $verify = false; |
| 753 | 753 | extract($this->settings[$Model->alias]); |
| 754 | 754 | $fields = array($Model->primaryKey, $field, $left, $right); |
| 755 | - $sort = $field . ' ' . $order; |
|
| 755 | + $sort = $field.' '.$order; |
|
| 756 | 756 | $nodes = $this->children($Model, $id, true, $fields, $sort, null, null, $recursive); |
| 757 | 757 | |
| 758 | 758 | $cacheQueries = $Model->cacheQueries; |
@@ -815,8 +815,8 @@ discard block |
||
| 815 | 815 | array($parent => $db->value($node[$parent], $parent)), |
| 816 | 816 | array($Model->escapeField($parent) => $node[$Model->primaryKey]) |
| 817 | 817 | ); |
| 818 | - $this->_sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1)); |
|
| 819 | - $this->_sync($Model, 2, '-', '> ' . ($node[$right])); |
|
| 818 | + $this->_sync($Model, 1, '-', 'BETWEEN '.($node[$left] + 1).' AND '.($node[$right] - 1)); |
|
| 819 | + $this->_sync($Model, 2, '-', '> '.($node[$right])); |
|
| 820 | 820 | $Model->id = $id; |
| 821 | 821 | |
| 822 | 822 | if ($delete) { |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | */ |
| 854 | 854 | public function verify(Model $Model) { |
| 855 | 855 | extract($this->settings[$Model->alias]); |
| 856 | - if (!$Model->find('count', array('conditions' => $scope))) { |
|
| 856 | + if ( ! $Model->find('count', array('conditions' => $scope))) { |
|
| 857 | 857 | return true; |
| 858 | 858 | } |
| 859 | 859 | $min = $this->_getMin($Model, $scope, $left, $recursive); |
@@ -865,14 +865,14 @@ discard block |
||
| 865 | 865 | $scope, 'OR' => array($Model->escapeField($left) => $i, $Model->escapeField($right) => $i) |
| 866 | 866 | ))); |
| 867 | 867 | if ($count != 1) { |
| 868 | - if (!$count) { |
|
| 868 | + if ( ! $count) { |
|
| 869 | 869 | $errors[] = array('index', $i, 'missing'); |
| 870 | 870 | } else { |
| 871 | 871 | $errors[] = array('index', $i, 'duplicate'); |
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | - $node = $Model->find('first', array('conditions' => array($scope, $Model->escapeField($right) . '< ' . $Model->escapeField($left)), 'recursive' => 0)); |
|
| 875 | + $node = $Model->find('first', array('conditions' => array($scope, $Model->escapeField($right).'< '.$Model->escapeField($left)), 'recursive' => 0)); |
|
| 876 | 876 | if ($node) { |
| 877 | 877 | $errors[] = array('node', $node[$Model->alias][$Model->primaryKey], 'left greater than right.'); |
| 878 | 878 | } |
@@ -891,17 +891,17 @@ discard block |
||
| 891 | 891 | $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], |
| 892 | 892 | 'left and right values identical'); |
| 893 | 893 | } elseif ($instance[$Model->alias][$parent]) { |
| 894 | - if (!$instance['VerifyParent'][$Model->primaryKey]) { |
|
| 894 | + if ( ! $instance['VerifyParent'][$Model->primaryKey]) { |
|
| 895 | 895 | $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], |
| 896 | - 'The parent node ' . $instance[$Model->alias][$parent] . ' doesn\'t exist'); |
|
| 896 | + 'The parent node '.$instance[$Model->alias][$parent].' doesn\'t exist'); |
|
| 897 | 897 | } elseif ($instance[$Model->alias][$left] < $instance['VerifyParent'][$left]) { |
| 898 | 898 | $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], |
| 899 | - 'left less than parent (node ' . $instance['VerifyParent'][$Model->primaryKey] . ').'); |
|
| 899 | + 'left less than parent (node '.$instance['VerifyParent'][$Model->primaryKey].').'); |
|
| 900 | 900 | } elseif ($instance[$Model->alias][$right] > $instance['VerifyParent'][$right]) { |
| 901 | 901 | $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], |
| 902 | - 'right greater than parent (node ' . $instance['VerifyParent'][$Model->primaryKey] . ').'); |
|
| 902 | + 'right greater than parent (node '.$instance['VerifyParent'][$Model->primaryKey].').'); |
|
| 903 | 903 | } |
| 904 | - } elseif ($Model->find('count', array('conditions' => array($scope, $Model->escapeField($left) . ' <' => $instance[$Model->alias][$left], $Model->escapeField($right) . ' >' => $instance[$Model->alias][$right]), 'recursive' => 0))) { |
|
| 904 | + } elseif ($Model->find('count', array('conditions' => array($scope, $Model->escapeField($left).' <' => $instance[$Model->alias][$left], $Model->escapeField($right).' >' => $instance[$Model->alias][$right]), 'recursive' => 0))) { |
|
| 905 | 905 | $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], 'The parent field is blank, but has a parent'); |
| 906 | 906 | } |
| 907 | 907 | } |
@@ -933,8 +933,8 @@ discard block |
||
| 933 | 933 | $edge = $this->_getMax($Model, $scope, $right, $recursive, $created); |
| 934 | 934 | |
| 935 | 935 | if (empty($parentId)) { |
| 936 | - $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created); |
|
| 937 | - $this->_sync($Model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created); |
|
| 936 | + $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN '.$node[$left].' AND '.$node[$right], $created); |
|
| 937 | + $this->_sync($Model, $node[$right] - $node[$left] + 1, '-', '> '.$node[$left], $created); |
|
| 938 | 938 | } else { |
| 939 | 939 | $values = $Model->find('first', array( |
| 940 | 940 | 'conditions' => array($scope, $Model->escapeField() => $parentId), |
@@ -958,27 +958,27 @@ discard block |
||
| 958 | 958 | return false; |
| 959 | 959 | } |
| 960 | 960 | if (empty($node[$left]) && empty($node[$right])) { |
| 961 | - $this->_sync($Model, 2, '+', '>= ' . $parentNode[$right], $created); |
|
| 961 | + $this->_sync($Model, 2, '+', '>= '.$parentNode[$right], $created); |
|
| 962 | 962 | $result = $Model->save( |
| 963 | 963 | array($left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId), |
| 964 | 964 | array('validate' => false, 'callbacks' => false) |
| 965 | 965 | ); |
| 966 | 966 | $Model->data = $result; |
| 967 | 967 | } else { |
| 968 | - $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created); |
|
| 968 | + $this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN '.$node[$left].' AND '.$node[$right], $created); |
|
| 969 | 969 | $diff = $node[$right] - $node[$left] + 1; |
| 970 | 970 | |
| 971 | 971 | if ($node[$left] > $parentNode[$left]) { |
| 972 | 972 | if ($node[$right] < $parentNode[$right]) { |
| 973 | - $this->_sync($Model, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $created); |
|
| 974 | - $this->_sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> ' . $edge, $created); |
|
| 973 | + $this->_sync($Model, $diff, '-', 'BETWEEN '.$node[$right].' AND '.($parentNode[$right] - 1), $created); |
|
| 974 | + $this->_sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> '.$edge, $created); |
|
| 975 | 975 | } else { |
| 976 | - $this->_sync($Model, $diff, '+', 'BETWEEN ' . $parentNode[$right] . ' AND ' . $node[$right], $created); |
|
| 977 | - $this->_sync($Model, $edge - $parentNode[$right] + 1, '-', '> ' . $edge, $created); |
|
| 976 | + $this->_sync($Model, $diff, '+', 'BETWEEN '.$parentNode[$right].' AND '.$node[$right], $created); |
|
| 977 | + $this->_sync($Model, $edge - $parentNode[$right] + 1, '-', '> '.$edge, $created); |
|
| 978 | 978 | } |
| 979 | 979 | } else { |
| 980 | - $this->_sync($Model, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $created); |
|
| 981 | - $this->_sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> ' . $edge, $created); |
|
| 980 | + $this->_sync($Model, $diff, '-', 'BETWEEN '.$node[$right].' AND '.($parentNode[$right] - 1), $created); |
|
| 981 | + $this->_sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> '.$edge, $created); |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | } |
@@ -999,10 +999,10 @@ discard block |
||
| 999 | 999 | $db = ConnectionManager::getDataSource($Model->useDbConfig); |
| 1000 | 1000 | if ($created) { |
| 1001 | 1001 | if (is_string($scope)) { |
| 1002 | - $scope .= " AND " . $Model->escapeField() . " <> "; |
|
| 1002 | + $scope .= " AND ".$Model->escapeField()." <> "; |
|
| 1003 | 1003 | $scope .= $db->value($Model->id, $Model->getColumnType($Model->primaryKey)); |
| 1004 | 1004 | } else { |
| 1005 | - $scope['NOT'][$Model->alias . '.' . $Model->primaryKey] = $Model->id; |
|
| 1005 | + $scope['NOT'][$Model->alias.'.'.$Model->primaryKey] = $Model->id; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | } |
| 1008 | 1008 | $name = $Model->escapeField($right); |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | $field = $right; |
| 1060 | 1060 | } |
| 1061 | 1061 | if (is_string($conditions)) { |
| 1062 | - $conditions = array($Model->escapeField($field) . " {$conditions}"); |
|
| 1062 | + $conditions = array($Model->escapeField($field)." {$conditions}"); |
|
| 1063 | 1063 | } |
| 1064 | 1064 | if (($scope !== '1 = 1' && $scope !== true) && $scope) { |
| 1065 | 1065 | $conditions[] = $scope; |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | if ($created) { |
| 1068 | 1068 | $conditions['NOT'][$Model->escapeField()] = $Model->id; |
| 1069 | 1069 | } |
| 1070 | - $Model->updateAll(array($Model->escapeField($field) => $Model->escapeField($field) . ' ' . $dir . ' ' . $shift), $conditions); |
|
| 1070 | + $Model->updateAll(array($Model->escapeField($field) => $Model->escapeField($field).' '.$dir.' '.$shift), $conditions); |
|
| 1071 | 1071 | $Model->recursive = $ModelRecursive; |
| 1072 | 1072 | } |
| 1073 | 1073 | |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | * |
| 74 | 74 | * @param string $behavior |
| 75 | 75 | * @param array $config |
| 76 | - * @return void |
|
| 76 | + * @return boolean |
|
| 77 | 77 | * @deprecated Will be removed in 3.0. Replaced with load(). |
| 78 | 78 | */ |
| 79 | 79 | public function attach($behavior, $config = array()) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function init($modelName, $behaviors = array()) { |
| 62 | 62 | $this->modelName = $modelName; |
| 63 | 63 | |
| 64 | - if (!empty($behaviors)) { |
|
| 64 | + if ( ! empty($behaviors)) { |
|
| 65 | 65 | foreach (BehaviorCollection::normalizeObjectArray($behaviors) as $config) { |
| 66 | 66 | $this->load($config['class'], $config['settings']); |
| 67 | 67 | } |
@@ -110,21 +110,21 @@ discard block |
||
| 110 | 110 | unset($config['enabled'], $config['className'], $config['priority']); |
| 111 | 111 | |
| 112 | 112 | list($plugin, $name) = pluginSplit($behavior, true); |
| 113 | - if (!isset($alias)) { |
|
| 113 | + if ( ! isset($alias)) { |
|
| 114 | 114 | $alias = $name; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $class = $name . 'Behavior'; |
|
| 117 | + $class = $name.'Behavior'; |
|
| 118 | 118 | |
| 119 | - App::uses($class, $plugin . 'Model/Behavior'); |
|
| 120 | - if (!class_exists($class)) { |
|
| 119 | + App::uses($class, $plugin.'Model/Behavior'); |
|
| 120 | + if ( ! class_exists($class)) { |
|
| 121 | 121 | throw new MissingBehaviorException(array( |
| 122 | 122 | 'class' => $class, |
| 123 | 123 | 'plugin' => substr($plugin, 0, -1) |
| 124 | 124 | )); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if (!isset($this->{$alias})) { |
|
| 127 | + if ( ! isset($this->{$alias})) { |
|
| 128 | 128 | if (ClassRegistry::isKeySet($class)) { |
| 129 | 129 | $this->_loaded[$alias] = ClassRegistry::getObject($class); |
| 130 | 130 | } else { |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | 157 | foreach ($methods as $m) { |
| 158 | - if (!isset($parentMethods[$m])) { |
|
| 158 | + if ( ! isset($parentMethods[$m])) { |
|
| 159 | 159 | $methodAllowed = ( |
| 160 | - $m[0] !== '_' && !array_key_exists($m, $this->_methods) && |
|
| 161 | - !in_array($m, $callbacks) |
|
| 160 | + $m[0] !== '_' && ! array_key_exists($m, $this->_methods) && |
|
| 161 | + ! in_array($m, $callbacks) |
|
| 162 | 162 | ); |
| 163 | 163 | if ($methodAllowed) { |
| 164 | 164 | $this->_methods[$m] = array($alias, $m); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | if ($configDisabled) { |
| 170 | 170 | $this->disable($alias); |
| 171 | - } elseif (!$this->enabled($alias)) { |
|
| 171 | + } elseif ( ! $this->enabled($alias)) { |
|
| 172 | 172 | $this->enable($alias); |
| 173 | 173 | } else { |
| 174 | 174 | $this->setPriority($alias, $priority); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | return $callback ? $this->_methods[$method] : true; |
| 264 | 264 | } |
| 265 | 265 | foreach ($this->_mappedMethods as $pattern => $target) { |
| 266 | - if (preg_match($pattern . 'i', $method)) { |
|
| 266 | + if (preg_match($pattern.'i', $method)) { |
|
| 267 | 267 | if ($callback) { |
| 268 | 268 | $target[] = $method; |
| 269 | 269 | return $target; |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | /** |
| 306 | 306 | * Returns last occurred error as a string, if any. |
| 307 | 307 | * |
| 308 | - * @return mixed Error description as a string, or false. |
|
| 308 | + * @return string|false Error description as a string, or false. |
|
| 309 | 309 | */ |
| 310 | 310 | public static function error() { |
| 311 | 311 | if (self::$lastError) { |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | * Find the handler class and make sure it implements the correct interface. |
| 526 | 526 | * |
| 527 | 527 | * @param string $handler |
| 528 | - * @return void |
|
| 528 | + * @return CakeSessionHandlerInterface |
|
| 529 | 529 | * @throws CakeSessionException |
| 530 | 530 | */ |
| 531 | 531 | protected static function _getHandler($handler) { |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | self::$time = time(); |
| 138 | 138 | |
| 139 | 139 | if (env('HTTP_USER_AGENT')) { |
| 140 | - self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); |
|
| 140 | + self::$_userAgent = md5(env('HTTP_USER_AGENT').Configure::read('Security.salt')); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | self::_setPath($base); |
| 144 | 144 | self::_setHost(env('HTTP_HOST')); |
| 145 | 145 | |
| 146 | - if (!self::$_initialized) { |
|
| 146 | + if ( ! self::$_initialized) { |
|
| 147 | 147 | register_shutdown_function('session_write_close'); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $id = self::id(); |
| 197 | 197 | self::_startSession(); |
| 198 | 198 | |
| 199 | - if (!$id && self::started()) { |
|
| 199 | + if ( ! $id && self::started()) { |
|
| 200 | 200 | self::_checkValid(); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return boolean True if variable is there |
| 222 | 222 | */ |
| 223 | 223 | public static function check($name = null) { |
| 224 | - if (!self::start()) { |
|
| 224 | + if ( ! self::start()) { |
|
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | if (empty($name)) { |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | public static function delete($name) { |
| 265 | 265 | if (self::check($name)) { |
| 266 | 266 | self::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); |
| 267 | - return !self::check($name); |
|
| 267 | + return ! self::check($name); |
|
| 268 | 268 | } |
| 269 | 269 | return false; |
| 270 | 270 | } |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | * @return void |
| 278 | 278 | */ |
| 279 | 279 | protected static function _overwrite(&$old, $new) { |
| 280 | - if (!empty($old)) { |
|
| 280 | + if ( ! empty($old)) { |
|
| 281 | 281 | foreach ($old as $key => $var) { |
| 282 | - if (!isset($new[$key])) { |
|
| 282 | + if ( ! isset($new[$key])) { |
|
| 283 | 283 | unset($old[$key]); |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @return string Error as string |
| 297 | 297 | */ |
| 298 | 298 | protected static function _error($errorNumber) { |
| 299 | - if (!is_array(self::$error) || !array_key_exists($errorNumber, self::$error)) { |
|
| 299 | + if ( ! is_array(self::$error) || ! array_key_exists($errorNumber, self::$error)) { |
|
| 300 | 300 | return false; |
| 301 | 301 | } |
| 302 | 302 | return self::$error[$errorNumber]; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @return mixed The value of the session variable |
| 372 | 372 | */ |
| 373 | 373 | public static function read($name = null) { |
| 374 | - if (!self::start()) { |
|
| 374 | + if ( ! self::start()) { |
|
| 375 | 375 | return false; |
| 376 | 376 | } |
| 377 | 377 | if ($name === null) { |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | * @return mixed Full $_SESSION array, or false on error. |
| 395 | 395 | */ |
| 396 | 396 | protected static function _returnSessionVars() { |
| 397 | - if (!empty($_SESSION)) { |
|
| 397 | + if ( ! empty($_SESSION)) { |
|
| 398 | 398 | return $_SESSION; |
| 399 | 399 | } |
| 400 | 400 | self::_setError(2, 'No Session vars set'); |
@@ -409,14 +409,14 @@ discard block |
||
| 409 | 409 | * @return boolean True if the write was successful, false if the write failed |
| 410 | 410 | */ |
| 411 | 411 | public static function write($name, $value = null) { |
| 412 | - if (!self::start()) { |
|
| 412 | + if ( ! self::start()) { |
|
| 413 | 413 | return false; |
| 414 | 414 | } |
| 415 | 415 | if (empty($name)) { |
| 416 | 416 | return false; |
| 417 | 417 | } |
| 418 | 418 | $write = $name; |
| 419 | - if (!is_array($name)) { |
|
| 419 | + if ( ! is_array($name)) { |
|
| 420 | 420 | $write = array($name => $value); |
| 421 | 421 | } |
| 422 | 422 | foreach ($write as $key => $val) { |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @return void |
| 435 | 435 | */ |
| 436 | 436 | public static function destroy() { |
| 437 | - if (!self::started()) { |
|
| 437 | + if ( ! self::started()) { |
|
| 438 | 438 | self::_startSession(); |
| 439 | 439 | } |
| 440 | 440 | |
@@ -472,30 +472,30 @@ discard block |
||
| 472 | 472 | $sessionConfig = Hash::merge($defaults, $sessionConfig); |
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | - if (!isset($sessionConfig['ini']['session.cookie_secure']) && env('HTTPS')) { |
|
| 475 | + if ( ! isset($sessionConfig['ini']['session.cookie_secure']) && env('HTTPS')) { |
|
| 476 | 476 | $sessionConfig['ini']['session.cookie_secure'] = 1; |
| 477 | 477 | } |
| 478 | - if (isset($sessionConfig['timeout']) && !isset($sessionConfig['cookieTimeout'])) { |
|
| 478 | + if (isset($sessionConfig['timeout']) && ! isset($sessionConfig['cookieTimeout'])) { |
|
| 479 | 479 | $sessionConfig['cookieTimeout'] = $sessionConfig['timeout']; |
| 480 | 480 | } |
| 481 | - if (!isset($sessionConfig['ini']['session.cookie_lifetime'])) { |
|
| 481 | + if ( ! isset($sessionConfig['ini']['session.cookie_lifetime'])) { |
|
| 482 | 482 | $sessionConfig['ini']['session.cookie_lifetime'] = $sessionConfig['cookieTimeout'] * 60; |
| 483 | 483 | } |
| 484 | - if (!isset($sessionConfig['ini']['session.name'])) { |
|
| 484 | + if ( ! isset($sessionConfig['ini']['session.name'])) { |
|
| 485 | 485 | $sessionConfig['ini']['session.name'] = $sessionConfig['cookie']; |
| 486 | 486 | } |
| 487 | - if (!empty($sessionConfig['handler'])) { |
|
| 487 | + if ( ! empty($sessionConfig['handler'])) { |
|
| 488 | 488 | $sessionConfig['ini']['session.save_handler'] = 'user'; |
| 489 | 489 | } |
| 490 | - if (!isset($sessionConfig['ini']['session.gc_maxlifetime'])) { |
|
| 490 | + if ( ! isset($sessionConfig['ini']['session.gc_maxlifetime'])) { |
|
| 491 | 491 | $sessionConfig['ini']['session.gc_maxlifetime'] = $sessionConfig['timeout'] * 60; |
| 492 | 492 | } |
| 493 | - if (!isset($sessionConfig['ini']['session.cookie_httponly'])) { |
|
| 493 | + if ( ! isset($sessionConfig['ini']['session.cookie_httponly'])) { |
|
| 494 | 494 | $sessionConfig['ini']['session.cookie_httponly'] = 1; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | if (empty($_SESSION)) { |
| 498 | - if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) { |
|
| 498 | + if ( ! empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) { |
|
| 499 | 499 | foreach ($sessionConfig['ini'] as $setting => $value) { |
| 500 | 500 | if (ini_set($setting, $value) === false) { |
| 501 | 501 | throw new CakeSessionException(__d('cake_dev', 'Unable to configure the session, setting %s failed.', $setting)); |
@@ -503,10 +503,10 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | - if (!empty($sessionConfig['handler']) && !isset($sessionConfig['handler']['engine'])) { |
|
| 506 | + if ( ! empty($sessionConfig['handler']) && ! isset($sessionConfig['handler']['engine'])) { |
|
| 507 | 507 | call_user_func_array('session_set_save_handler', $sessionConfig['handler']); |
| 508 | 508 | } |
| 509 | - if (!empty($sessionConfig['handler']['engine'])) { |
|
| 509 | + if ( ! empty($sessionConfig['handler']['engine'])) { |
|
| 510 | 510 | $handler = self::_getHandler($sessionConfig['handler']['engine']); |
| 511 | 511 | session_set_save_handler( |
| 512 | 512 | array($handler, 'open'), |
@@ -530,8 +530,8 @@ discard block |
||
| 530 | 530 | */ |
| 531 | 531 | protected static function _getHandler($handler) { |
| 532 | 532 | list($plugin, $class) = pluginSplit($handler, true); |
| 533 | - App::uses($class, $plugin . 'Model/Datasource/Session'); |
|
| 534 | - if (!class_exists($class)) { |
|
| 533 | + App::uses($class, $plugin.'Model/Datasource/Session'); |
|
| 534 | + if ( ! class_exists($class)) { |
|
| 535 | 535 | throw new CakeSessionException(__d('cake_dev', 'Could not load %s to handle the session.', $class)); |
| 536 | 536 | } |
| 537 | 537 | $handler = new $class(); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | 'session.serialize_handler' => 'php', |
| 567 | 567 | 'session.use_cookies' => 1, |
| 568 | 568 | 'session.cookie_path' => self::$path, |
| 569 | - 'session.save_path' => TMP . 'sessions', |
|
| 569 | + 'session.save_path' => TMP.'sessions', |
|
| 570 | 570 | 'session.save_handler' => 'files' |
| 571 | 571 | ) |
| 572 | 572 | ), |