@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * if set to false, the response will be set to private |
814 | 814 | * if no value is provided, it will return whether the response is sharable or not |
815 | 815 | * @param integer $time time in seconds after which the response should no longer be considered fresh |
816 | - * @return boolean |
|
816 | + * @return null|boolean |
|
817 | 817 | */ |
818 | 818 | public function sharable($public = null, $time = null) { |
819 | 819 | if ($public === null) { |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | * If called with no parameters, this function will return the current max-age value if any |
849 | 849 | * |
850 | 850 | * @param integer $seconds if null, the method will return the current s-maxage value |
851 | - * @return integer |
|
851 | + * @return string|null |
|
852 | 852 | */ |
853 | 853 | public function sharedMaxAge($seconds = null) { |
854 | 854 | if ($seconds !== null) { |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | * If called with no parameters, this function will return the current max-age value if any |
869 | 869 | * |
870 | 870 | * @param integer $seconds if null, the method will return the current max-age value |
871 | - * @return integer |
|
871 | + * @return string|null |
|
872 | 872 | */ |
873 | 873 | public function maxAge($seconds = null) { |
874 | 874 | if ($seconds !== null) { |
@@ -888,8 +888,6 @@ discard block |
||
888 | 888 | * with the origin. |
889 | 889 | * If called with no parameters, this function will return whether must-revalidate is present. |
890 | 890 | * |
891 | - * @param integer $seconds if null, the method will return the current |
|
892 | - * must-revalidate value |
|
893 | 891 | * @return boolean |
894 | 892 | */ |
895 | 893 | public function mustRevalidate($enable = null) { |
@@ -1029,7 +1027,6 @@ discard block |
||
1029 | 1027 | * |
1030 | 1028 | * If no parameters are passed, current Etag header is returned. |
1031 | 1029 | * |
1032 | - * @param string $hash the unique has that identifies this response |
|
1033 | 1030 | * @param boolean $weak whether the response is semantically the same as |
1034 | 1031 | * other with the same hash or not |
1035 | 1032 | * @return string |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if (isset($options['type'])) { |
394 | 394 | $this->type($options['type']); |
395 | 395 | } |
396 | - if (!isset($options['charset'])) { |
|
396 | + if ( ! isset($options['charset'])) { |
|
397 | 397 | $options['charset'] = Configure::read('App.encoding'); |
398 | 398 | } |
399 | 399 | $this->charset($options['charset']); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $this->_setContentLength(); |
418 | 418 | $this->_setContentType(); |
419 | 419 | foreach ($this->_headers as $header => $values) { |
420 | - foreach ((array)$values as $value) { |
|
420 | + foreach ((array) $values as $value) { |
|
421 | 421 | $this->_sendHeader($header, $value); |
422 | 422 | } |
423 | 423 | } |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @return void |
493 | 493 | */ |
494 | 494 | protected function _setContentLength() { |
495 | - $shouldSetLength = !isset($this->_headers['Content-Length']) && !in_array($this->_status, range(301, 307)); |
|
495 | + $shouldSetLength = ! isset($this->_headers['Content-Length']) && ! in_array($this->_status, range(301, 307)); |
|
496 | 496 | if (isset($this->_headers['Content-Length']) && $this->_headers['Content-Length'] === false) { |
497 | 497 | unset($this->_headers['Content-Length']); |
498 | 498 | return; |
499 | 499 | } |
500 | - if ($shouldSetLength && !$this->outputCompressed()) { |
|
500 | + if ($shouldSetLength && ! $this->outputCompressed()) { |
|
501 | 501 | $offset = ob_get_level() ? ob_get_length() : 0; |
502 | 502 | if (ini_get('mbstring.func_overload') & 2 && function_exists('mb_strlen')) { |
503 | 503 | $this->length($offset + mb_strlen($this->_body, '8bit')); |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return void |
516 | 516 | */ |
517 | 517 | protected function _sendHeader($name, $value = null) { |
518 | - if (!headers_sent()) { |
|
518 | + if ( ! headers_sent()) { |
|
519 | 519 | if ($value === null) { |
520 | 520 | header($name); |
521 | 521 | } else { |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | if ($code === null) { |
621 | 621 | return $this->_status; |
622 | 622 | } |
623 | - if (!isset($this->_statusCodes[$code])) { |
|
623 | + if ( ! isset($this->_statusCodes[$code])) { |
|
624 | 624 | throw new CakeException(__d('cake_dev', 'Unknown status code')); |
625 | 625 | } |
626 | 626 | return $this->_status = $code; |
@@ -664,13 +664,13 @@ discard block |
||
664 | 664 | if (is_array($code)) { |
665 | 665 | $codes = array_keys($code); |
666 | 666 | $min = min($codes); |
667 | - if (!is_int($min) || $min < 100 || max($codes) > 999) { |
|
667 | + if ( ! is_int($min) || $min < 100 || max($codes) > 999) { |
|
668 | 668 | throw new CakeException(__d('cake_dev', 'Invalid status code')); |
669 | 669 | } |
670 | 670 | $this->_statusCodes = $code + $this->_statusCodes; |
671 | 671 | return true; |
672 | 672 | } |
673 | - if (!isset($this->_statusCodes[$code])) { |
|
673 | + if ( ! isset($this->_statusCodes[$code])) { |
|
674 | 674 | return null; |
675 | 675 | } |
676 | 676 | return array($code => $this->_statusCodes[$code]); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | } |
751 | 751 | |
752 | 752 | foreach ($this->_mimeTypes as $alias => $types) { |
753 | - if (in_array($ctype, (array)$types)) { |
|
753 | + if (in_array($ctype, (array) $types)) { |
|
754 | 754 | return $alias; |
755 | 755 | } |
756 | 756 | } |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | public function disableCache() { |
780 | 780 | $this->header(array( |
781 | 781 | 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', |
782 | - 'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT", |
|
782 | + 'Last-Modified' => gmdate("D, d M Y H:i:s")." GMT", |
|
783 | 783 | 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' |
784 | 784 | )); |
785 | 785 | } |
@@ -792,11 +792,11 @@ discard block |
||
792 | 792 | * @return void |
793 | 793 | */ |
794 | 794 | public function cache($since, $time = '+1 day') { |
795 | - if (!is_int($time)) { |
|
795 | + if ( ! is_int($time)) { |
|
796 | 796 | $time = strtotime($time); |
797 | 797 | } |
798 | 798 | $this->header(array( |
799 | - 'Date' => gmdate("D, j M Y G:i:s ", time()) . 'GMT' |
|
799 | + 'Date' => gmdate("D, j M Y G:i:s ", time()).'GMT' |
|
800 | 800 | )); |
801 | 801 | $this->modified($since); |
802 | 802 | $this->expires($time); |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $public = array_key_exists('public', $this->_cacheDirectives); |
821 | 821 | $private = array_key_exists('private', $this->_cacheDirectives); |
822 | 822 | $noCache = array_key_exists('no-cache', $this->_cacheDirectives); |
823 | - if (!$public && !$private && !$noCache) { |
|
823 | + if ( ! $public && ! $private && ! $noCache) { |
|
824 | 824 | return null; |
825 | 825 | } |
826 | 826 | $sharable = $public || ! ($private || $noCache); |
@@ -835,10 +835,10 @@ discard block |
||
835 | 835 | unset($this->_cacheDirectives['public']); |
836 | 836 | $this->maxAge($time); |
837 | 837 | } |
838 | - if (!$time) { |
|
838 | + if ( ! $time) { |
|
839 | 839 | $this->_setCacheControl(); |
840 | 840 | } |
841 | - return (bool)$public; |
|
841 | + return (bool) $public; |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | /** |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | public function expires($time = null) { |
937 | 937 | if ($time !== null) { |
938 | 938 | $date = $this->_getUTCDate($time); |
939 | - $this->_headers['Expires'] = $date->format('D, j M Y H:i:s') . ' GMT'; |
|
939 | + $this->_headers['Expires'] = $date->format('D, j M Y H:i:s').' GMT'; |
|
940 | 940 | } |
941 | 941 | if (isset($this->_headers['Expires'])) { |
942 | 942 | return $this->_headers['Expires']; |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | public function modified($time = null) { |
961 | 961 | if ($time !== null) { |
962 | 962 | $date = $this->_getUTCDate($time); |
963 | - $this->_headers['Last-Modified'] = $date->format('D, j M Y H:i:s') . ' GMT'; |
|
963 | + $this->_headers['Last-Modified'] = $date->format('D, j M Y H:i:s').' GMT'; |
|
964 | 964 | } |
965 | 965 | if (isset($this->_headers['Last-Modified'])) { |
966 | 966 | return $this->_headers['Last-Modified']; |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | */ |
1005 | 1005 | public function vary($cacheVariances = null) { |
1006 | 1006 | if ($cacheVariances !== null) { |
1007 | - $cacheVariances = (array)$cacheVariances; |
|
1007 | + $cacheVariances = (array) $cacheVariances; |
|
1008 | 1008 | $this->_headers['Vary'] = implode(', ', $cacheVariances); |
1009 | 1009 | } |
1010 | 1010 | if (isset($this->_headers['Vary'])) { |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * @return void |
1094 | 1094 | */ |
1095 | 1095 | public function download($filename) { |
1096 | - $this->header('Content-Disposition', 'attachment; filename="' . $filename . '"'); |
|
1096 | + $this->header('Content-Disposition', 'attachment; filename="'.$filename.'"'); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | /** |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | if (empty($checks)) { |
1154 | 1154 | return false; |
1155 | 1155 | } |
1156 | - $notModified = !in_array(false, $checks, true); |
|
1156 | + $notModified = ! in_array(false, $checks, true); |
|
1157 | 1157 | if ($notModified) { |
1158 | 1158 | $this->notModified(); |
1159 | 1159 | } |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | * @return string |
1168 | 1168 | */ |
1169 | 1169 | public function __toString() { |
1170 | - return (string)$this->_body; |
|
1170 | + return (string) $this->_body; |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | /** |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | if (is_string($options)) { |
1219 | - if (!isset($this->_cookies[$options])) { |
|
1219 | + if ( ! isset($this->_cookies[$options])) { |
|
1220 | 1220 | return null; |
1221 | 1221 | } |
1222 | 1222 | return $this->_cookies[$options]; |
@@ -1266,12 +1266,12 @@ discard block |
||
1266 | 1266 | )); |
1267 | 1267 | } |
1268 | 1268 | |
1269 | - if (!is_file($path)) { |
|
1270 | - $path = APP . $path; |
|
1269 | + if ( ! is_file($path)) { |
|
1270 | + $path = APP.$path; |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | $file = new File($path); |
1274 | - if (!$file->exists() || !$file->readable()) { |
|
1274 | + if ( ! $file->exists() || ! $file->readable()) { |
|
1275 | 1275 | if (Configure::read('debug')) { |
1276 | 1276 | throw new NotFoundException(__d('cake_dev', 'The requested file %s was not found or not readable', $path)); |
1277 | 1277 | } |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | |
1281 | 1281 | $extension = strtolower($file->ext()); |
1282 | 1282 | $download = $options['download']; |
1283 | - if ((!$extension || $this->type($extension) === false) && $download === null) { |
|
1283 | + if (( ! $extension || $this->type($extension) === false) && $download === null) { |
|
1284 | 1284 | $download = true; |
1285 | 1285 | } |
1286 | 1286 | |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | $contentType = 'application/force-download'; |
1295 | 1295 | } |
1296 | 1296 | |
1297 | - if (!empty($contentType)) { |
|
1297 | + if ( ! empty($contentType)) { |
|
1298 | 1298 | $this->type($contentType); |
1299 | 1299 | } |
1300 | 1300 | if ($options['name'] === null) { |
@@ -1347,14 +1347,14 @@ discard block |
||
1347 | 1347 | if ($start > $end || $end > $lastByte || $start > $lastByte) { |
1348 | 1348 | $this->statusCode(416); |
1349 | 1349 | $this->header(array( |
1350 | - 'Content-Range' => 'bytes 0-' . $lastByte . '/' . $fileSize |
|
1350 | + 'Content-Range' => 'bytes 0-'.$lastByte.'/'.$fileSize |
|
1351 | 1351 | )); |
1352 | 1352 | return; |
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | $this->header(array( |
1356 | 1356 | 'Content-Length' => $end - $start + 1, |
1357 | - 'Content-Range' => 'bytes ' . $start . '-' . $end . '/' . $fileSize |
|
1357 | + 'Content-Range' => 'bytes '.$start.'-'.$end.'/'.$fileSize |
|
1358 | 1358 | )); |
1359 | 1359 | |
1360 | 1360 | $this->statusCode(206); |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | $bufferSize = 8192; |
1384 | 1384 | set_time_limit(0); |
1385 | 1385 | session_write_close(); |
1386 | - while (!feof($file->handle)) { |
|
1387 | - if (!$this->_isActive()) { |
|
1386 | + while ( ! feof($file->handle)) { |
|
1387 | + if ( ! $this->_isActive()) { |
|
1388 | 1388 | $file->close(); |
1389 | 1389 | return false; |
1390 | 1390 | } |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | $bufferSize = $end - $offset + 1; |
1397 | 1397 | } |
1398 | 1398 | echo fread($file->handle, $bufferSize); |
1399 | - if (!$compress) { |
|
1399 | + if ( ! $compress) { |
|
1400 | 1400 | $this->_flushBuffer(); |
1401 | 1401 | } |
1402 | 1402 | } |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | * @return boolean |
1411 | 1411 | */ |
1412 | 1412 | protected function _isActive() { |
1413 | - return connection_status() === CONNECTION_NORMAL && !connection_aborted(); |
|
1413 | + return connection_status() === CONNECTION_NORMAL && ! connection_aborted(); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | /** |
@@ -288,7 +288,7 @@ |
||
288 | 288 | * established. |
289 | 289 | * |
290 | 290 | * @param integer $length Optional buffer length to read; defaults to 1024 |
291 | - * @return mixed Socket data |
|
291 | + * @return false|string Socket data |
|
292 | 292 | */ |
293 | 293 | public function read($length = 1024) { |
294 | 294 | if (!$this->connected) { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function __construct($config = array()) { |
118 | 118 | $this->config = array_merge($this->_baseConfig, $config); |
119 | - if (!is_numeric($this->config['protocol'])) { |
|
119 | + if ( ! is_numeric($this->config['protocol'])) { |
|
120 | 120 | $this->config['protocol'] = getprotobyname($this->config['protocol']); |
121 | 121 | } |
122 | 122 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $scheme = 'ssl://'; |
138 | 138 | } |
139 | 139 | |
140 | - if (!empty($this->config['context'])) { |
|
140 | + if ( ! empty($this->config['context'])) { |
|
141 | 141 | $context = stream_context_create($this->config['context']); |
142 | 142 | } else { |
143 | 143 | $context = stream_context_create(); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | set_error_handler(array($this, '_connectionErrorHandler')); |
152 | 152 | $this->connection = stream_socket_client( |
153 | - $scheme . $this->config['host'] . ':' . $this->config['port'], |
|
153 | + $scheme.$this->config['host'].':'.$this->config['port'], |
|
154 | 154 | $errNum, |
155 | 155 | $errStr, |
156 | 156 | $this->config['timeout'], |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | ); |
160 | 160 | restore_error_handler(); |
161 | 161 | |
162 | - if (!empty($errNum) || !empty($errStr)) { |
|
162 | + if ( ! empty($errNum) || ! empty($errStr)) { |
|
163 | 163 | $this->setLastError($errNum, $errStr); |
164 | 164 | throw new SocketException($errStr, $errNum); |
165 | 165 | } |
166 | 166 | |
167 | - if (!$this->connection && $this->_connectionErrors) { |
|
167 | + if ( ! $this->connection && $this->_connectionErrors) { |
|
168 | 168 | $message = implode("\n", $this->_connectionErrors); |
169 | 169 | throw new SocketException($message, E_WARNING); |
170 | 170 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return null|array Null when there is no connection, an array when there is. |
197 | 197 | */ |
198 | 198 | public function context() { |
199 | - if (!$this->connection) { |
|
199 | + if ( ! $this->connection) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | return stream_context_get_options($this->connection); |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return string Last error |
245 | 245 | */ |
246 | 246 | public function lastError() { |
247 | - if (!empty($this->lastError)) { |
|
248 | - return $this->lastError['num'] . ': ' . $this->lastError['str']; |
|
247 | + if ( ! empty($this->lastError)) { |
|
248 | + return $this->lastError['num'].': '.$this->lastError['str']; |
|
249 | 249 | } |
250 | 250 | return null; |
251 | 251 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @return boolean Success |
269 | 269 | */ |
270 | 270 | public function write($data) { |
271 | - if (!$this->connected) { |
|
272 | - if (!$this->connect()) { |
|
271 | + if ( ! $this->connected) { |
|
272 | + if ( ! $this->connect()) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | } |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | * @return mixed Socket data |
292 | 292 | */ |
293 | 293 | public function read($length = 1024) { |
294 | - if (!$this->connected) { |
|
295 | - if (!$this->connect()) { |
|
294 | + if ( ! $this->connected) { |
|
295 | + if ( ! $this->connect()) { |
|
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - if (!feof($this->connection)) { |
|
300 | + if ( ! feof($this->connection)) { |
|
301 | 301 | $buffer = fread($this->connection, $length); |
302 | 302 | $info = stream_get_meta_data($this->connection); |
303 | 303 | if ($info['timed_out']) { |
@@ -315,16 +315,16 @@ discard block |
||
315 | 315 | * @return boolean Success |
316 | 316 | */ |
317 | 317 | public function disconnect() { |
318 | - if (!is_resource($this->connection)) { |
|
318 | + if ( ! is_resource($this->connection)) { |
|
319 | 319 | $this->connected = false; |
320 | 320 | return true; |
321 | 321 | } |
322 | - $this->connected = !fclose($this->connection); |
|
322 | + $this->connected = ! fclose($this->connection); |
|
323 | 323 | |
324 | - if (!$this->connected) { |
|
324 | + if ( ! $this->connected) { |
|
325 | 325 | $this->connection = null; |
326 | 326 | } |
327 | - return !$this->connected; |
|
327 | + return ! $this->connected; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | * @see stream_socket_enable_crypto |
368 | 368 | */ |
369 | 369 | public function enableCrypto($type, $clientOrServer = 'client', $enable = true) { |
370 | - if (!array_key_exists($type . '_' . $clientOrServer, $this->_encryptMethods)) { |
|
370 | + if ( ! array_key_exists($type.'_'.$clientOrServer, $this->_encryptMethods)) { |
|
371 | 371 | throw new InvalidArgumentException(__d('cake_dev', 'Invalid encryption scheme chosen')); |
372 | 372 | } |
373 | 373 | $enableCryptoResult = false; |
374 | 374 | try { |
375 | - $enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, $this->_encryptMethods[$type . '_' . $clientOrServer]); |
|
375 | + $enableCryptoResult = stream_socket_enable_crypto($this->connection, $enable, $this->_encryptMethods[$type.'_'.$clientOrServer]); |
|
376 | 376 | } catch (Exception $e) { |
377 | 377 | $this->setLastError(null, $e->getMessage()); |
378 | 378 | throw new SocketException($e->getMessage()); |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * Add header for the message |
667 | 667 | * |
668 | 668 | * @param array $headers |
669 | - * @return object $this |
|
669 | + * @return CakeEmail $this |
|
670 | 670 | * @throws SocketException |
671 | 671 | */ |
672 | 672 | public function addHeaders($headers) { |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | * |
1309 | 1309 | * @param string $message Message to wrap |
1310 | 1310 | * @param integer $wrapLength The line length |
1311 | - * @return array Wrapped message |
|
1311 | + * @return string[] Wrapped message |
|
1312 | 1312 | */ |
1313 | 1313 | protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) { |
1314 | 1314 | if (strlen($message) === 0) { |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | /** |
1587 | 1587 | * Gets the text body types that are in this email message |
1588 | 1588 | * |
1589 | - * @return array Array of types. Valid types are 'text' and 'html' |
|
1589 | + * @return string[] Array of types. Valid types are 'text' and 'html' |
|
1590 | 1590 | */ |
1591 | 1591 | protected function _getTypes() { |
1592 | 1592 | $types = array($this->_emailFormat); |
@@ -1668,7 +1668,7 @@ discard block |
||
1668 | 1668 | /** |
1669 | 1669 | * Return the Content-Transfer Encoding value based on the set charset |
1670 | 1670 | * |
1671 | - * @return void |
|
1671 | + * @return string |
|
1672 | 1672 | */ |
1673 | 1673 | protected function _getContentTransferEncoding() { |
1674 | 1674 | $charset = strtoupper($this->charset); |
@@ -555,8 +555,8 @@ discard block |
||
555 | 555 | * @throws SocketException |
556 | 556 | */ |
557 | 557 | protected function _setEmail($varName, $email, $name) { |
558 | - if (!is_array($email)) { |
|
559 | - if (!Validation::email($email, false, $this->_emailPattern)) { |
|
558 | + if ( ! is_array($email)) { |
|
559 | + if ( ! Validation::email($email, false, $this->_emailPattern)) { |
|
560 | 560 | throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email)); |
561 | 561 | } |
562 | 562 | if ($name === null) { |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | if (is_int($key)) { |
571 | 571 | $key = $value; |
572 | 572 | } |
573 | - if (!Validation::email($key, false, $this->_emailPattern)) { |
|
573 | + if ( ! Validation::email($key, false, $this->_emailPattern)) { |
|
574 | 574 | throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $key)); |
575 | 575 | } |
576 | 576 | $list[$key] = $value; |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | * @throws SocketException |
610 | 610 | */ |
611 | 611 | protected function _addEmail($varName, $email, $name) { |
612 | - if (!is_array($email)) { |
|
613 | - if (!Validation::email($email, false, $this->_emailPattern)) { |
|
612 | + if ( ! is_array($email)) { |
|
613 | + if ( ! Validation::email($email, false, $this->_emailPattern)) { |
|
614 | 614 | throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email)); |
615 | 615 | } |
616 | 616 | if ($name === null) { |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | if (is_int($key)) { |
625 | 625 | $key = $value; |
626 | 626 | } |
627 | - if (!Validation::email($key, false, $this->_emailPattern)) { |
|
627 | + if ( ! Validation::email($key, false, $this->_emailPattern)) { |
|
628 | 628 | throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $key)); |
629 | 629 | } |
630 | 630 | $list[$key] = $value; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | if ($subject === null) { |
644 | 644 | return $this->_subject; |
645 | 645 | } |
646 | - $this->_subject = $this->_encode((string)$subject); |
|
646 | + $this->_subject = $this->_encode((string) $subject); |
|
647 | 647 | return $this; |
648 | 648 | } |
649 | 649 | |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | * @throws SocketException |
656 | 656 | */ |
657 | 657 | public function setHeaders($headers) { |
658 | - if (!is_array($headers)) { |
|
658 | + if ( ! is_array($headers)) { |
|
659 | 659 | throw new SocketException(__d('cake_dev', '$headers should be an array.')); |
660 | 660 | } |
661 | 661 | $this->_headers = $headers; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @throws SocketException |
671 | 671 | */ |
672 | 672 | public function addHeaders($headers) { |
673 | - if (!is_array($headers)) { |
|
673 | + if ( ! is_array($headers)) { |
|
674 | 674 | throw new SocketException(__d('cake_dev', '$headers should be an array.')); |
675 | 675 | } |
676 | 676 | $this->_headers = array_merge($this->_headers, $headers); |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | ); |
711 | 711 | foreach ($relation as $var => $header) { |
712 | 712 | if ($include[$var]) { |
713 | - $var = '_' . $var; |
|
713 | + $var = '_'.$var; |
|
714 | 714 | $headers[$header] = current($this->_formatAddress($this->{$var})); |
715 | 715 | } |
716 | 716 | } |
@@ -724,21 +724,21 @@ discard block |
||
724 | 724 | |
725 | 725 | foreach (array('to', 'cc', 'bcc') as $var) { |
726 | 726 | if ($include[$var]) { |
727 | - $classVar = '_' . $var; |
|
727 | + $classVar = '_'.$var; |
|
728 | 728 | $headers[ucfirst($var)] = implode(', ', $this->_formatAddress($this->{$classVar})); |
729 | 729 | } |
730 | 730 | } |
731 | 731 | |
732 | 732 | $headers += $this->_headers; |
733 | - if (!isset($headers['X-Mailer'])) { |
|
733 | + if ( ! isset($headers['X-Mailer'])) { |
|
734 | 734 | $headers['X-Mailer'] = self::EMAIL_CLIENT; |
735 | 735 | } |
736 | - if (!isset($headers['Date'])) { |
|
736 | + if ( ! isset($headers['Date'])) { |
|
737 | 737 | $headers['Date'] = date(DATE_RFC2822); |
738 | 738 | } |
739 | 739 | if ($this->_messageId !== false) { |
740 | 740 | if ($this->_messageId === true) { |
741 | - $headers['Message-ID'] = '<' . str_replace('-', '', String::UUID()) . '@' . $this->_domain . '>'; |
|
741 | + $headers['Message-ID'] = '<'.str_replace('-', '', String::UUID()).'@'.$this->_domain.'>'; |
|
742 | 742 | } else { |
743 | 743 | $headers['Message-ID'] = $this->_messageId; |
744 | 744 | } |
@@ -749,12 +749,12 @@ discard block |
||
749 | 749 | } |
750 | 750 | |
751 | 751 | $headers['MIME-Version'] = '1.0'; |
752 | - if (!empty($this->_attachments) || $this->_emailFormat === 'both') { |
|
753 | - $headers['Content-Type'] = 'multipart/mixed; boundary="' . $this->_boundary . '"'; |
|
752 | + if ( ! empty($this->_attachments) || $this->_emailFormat === 'both') { |
|
753 | + $headers['Content-Type'] = 'multipart/mixed; boundary="'.$this->_boundary.'"'; |
|
754 | 754 | } elseif ($this->_emailFormat === 'text') { |
755 | - $headers['Content-Type'] = 'text/plain; charset=' . $this->_getContentTypeCharset(); |
|
755 | + $headers['Content-Type'] = 'text/plain; charset='.$this->_getContentTypeCharset(); |
|
756 | 756 | } elseif ($this->_emailFormat === 'html') { |
757 | - $headers['Content-Type'] = 'text/html; charset=' . $this->_getContentTypeCharset(); |
|
757 | + $headers['Content-Type'] = 'text/html; charset='.$this->_getContentTypeCharset(); |
|
758 | 758 | } |
759 | 759 | $headers['Content-Transfer-Encoding'] = $this->_getContentTransferEncoding(); |
760 | 760 | |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | } else { |
780 | 780 | $encoded = $this->_encode($alias); |
781 | 781 | if ($encoded === $alias && preg_match('/[^a-z0-9 ]/i', $encoded)) { |
782 | - $encoded = '"' . str_replace('"', '\"', $encoded) . '"'; |
|
782 | + $encoded = '"'.str_replace('"', '\"', $encoded).'"'; |
|
783 | 783 | } |
784 | 784 | $return[] = sprintf('%s <%s>', $encoded, $email); |
785 | 785 | } |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | if ($viewVars === null) { |
833 | 833 | return $this->_viewVars; |
834 | 834 | } |
835 | - $this->_viewVars = array_merge($this->_viewVars, (array)$viewVars); |
|
835 | + $this->_viewVars = array_merge($this->_viewVars, (array) $viewVars); |
|
836 | 836 | return $this; |
837 | 837 | } |
838 | 838 | |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | if ($helpers === null) { |
861 | 861 | return $this->_helpers; |
862 | 862 | } |
863 | - $this->_helpers = (array)$helpers; |
|
863 | + $this->_helpers = (array) $helpers; |
|
864 | 864 | return $this; |
865 | 865 | } |
866 | 866 | |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | if ($format === null) { |
876 | 876 | return $this->_emailFormat; |
877 | 877 | } |
878 | - if (!in_array($format, $this->_emailFormatAvailable)) { |
|
878 | + if ( ! in_array($format, $this->_emailFormatAvailable)) { |
|
879 | 879 | throw new SocketException(__d('cake_dev', 'Format not available.')); |
880 | 880 | } |
881 | 881 | $this->_emailFormat = $format; |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | if ($name === null) { |
893 | 893 | return $this->_transportName; |
894 | 894 | } |
895 | - $this->_transportName = (string)$name; |
|
895 | + $this->_transportName = (string) $name; |
|
896 | 896 | $this->_transportClass = null; |
897 | 897 | return $this; |
898 | 898 | } |
@@ -909,10 +909,10 @@ discard block |
||
909 | 909 | } |
910 | 910 | list($plugin, $transportClassname) = pluginSplit($this->_transportName, true); |
911 | 911 | $transportClassname .= 'Transport'; |
912 | - App::uses($transportClassname, $plugin . 'Network/Email'); |
|
913 | - if (!class_exists($transportClassname)) { |
|
912 | + App::uses($transportClassname, $plugin.'Network/Email'); |
|
913 | + if ( ! class_exists($transportClassname)) { |
|
914 | 914 | throw new SocketException(__d('cake_dev', 'Class "%s" not found.', $transportClassname)); |
915 | - } elseif (!method_exists($transportClassname, 'send')) { |
|
915 | + } elseif ( ! method_exists($transportClassname, 'send')) { |
|
916 | 916 | throw new SocketException(__d('cake_dev', 'The "%s" does not have a %s method.', $transportClassname, 'send()')); |
917 | 917 | } |
918 | 918 | |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | if (is_bool($message)) { |
934 | 934 | $this->_messageId = $message; |
935 | 935 | } else { |
936 | - if (!preg_match('/^\<.+@.+\>$/', $message)) { |
|
936 | + if ( ! preg_match('/^\<.+@.+\>$/', $message)) { |
|
937 | 937 | throw new SocketException(__d('cake_dev', 'Invalid format for Message-ID. The text should be something like "<[email protected]>"')); |
938 | 938 | } |
939 | 939 | $this->_messageId = $message; |
@@ -1007,12 +1007,12 @@ discard block |
||
1007 | 1007 | return $this->_attachments; |
1008 | 1008 | } |
1009 | 1009 | $attach = array(); |
1010 | - foreach ((array)$attachments as $name => $fileInfo) { |
|
1011 | - if (!is_array($fileInfo)) { |
|
1010 | + foreach ((array) $attachments as $name => $fileInfo) { |
|
1011 | + if ( ! is_array($fileInfo)) { |
|
1012 | 1012 | $fileInfo = array('file' => $fileInfo); |
1013 | 1013 | } |
1014 | - if (!isset($fileInfo['file'])) { |
|
1015 | - if (!isset($fileInfo['data'])) { |
|
1014 | + if ( ! isset($fileInfo['file'])) { |
|
1015 | + if ( ! isset($fileInfo['data'])) { |
|
1016 | 1016 | throw new SocketException(__d('cake_dev', 'No file or data specified.')); |
1017 | 1017 | } |
1018 | 1018 | if (is_int($name)) { |
@@ -1022,14 +1022,14 @@ discard block |
||
1022 | 1022 | } else { |
1023 | 1023 | $fileName = $fileInfo['file']; |
1024 | 1024 | $fileInfo['file'] = realpath($fileInfo['file']); |
1025 | - if ($fileInfo['file'] === false || !file_exists($fileInfo['file'])) { |
|
1025 | + if ($fileInfo['file'] === false || ! file_exists($fileInfo['file'])) { |
|
1026 | 1026 | throw new SocketException(__d('cake_dev', 'File not found: "%s"', $fileName)); |
1027 | 1027 | } |
1028 | 1028 | if (is_int($name)) { |
1029 | 1029 | $name = basename($fileInfo['file']); |
1030 | 1030 | } |
1031 | 1031 | } |
1032 | - if (!isset($fileInfo['mimetype'])) { |
|
1032 | + if ( ! isset($fileInfo['mimetype'])) { |
|
1033 | 1033 | $fileInfo['mimetype'] = 'application/octet-stream'; |
1034 | 1034 | } |
1035 | 1035 | $attach[$name] = $fileInfo; |
@@ -1089,8 +1089,8 @@ discard block |
||
1089 | 1089 | if ($config === null) { |
1090 | 1090 | return $this->_config; |
1091 | 1091 | } |
1092 | - if (!is_array($config)) { |
|
1093 | - $config = (string)$config; |
|
1092 | + if ( ! is_array($config)) { |
|
1093 | + $config = (string) $config; |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | $this->_applyConfig($config); |
@@ -1113,26 +1113,26 @@ discard block |
||
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | if (is_array($content)) { |
1116 | - $content = implode("\n", $content) . "\n"; |
|
1116 | + $content = implode("\n", $content)."\n"; |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | $this->_message = $this->_render($this->_wrap($content)); |
1120 | 1120 | |
1121 | 1121 | $contents = $this->transportClass()->send($this); |
1122 | - if (!empty($this->_config['log'])) { |
|
1122 | + if ( ! empty($this->_config['log'])) { |
|
1123 | 1123 | $config = array( |
1124 | 1124 | 'level' => LOG_DEBUG, |
1125 | 1125 | 'scope' => 'email' |
1126 | 1126 | ); |
1127 | 1127 | if ($this->_config['log'] !== true) { |
1128 | - if (!is_array($this->_config['log'])) { |
|
1128 | + if ( ! is_array($this->_config['log'])) { |
|
1129 | 1129 | $this->_config['log'] = array('level' => $this->_config['log']); |
1130 | 1130 | } |
1131 | 1131 | $config = array_merge($config, $this->_config['log']); |
1132 | 1132 | } |
1133 | 1133 | CakeLog::write( |
1134 | 1134 | $config['level'], |
1135 | - PHP_EOL . $contents['headers'] . PHP_EOL . $contents['message'], |
|
1135 | + PHP_EOL.$contents['headers'].PHP_EOL.$contents['message'], |
|
1136 | 1136 | $config['scope'] |
1137 | 1137 | ); |
1138 | 1138 | } |
@@ -1183,20 +1183,20 @@ discard block |
||
1183 | 1183 | */ |
1184 | 1184 | protected function _applyConfig($config) { |
1185 | 1185 | if (is_string($config)) { |
1186 | - if (!class_exists($this->_configClass) && !config('email')) { |
|
1187 | - throw new ConfigureException(__d('cake_dev', '%s not found.', APP . 'Config' . DS . 'email.php')); |
|
1186 | + if ( ! class_exists($this->_configClass) && ! config('email')) { |
|
1187 | + throw new ConfigureException(__d('cake_dev', '%s not found.', APP.'Config'.DS.'email.php')); |
|
1188 | 1188 | } |
1189 | 1189 | $configs = new $this->_configClass(); |
1190 | - if (!isset($configs->{$config})) { |
|
1190 | + if ( ! isset($configs->{$config})) { |
|
1191 | 1191 | throw new ConfigureException(__d('cake_dev', 'Unknown email configuration "%s".', $config)); |
1192 | 1192 | } |
1193 | 1193 | $config = $configs->{$config}; |
1194 | 1194 | } |
1195 | 1195 | $this->_config = array_merge($this->_config, $config); |
1196 | - if (!empty($config['charset'])) { |
|
1196 | + if ( ! empty($config['charset'])) { |
|
1197 | 1197 | $this->charset = $config['charset']; |
1198 | 1198 | } |
1199 | - if (!empty($config['headerCharset'])) { |
|
1199 | + if ( ! empty($config['headerCharset'])) { |
|
1200 | 1200 | $this->headerCharset = $config['headerCharset']; |
1201 | 1201 | } |
1202 | 1202 | if (empty($this->headerCharset)) { |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | * @return string |
1298 | 1298 | */ |
1299 | 1299 | protected function _encodeString($text, $charset) { |
1300 | - if ($this->_appCharset === $charset || !function_exists('mb_convert_encoding')) { |
|
1300 | + if ($this->_appCharset === $charset || ! function_exists('mb_convert_encoding')) { |
|
1301 | 1301 | return $text; |
1302 | 1302 | } |
1303 | 1303 | return mb_convert_encoding($text, $charset, $this->_appCharset); |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | $formatted[] = $line; |
1329 | 1329 | continue; |
1330 | 1330 | } |
1331 | - if (!preg_match('/<[a-z]+.*>/i', $line)) { |
|
1331 | + if ( ! preg_match('/<[a-z]+.*>/i', $line)) { |
|
1332 | 1332 | $formatted = array_merge( |
1333 | 1333 | $formatted, |
1334 | 1334 | explode("\n", wordwrap($line, $wrapLength, "\n", $cut)) |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | } |
1403 | 1403 | } |
1404 | 1404 | } |
1405 | - if (!empty($tmpLine)) { |
|
1405 | + if ( ! empty($tmpLine)) { |
|
1406 | 1406 | $formatted[] = $tmpLine; |
1407 | 1407 | } |
1408 | 1408 | } |
@@ -1416,7 +1416,7 @@ discard block |
||
1416 | 1416 | * @return void |
1417 | 1417 | */ |
1418 | 1418 | protected function _createBoundary() { |
1419 | - if (!empty($this->_attachments) || $this->_emailFormat === 'both') { |
|
1419 | + if ( ! empty($this->_attachments) || $this->_emailFormat === 'both') { |
|
1420 | 1420 | $this->_boundary = md5(uniqid(time())); |
1421 | 1421 | } |
1422 | 1422 | } |
@@ -1434,19 +1434,19 @@ discard block |
||
1434 | 1434 | |
1435 | 1435 | $msg = array(); |
1436 | 1436 | foreach ($this->_attachments as $filename => $fileInfo) { |
1437 | - if (!empty($fileInfo['contentId'])) { |
|
1437 | + if ( ! empty($fileInfo['contentId'])) { |
|
1438 | 1438 | continue; |
1439 | 1439 | } |
1440 | 1440 | $data = isset($fileInfo['data']) ? $fileInfo['data'] : $this->_readFile($fileInfo['file']); |
1441 | 1441 | |
1442 | - $msg[] = '--' . $boundary; |
|
1443 | - $msg[] = 'Content-Type: ' . $fileInfo['mimetype']; |
|
1442 | + $msg[] = '--'.$boundary; |
|
1443 | + $msg[] = 'Content-Type: '.$fileInfo['mimetype']; |
|
1444 | 1444 | $msg[] = 'Content-Transfer-Encoding: base64'; |
1445 | 1445 | if ( |
1446 | - !isset($fileInfo['contentDisposition']) || |
|
1446 | + ! isset($fileInfo['contentDisposition']) || |
|
1447 | 1447 | $fileInfo['contentDisposition'] |
1448 | 1448 | ) { |
1449 | - $msg[] = 'Content-Disposition: attachment; filename="' . $filename . '"'; |
|
1449 | + $msg[] = 'Content-Disposition: attachment; filename="'.$filename.'"'; |
|
1450 | 1450 | } |
1451 | 1451 | $msg[] = ''; |
1452 | 1452 | $msg[] = $data; |
@@ -1484,11 +1484,11 @@ discard block |
||
1484 | 1484 | } |
1485 | 1485 | $data = isset($fileInfo['data']) ? $fileInfo['data'] : $this->_readFile($fileInfo['file']); |
1486 | 1486 | |
1487 | - $msg[] = '--' . $boundary; |
|
1488 | - $msg[] = 'Content-Type: ' . $fileInfo['mimetype']; |
|
1487 | + $msg[] = '--'.$boundary; |
|
1488 | + $msg[] = 'Content-Type: '.$fileInfo['mimetype']; |
|
1489 | 1489 | $msg[] = 'Content-Transfer-Encoding: base64'; |
1490 | - $msg[] = 'Content-ID: <' . $fileInfo['contentId'] . '>'; |
|
1491 | - $msg[] = 'Content-Disposition: inline; filename="' . $filename . '"'; |
|
1490 | + $msg[] = 'Content-ID: <'.$fileInfo['contentId'].'>'; |
|
1491 | + $msg[] = 'Content-Disposition: inline; filename="'.$filename.'"'; |
|
1492 | 1492 | $msg[] = ''; |
1493 | 1493 | $msg[] = $data; |
1494 | 1494 | $msg[] = ''; |
@@ -1511,32 +1511,32 @@ discard block |
||
1511 | 1511 | $this->_createBoundary(); |
1512 | 1512 | $msg = array(); |
1513 | 1513 | |
1514 | - $contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId')); |
|
1514 | + $contentIds = array_filter((array) Hash::extract($this->_attachments, '{s}.contentId')); |
|
1515 | 1515 | $hasInlineAttachments = count($contentIds) > 0; |
1516 | - $hasAttachments = !empty($this->_attachments); |
|
1516 | + $hasAttachments = ! empty($this->_attachments); |
|
1517 | 1517 | $hasMultipleTypes = count($rendered) > 1; |
1518 | 1518 | |
1519 | 1519 | $boundary = $relBoundary = $textBoundary = $this->_boundary; |
1520 | 1520 | |
1521 | 1521 | if ($hasInlineAttachments) { |
1522 | - $msg[] = '--' . $boundary; |
|
1523 | - $msg[] = 'Content-Type: multipart/related; boundary="rel-' . $boundary . '"'; |
|
1522 | + $msg[] = '--'.$boundary; |
|
1523 | + $msg[] = 'Content-Type: multipart/related; boundary="rel-'.$boundary.'"'; |
|
1524 | 1524 | $msg[] = ''; |
1525 | - $relBoundary = $textBoundary = 'rel-' . $boundary; |
|
1525 | + $relBoundary = $textBoundary = 'rel-'.$boundary; |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | if ($hasMultipleTypes) { |
1529 | - $msg[] = '--' . $relBoundary; |
|
1530 | - $msg[] = 'Content-Type: multipart/alternative; boundary="alt-' . $boundary . '"'; |
|
1529 | + $msg[] = '--'.$relBoundary; |
|
1530 | + $msg[] = 'Content-Type: multipart/alternative; boundary="alt-'.$boundary.'"'; |
|
1531 | 1531 | $msg[] = ''; |
1532 | - $textBoundary = 'alt-' . $boundary; |
|
1532 | + $textBoundary = 'alt-'.$boundary; |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | 1535 | if (isset($rendered['text'])) { |
1536 | 1536 | if ($textBoundary !== $boundary || $hasAttachments) { |
1537 | - $msg[] = '--' . $textBoundary; |
|
1538 | - $msg[] = 'Content-Type: text/plain; charset=' . $this->_getContentTypeCharset(); |
|
1539 | - $msg[] = 'Content-Transfer-Encoding: ' . $this->_getContentTransferEncoding(); |
|
1537 | + $msg[] = '--'.$textBoundary; |
|
1538 | + $msg[] = 'Content-Type: text/plain; charset='.$this->_getContentTypeCharset(); |
|
1539 | + $msg[] = 'Content-Transfer-Encoding: '.$this->_getContentTransferEncoding(); |
|
1540 | 1540 | $msg[] = ''; |
1541 | 1541 | } |
1542 | 1542 | $this->_textMessage = $rendered['text']; |
@@ -1547,9 +1547,9 @@ discard block |
||
1547 | 1547 | |
1548 | 1548 | if (isset($rendered['html'])) { |
1549 | 1549 | if ($textBoundary !== $boundary || $hasAttachments) { |
1550 | - $msg[] = '--' . $textBoundary; |
|
1551 | - $msg[] = 'Content-Type: text/html; charset=' . $this->_getContentTypeCharset(); |
|
1552 | - $msg[] = 'Content-Transfer-Encoding: ' . $this->_getContentTransferEncoding(); |
|
1550 | + $msg[] = '--'.$textBoundary; |
|
1551 | + $msg[] = 'Content-Type: text/html; charset='.$this->_getContentTypeCharset(); |
|
1552 | + $msg[] = 'Content-Transfer-Encoding: '.$this->_getContentTransferEncoding(); |
|
1553 | 1553 | $msg[] = ''; |
1554 | 1554 | } |
1555 | 1555 | $this->_htmlMessage = $rendered['html']; |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | } |
1560 | 1560 | |
1561 | 1561 | if ($hasMultipleTypes) { |
1562 | - $msg[] = '--' . $textBoundary . '--'; |
|
1562 | + $msg[] = '--'.$textBoundary.'--'; |
|
1563 | 1563 | $msg[] = ''; |
1564 | 1564 | } |
1565 | 1565 | |
@@ -1567,7 +1567,7 @@ discard block |
||
1567 | 1567 | $attachments = $this->_attachInlineFiles($relBoundary); |
1568 | 1568 | $msg = array_merge($msg, $attachments); |
1569 | 1569 | $msg[] = ''; |
1570 | - $msg[] = '--' . $relBoundary . '--'; |
|
1570 | + $msg[] = '--'.$relBoundary.'--'; |
|
1571 | 1571 | $msg[] = ''; |
1572 | 1572 | } |
1573 | 1573 | |
@@ -1577,7 +1577,7 @@ discard block |
||
1577 | 1577 | } |
1578 | 1578 | if ($hasAttachments || $hasMultipleTypes) { |
1579 | 1579 | $msg[] = ''; |
1580 | - $msg[] = '--' . $boundary . '--'; |
|
1580 | + $msg[] = '--'.$boundary.'--'; |
|
1581 | 1581 | $msg[] = ''; |
1582 | 1582 | } |
1583 | 1583 | return $msg; |
@@ -1617,7 +1617,7 @@ discard block |
||
1617 | 1617 | if ($viewClass !== 'View') { |
1618 | 1618 | list($plugin, $viewClass) = pluginSplit($viewClass, true); |
1619 | 1619 | $viewClass .= 'View'; |
1620 | - App::uses($viewClass, $plugin . 'View'); |
|
1620 | + App::uses($viewClass, $plugin.'View'); |
|
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | $View = new $viewClass(null); |
@@ -1650,7 +1650,7 @@ discard block |
||
1650 | 1650 | |
1651 | 1651 | foreach ($types as $type) { |
1652 | 1652 | $View->hasRendered = false; |
1653 | - $View->viewPath = $View->layoutPath = 'Emails' . DS . $type; |
|
1653 | + $View->viewPath = $View->layoutPath = 'Emails'.DS.$type; |
|
1654 | 1654 | |
1655 | 1655 | $render = $View->render($this->_template, $this->_layout); |
1656 | 1656 | $render = str_replace(array("\r\n", "\r"), "\n", $render); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * Send mail |
51 | 51 | * |
52 | 52 | * @param CakeEmail $email CakeEmail |
53 | - * @return array |
|
53 | + * @return string |
|
54 | 54 | * @throws SocketException |
55 | 55 | */ |
56 | 56 | public function send(CakeEmail $email) { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function _connect() { |
98 | 98 | $this->_generateSocket(); |
99 | - if (!$this->_socket->connect()) { |
|
99 | + if ( ! $this->_socket->connect()) { |
|
100 | 100 | throw new SocketException(__d('cake_dev', 'Unable to connect to SMTP server.')); |
101 | 101 | } |
102 | 102 | $this->_smtpSend(null, '220'); |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | if (isset($this->_config['username']) && isset($this->_config['password'])) { |
139 | 139 | $authRequired = $this->_smtpSend('AUTH LOGIN', '334|503'); |
140 | 140 | if ($authRequired == '334') { |
141 | - if (!$this->_smtpSend(base64_encode($this->_config['username']), '334')) { |
|
141 | + if ( ! $this->_smtpSend(base64_encode($this->_config['username']), '334')) { |
|
142 | 142 | throw new SocketException(__d('cake_dev', 'SMTP server did not accept the username.')); |
143 | 143 | } |
144 | - if (!$this->_smtpSend(base64_encode($this->_config['password']), '235')) { |
|
144 | + if ( ! $this->_smtpSend(base64_encode($this->_config['password']), '235')) { |
|
145 | 145 | throw new SocketException(__d('cake_dev', 'SMTP server did not accept the password.')); |
146 | 146 | } |
147 | 147 | } elseif ($authRequired == '504') { |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | if (empty($from)) { |
164 | 164 | $from = $this->_cakeEmail->from(); |
165 | 165 | } |
166 | - $this->_smtpSend('MAIL FROM:<' . key($from) . '>'); |
|
166 | + $this->_smtpSend('MAIL FROM:<'.key($from).'>'); |
|
167 | 167 | |
168 | 168 | $to = $this->_cakeEmail->to(); |
169 | 169 | $cc = $this->_cakeEmail->cc(); |
170 | 170 | $bcc = $this->_cakeEmail->bcc(); |
171 | 171 | $emails = array_merge(array_keys($to), array_keys($cc), array_keys($bcc)); |
172 | 172 | foreach ($emails as $email) { |
173 | - $this->_smtpSend('RCPT TO:<' . $email . '>'); |
|
173 | + $this->_smtpSend('RCPT TO:<'.$email.'>'); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | $lines = $this->_cakeEmail->message(); |
189 | 189 | $messages = array(); |
190 | 190 | foreach ($lines as $line) { |
191 | - if ((!empty($line)) && ($line[0] === '.')) { |
|
192 | - $messages[] = '.' . $line; |
|
191 | + if (( ! empty($line)) && ($line[0] === '.')) { |
|
192 | + $messages[] = '.'.$line; |
|
193 | 193 | } else { |
194 | 194 | $messages[] = $line; |
195 | 195 | } |
196 | 196 | } |
197 | 197 | $message = implode("\r\n", $messages); |
198 | - $this->_smtpSend($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n."); |
|
198 | + $this->_smtpSend($headers."\r\n\r\n".$message."\r\n\r\n\r\n."); |
|
199 | 199 | $this->_content = array('headers' => $headers, 'message' => $message); |
200 | 200 | } |
201 | 201 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | protected function _smtpSend($data, $checkCode = '250') { |
232 | 232 | if ($data !== null) { |
233 | - $this->_socket->write($data . "\r\n"); |
|
233 | + $this->_socket->write($data."\r\n"); |
|
234 | 234 | } |
235 | 235 | while ($checkCode !== false) { |
236 | 236 | $response = ''; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $responseLines = explode("\r\n", rtrim($response, "\r\n")); |
245 | 245 | $response = end($responseLines); |
246 | 246 | |
247 | - if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) { |
|
247 | + if (preg_match('/^('.$checkCode.')(.)/', $response, $code)) { |
|
248 | 248 | if ($code[2] === '-') { |
249 | 249 | continue; |
250 | 250 | } |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * |
546 | 546 | * @param string|array Either a string or array of URL options to create a URL with. |
547 | 547 | * @param string $uriTemplate A template string to use for URL formatting. |
548 | - * @return mixed Either false on failure or a string containing the composed URL. |
|
548 | + * @return false|string Either false on failure or a string containing the composed URL. |
|
549 | 549 | */ |
550 | 550 | public function url($url = null, $uriTemplate = null) { |
551 | 551 | if ($url === null) { |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @param string|array $uri Either A $uri array, or a request string. Will use $this->config if left empty. |
700 | 700 | * @param string $uriTemplate The Uri template/format to use. |
701 | - * @return mixed A fully qualified URL formatted according to $uriTemplate, or false on failure |
|
701 | + * @return false|string A fully qualified URL formatted according to $uriTemplate, or false on failure |
|
702 | 702 | */ |
703 | 703 | protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { |
704 | 704 | if (is_string($uri)) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $this->_contentResource = null; |
241 | 241 | return; |
242 | 242 | } |
243 | - if (!is_resource($resource)) { |
|
243 | + if ( ! is_resource($resource)) { |
|
244 | 244 | throw new SocketException(__d('cake_dev', 'Invalid resource.')); |
245 | 245 | } |
246 | 246 | $this->_contentResource = $resource; |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | |
260 | 260 | if (is_string($request)) { |
261 | 261 | $request = array('uri' => $request); |
262 | - } elseif (!is_array($request)) { |
|
262 | + } elseif ( ! is_array($request)) { |
|
263 | 263 | return false; |
264 | 264 | } |
265 | 265 | |
266 | - if (!isset($request['uri'])) { |
|
266 | + if ( ! isset($request['uri'])) { |
|
267 | 267 | $request['uri'] = null; |
268 | 268 | } |
269 | 269 | $uri = $this->_parseUri($request['uri']); |
270 | - if (!isset($uri['host'])) { |
|
270 | + if ( ! isset($uri['host'])) { |
|
271 | 271 | $host = $this->config['host']; |
272 | 272 | } |
273 | 273 | if (isset($request['host'])) { |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | $this->_configUri($this->request['uri']); |
282 | 282 | |
283 | 283 | $Host = $this->request['uri']['host']; |
284 | - if (!empty($this->config['request']['cookies'][$Host])) { |
|
285 | - if (!isset($this->request['cookies'])) { |
|
284 | + if ( ! empty($this->config['request']['cookies'][$Host])) { |
|
285 | + if ( ! isset($this->request['cookies'])) { |
|
286 | 286 | $this->request['cookies'] = array(); |
287 | 287 | } |
288 | - if (!isset($request['cookies'])) { |
|
288 | + if ( ! isset($request['cookies'])) { |
|
289 | 289 | $request['cookies'] = array(); |
290 | 290 | } |
291 | 291 | $this->request['cookies'] = array_merge($this->request['cookies'], $this->config['request']['cookies'][$Host], $request['cookies']); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $cookies = null; |
301 | 301 | |
302 | 302 | if (is_array($this->request['header'])) { |
303 | - if (!empty($this->request['cookies'])) { |
|
303 | + if ( ! empty($this->request['cookies'])) { |
|
304 | 304 | $cookies = $this->buildCookies($this->request['cookies']); |
305 | 305 | } |
306 | 306 | $scheme = ''; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | ($scheme === 'https' && $port != 443) || |
317 | 317 | ($port != 80 && $port != 443) |
318 | 318 | ) { |
319 | - $Host .= ':' . $port; |
|
319 | + $Host .= ':'.$port; |
|
320 | 320 | } |
321 | 321 | $this->request['header'] = array_merge(compact('Host'), $this->request['header']); |
322 | 322 | } |
@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | $this->request['body'] = http_build_query($this->request['body'], '', '&'); |
334 | 334 | } |
335 | 335 | |
336 | - if (!empty($this->request['body']) && !isset($this->request['header']['Content-Type'])) { |
|
336 | + if ( ! empty($this->request['body']) && ! isset($this->request['header']['Content-Type'])) { |
|
337 | 337 | $this->request['header']['Content-Type'] = 'application/x-www-form-urlencoded'; |
338 | 338 | } |
339 | 339 | |
340 | - if (!empty($this->request['body']) && !isset($this->request['header']['Content-Length'])) { |
|
340 | + if ( ! empty($this->request['body']) && ! isset($this->request['header']['Content-Length'])) { |
|
341 | 341 | $this->request['header']['Content-Length'] = strlen($this->request['body']); |
342 | 342 | } |
343 | 343 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | if (isset($this->request['header']['Connection'])) { |
346 | 346 | $connectionType = $this->request['header']['Connection']; |
347 | 347 | } |
348 | - $this->request['header'] = $this->_buildHeader($this->request['header']) . $cookies; |
|
348 | + $this->request['header'] = $this->_buildHeader($this->request['header']).$cookies; |
|
349 | 349 | |
350 | 350 | if (empty($this->request['line'])) { |
351 | 351 | $this->request['line'] = $this->_buildRequestLine($this->request); |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | list($plugin, $responseClass) = pluginSplit($this->responseClass, true); |
402 | - App::uses($responseClass, $plugin . 'Network/Http'); |
|
403 | - if (!class_exists($responseClass)) { |
|
402 | + App::uses($responseClass, $plugin.'Network/Http'); |
|
403 | + if ( ! class_exists($responseClass)) { |
|
404 | 404 | throw new SocketException(__d('cake_dev', 'Class %s not found.', $this->responseClass)); |
405 | 405 | } |
406 | 406 | $this->response = new $responseClass($response); |
407 | 407 | |
408 | - if (!empty($this->response->cookies)) { |
|
409 | - if (!isset($this->config['request']['cookies'][$Host])) { |
|
408 | + if ( ! empty($this->response->cookies)) { |
|
409 | + if ( ! isset($this->config['request']['cookies'][$Host])) { |
|
410 | 410 | $this->config['request']['cookies'][$Host] = array(); |
411 | 411 | } |
412 | 412 | $this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @return mixed Result of request, either false on failure or the response to the request. |
446 | 446 | */ |
447 | 447 | public function get($uri = null, $query = array(), $request = array()) { |
448 | - if (!empty($query)) { |
|
448 | + if ( ! empty($query)) { |
|
449 | 449 | $uri = $this->_parseUri($uri, $this->config['request']['uri']); |
450 | 450 | if (isset($uri['query'])) { |
451 | 451 | $uri['query'] = array_merge($uri['query'], $query); |
@@ -561,12 +561,12 @@ discard block |
||
561 | 561 | $port = $port[0]; |
562 | 562 | } |
563 | 563 | if ($url{0} === '/') { |
564 | - $url = $this->config['request']['uri']['host'] . ':' . $port . $url; |
|
564 | + $url = $this->config['request']['uri']['host'].':'.$port.$url; |
|
565 | 565 | } |
566 | - if (!preg_match('/^.+:\/\/|\*|^\//', $url)) { |
|
567 | - $url = $scheme . '://' . $url; |
|
566 | + if ( ! preg_match('/^.+:\/\/|\*|^\//', $url)) { |
|
567 | + $url = $scheme.'://'.$url; |
|
568 | 568 | } |
569 | - } elseif (!is_array($url) && !empty($url)) { |
|
569 | + } elseif ( ! is_array($url) && ! empty($url)) { |
|
570 | 570 | return false; |
571 | 571 | } |
572 | 572 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $url = $this->config['request']['uri']; |
578 | 578 | } |
579 | 579 | |
580 | - if (!empty($uriTemplate)) { |
|
580 | + if ( ! empty($uriTemplate)) { |
|
581 | 581 | return $this->_buildUri($url, $uriTemplate); |
582 | 582 | } |
583 | 583 | return $this->_buildUri($url); |
@@ -595,13 +595,13 @@ discard block |
||
595 | 595 | } |
596 | 596 | $method = key($this->_auth); |
597 | 597 | list($plugin, $authClass) = pluginSplit($method, true); |
598 | - $authClass = Inflector::camelize($authClass) . 'Authentication'; |
|
599 | - App::uses($authClass, $plugin . 'Network/Http'); |
|
598 | + $authClass = Inflector::camelize($authClass).'Authentication'; |
|
599 | + App::uses($authClass, $plugin.'Network/Http'); |
|
600 | 600 | |
601 | - if (!class_exists($authClass)) { |
|
601 | + if ( ! class_exists($authClass)) { |
|
602 | 602 | throw new SocketException(__d('cake_dev', 'Unknown authentication method.')); |
603 | 603 | } |
604 | - if (!method_exists($authClass, 'authentication')) { |
|
604 | + if ( ! method_exists($authClass, 'authentication')) { |
|
605 | 605 | throw new SocketException(__d('cake_dev', 'The %s does not support authentication.', $authClass)); |
606 | 606 | } |
607 | 607 | call_user_func_array("$authClass::authentication", array($this, &$this->_auth[$method])); |
@@ -614,23 +614,23 @@ discard block |
||
614 | 614 | * @throws SocketException |
615 | 615 | */ |
616 | 616 | protected function _setProxy() { |
617 | - if (empty($this->_proxy) || !isset($this->_proxy['host'], $this->_proxy['port'])) { |
|
617 | + if (empty($this->_proxy) || ! isset($this->_proxy['host'], $this->_proxy['port'])) { |
|
618 | 618 | return; |
619 | 619 | } |
620 | 620 | $this->config['host'] = $this->_proxy['host']; |
621 | 621 | $this->config['port'] = $this->_proxy['port']; |
622 | 622 | |
623 | - if (empty($this->_proxy['method']) || !isset($this->_proxy['user'], $this->_proxy['pass'])) { |
|
623 | + if (empty($this->_proxy['method']) || ! isset($this->_proxy['user'], $this->_proxy['pass'])) { |
|
624 | 624 | return; |
625 | 625 | } |
626 | 626 | list($plugin, $authClass) = pluginSplit($this->_proxy['method'], true); |
627 | - $authClass = Inflector::camelize($authClass) . 'Authentication'; |
|
628 | - App::uses($authClass, $plugin . 'Network/Http'); |
|
627 | + $authClass = Inflector::camelize($authClass).'Authentication'; |
|
628 | + App::uses($authClass, $plugin.'Network/Http'); |
|
629 | 629 | |
630 | - if (!class_exists($authClass)) { |
|
630 | + if ( ! class_exists($authClass)) { |
|
631 | 631 | throw new SocketException(__d('cake_dev', 'Unknown authentication method for proxy.')); |
632 | 632 | } |
633 | - if (!method_exists($authClass, 'proxyAuthentication')) { |
|
633 | + if ( ! method_exists($authClass, 'proxyAuthentication')) { |
|
634 | 634 | throw new SocketException(__d('cake_dev', 'The %s does not support proxy authentication.', $authClass)); |
635 | 635 | } |
636 | 636 | call_user_func_array("$authClass::proxyAuthentication", array($this, &$this->_proxy)); |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | $uri = $this->_parseUri($uri, true); |
654 | 654 | } |
655 | 655 | |
656 | - if (!isset($uri['host'])) { |
|
656 | + if ( ! isset($uri['host'])) { |
|
657 | 657 | return false; |
658 | 658 | } |
659 | 659 | $config = array( |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | unset($this->config[$key]); |
686 | 686 | } |
687 | 687 | if (empty($this->config['context']['ssl']['cafile'])) { |
688 | - $this->config['context']['ssl']['cafile'] = CAKE . 'Config' . DS . 'cacert.pem'; |
|
688 | + $this->config['context']['ssl']['cafile'] = CAKE.'Config'.DS.'cacert.pem'; |
|
689 | 689 | } |
690 | - if (!empty($this->config['context']['ssl']['verify_host'])) { |
|
690 | + if ( ! empty($this->config['context']['ssl']['verify_host'])) { |
|
691 | 691 | $this->config['context']['ssl']['CN_match'] = $host; |
692 | 692 | } |
693 | 693 | unset($this->config['context']['ssl']['verify_host']); |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | } |
707 | 707 | $uri = $this->_parseUri($uri, true); |
708 | 708 | |
709 | - if (!is_array($uri) || empty($uri)) { |
|
709 | + if ( ! is_array($uri) || empty($uri)) { |
|
710 | 710 | return false; |
711 | 711 | } |
712 | 712 | |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $uriTemplate = str_replace(':%port', null, $uriTemplate); |
732 | 732 | } |
733 | 733 | foreach ($uri as $property => $value) { |
734 | - $uriTemplate = str_replace('%' . $property, $value, $uriTemplate); |
|
734 | + $uriTemplate = str_replace('%'.$property, $value, $uriTemplate); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | if ($uriTemplate === '/*') { |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | if (is_string($uri)) { |
764 | 764 | $uri = parse_url($uri); |
765 | 765 | } |
766 | - if (!is_array($uri) || empty($uri)) { |
|
766 | + if ( ! is_array($uri) || empty($uri)) { |
|
767 | 767 | return false; |
768 | 768 | } |
769 | 769 | if ($base === true) { |
@@ -771,14 +771,14 @@ discard block |
||
771 | 771 | } |
772 | 772 | |
773 | 773 | if (isset($base['port'], $base['scheme']) && is_array($base['port']) && is_array($base['scheme'])) { |
774 | - if (isset($uri['scheme']) && !isset($uri['port'])) { |
|
774 | + if (isset($uri['scheme']) && ! isset($uri['port'])) { |
|
775 | 775 | $base['port'] = $base['port'][array_search($uri['scheme'], $base['scheme'])]; |
776 | - } elseif (isset($uri['port']) && !isset($uri['scheme'])) { |
|
776 | + } elseif (isset($uri['port']) && ! isset($uri['scheme'])) { |
|
777 | 777 | $base['scheme'] = $base['scheme'][array_search($uri['port'], $base['port'])]; |
778 | 778 | } |
779 | 779 | } |
780 | 780 | |
781 | - if (is_array($base) && !empty($base)) { |
|
781 | + if (is_array($base) && ! empty($base)) { |
|
782 | 782 | $uri = array_merge($base, $uri); |
783 | 783 | } |
784 | 784 | |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | $uri['query'] = $this->_parseQuery($uri['query']); |
794 | 794 | } |
795 | 795 | |
796 | - if (!array_intersect_key($uriBase, $uri)) { |
|
796 | + if ( ! array_intersect_key($uriBase, $uri)) { |
|
797 | 797 | return false; |
798 | 798 | } |
799 | 799 | return $uri; |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | |
821 | 821 | $parsedQuery = array(); |
822 | 822 | |
823 | - if (is_string($query) && !empty($query)) { |
|
823 | + if (is_string($query) && ! empty($query)) { |
|
824 | 824 | $query = preg_replace('/^\?/', '', $query); |
825 | 825 | $items = explode('&', $query); |
826 | 826 | |
@@ -838,13 +838,13 @@ discard block |
||
838 | 838 | if (preg_match_all('/\[([^\[\]]*)\]/iUs', $key, $matches)) { |
839 | 839 | $subKeys = $matches[1]; |
840 | 840 | $rootKey = substr($key, 0, strpos($key, '[')); |
841 | - if (!empty($rootKey)) { |
|
841 | + if ( ! empty($rootKey)) { |
|
842 | 842 | array_unshift($subKeys, $rootKey); |
843 | 843 | } |
844 | - $queryNode =& $parsedQuery; |
|
844 | + $queryNode = & $parsedQuery; |
|
845 | 845 | |
846 | 846 | foreach ($subKeys as $subKey) { |
847 | - if (!is_array($queryNode)) { |
|
847 | + if ( ! is_array($queryNode)) { |
|
848 | 848 | $queryNode = array(); |
849 | 849 | } |
850 | 850 | |
@@ -853,15 +853,15 @@ discard block |
||
853 | 853 | end($queryNode); |
854 | 854 | $subKey = key($queryNode); |
855 | 855 | } |
856 | - $queryNode =& $queryNode[$subKey]; |
|
856 | + $queryNode = & $queryNode[$subKey]; |
|
857 | 857 | } |
858 | 858 | $queryNode = $value; |
859 | 859 | continue; |
860 | 860 | } |
861 | - if (!isset($parsedQuery[$key])) { |
|
861 | + if ( ! isset($parsedQuery[$key])) { |
|
862 | 862 | $parsedQuery[$key] = $value; |
863 | 863 | } else { |
864 | - $parsedQuery[$key] = (array)$parsedQuery[$key]; |
|
864 | + $parsedQuery[$key] = (array) $parsedQuery[$key]; |
|
865 | 865 | $parsedQuery[$key][] = $value; |
866 | 866 | } |
867 | 867 | } |
@@ -882,28 +882,28 @@ discard block |
||
882 | 882 | |
883 | 883 | if (is_string($request)) { |
884 | 884 | $isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match); |
885 | - if (!$this->quirksMode && (!$isValid || ($match[2] === '*' && !in_array($match[3], $asteriskMethods)))) { |
|
885 | + if ( ! $this->quirksMode && ( ! $isValid || ($match[2] === '*' && ! in_array($match[3], $asteriskMethods)))) { |
|
886 | 886 | throw new SocketException(__d('cake_dev', 'HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.')); |
887 | 887 | } |
888 | 888 | return $request; |
889 | - } elseif (!is_array($request)) { |
|
889 | + } elseif ( ! is_array($request)) { |
|
890 | 890 | return false; |
891 | - } elseif (!array_key_exists('uri', $request)) { |
|
891 | + } elseif ( ! array_key_exists('uri', $request)) { |
|
892 | 892 | return false; |
893 | 893 | } |
894 | 894 | |
895 | 895 | $request['uri'] = $this->_parseUri($request['uri']); |
896 | 896 | $request = array_merge(array('method' => 'GET'), $request); |
897 | - if (!empty($this->_proxy['host'])) { |
|
897 | + if ( ! empty($this->_proxy['host'])) { |
|
898 | 898 | $request['uri'] = $this->_buildUri($request['uri'], '%scheme://%host:%port/%path?%query'); |
899 | 899 | } else { |
900 | 900 | $request['uri'] = $this->_buildUri($request['uri'], '/%path?%query'); |
901 | 901 | } |
902 | 902 | |
903 | - if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { |
|
903 | + if ( ! $this->quirksMode && $request['uri'] === '*' && ! in_array($request['method'], $asteriskMethods)) { |
|
904 | 904 | throw new SocketException(__d('cake_dev', 'HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods))); |
905 | 905 | } |
906 | - return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . "\r\n"; |
|
906 | + return $request['method'].' '.$request['uri'].' '.$versionToken."\r\n"; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | /** |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | protected function _buildHeader($header, $mode = 'standard') { |
917 | 917 | if (is_string($header)) { |
918 | 918 | return $header; |
919 | - } elseif (!is_array($header)) { |
|
919 | + } elseif ( ! is_array($header)) { |
|
920 | 920 | return false; |
921 | 921 | } |
922 | 922 | |
@@ -936,11 +936,11 @@ discard block |
||
936 | 936 | if (is_array($contents) && $mode === 'standard') { |
937 | 937 | $contents = implode(',', $contents); |
938 | 938 | } |
939 | - foreach ((array)$contents as $content) { |
|
939 | + foreach ((array) $contents as $content) { |
|
940 | 940 | $contents = preg_replace("/\r\n(?![\t ])/", "\r\n ", $content); |
941 | 941 | $field = $this->_escapeToken($field); |
942 | 942 | |
943 | - $returnHeader .= $field . ': ' . $contents . "\r\n"; |
|
943 | + $returnHeader .= $field.': '.$contents."\r\n"; |
|
944 | 944 | } |
945 | 945 | } |
946 | 946 | return $returnHeader; |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | } else { |
964 | 964 | $value = $this->_escapeToken($cookie, array(';')); |
965 | 965 | } |
966 | - $header[] = $name . '=' . $value; |
|
966 | + $header[] = $name.'='.$value; |
|
967 | 967 | } |
968 | 968 | return $this->_buildHeader(array('Cookie' => implode('; ', $header)), 'pragmatic'); |
969 | 969 | } |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | * @return string Escaped token |
977 | 977 | */ |
978 | 978 | protected function _escapeToken($token, $chars = null) { |
979 | - $regex = '/([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])/'; |
|
979 | + $regex = '/(['.implode('', $this->_tokenEscapeChars(true, $chars)).'])/'; |
|
980 | 980 | $token = preg_replace($regex, '"\\1"', $token); |
981 | 981 | return $token; |
982 | 982 | } |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | * @return array Escape chars |
990 | 990 | */ |
991 | 991 | protected function _tokenEscapeChars($hex = true, $chars = null) { |
992 | - if (!empty($chars)) { |
|
992 | + if ( ! empty($chars)) { |
|
993 | 993 | $escape = $chars; |
994 | 994 | } else { |
995 | 995 | $escape = array('"', "(", ")", "<", ">", "@", ",", ";", ":", "\\", "/", "[", "]", "?", "=", "{", "}", " "); |
@@ -999,11 +999,11 @@ discard block |
||
999 | 999 | $escape[] = chr(127); |
1000 | 1000 | } |
1001 | 1001 | |
1002 | - if (!$hex) { |
|
1002 | + if ( ! $hex) { |
|
1003 | 1003 | return $escape; |
1004 | 1004 | } |
1005 | 1005 | foreach ($escape as $key => $char) { |
1006 | - $escape[$key] = '\\x' . str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); |
|
1006 | + $escape[$key] = '\\x'.str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); |
|
1007 | 1007 | } |
1008 | 1008 | return $escape; |
1009 | 1009 | } |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | if (empty($initalState)) { |
1021 | 1021 | $initalState = get_class_vars(__CLASS__); |
1022 | 1022 | } |
1023 | - if (!$full) { |
|
1023 | + if ( ! $full) { |
|
1024 | 1024 | $this->request = $initalState['request']; |
1025 | 1025 | $this->response = $initalState['response']; |
1026 | 1026 | return true; |
@@ -104,7 +104,7 @@ |
||
104 | 104 | * |
105 | 105 | * @param string $name Header name |
106 | 106 | * @param array $headers |
107 | - * @return mixed String if header exists or null |
|
107 | + * @return string|boolean String if header exists or null |
|
108 | 108 | */ |
109 | 109 | public function getHeader($name, $headers = null) { |
110 | 110 | if (!is_array($headers)) { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return string |
97 | 97 | */ |
98 | 98 | public function body() { |
99 | - return (string)$this->body; |
|
99 | + return (string) $this->body; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * @return mixed String if header exists or null |
108 | 108 | */ |
109 | 109 | public function getHeader($name, $headers = null) { |
110 | - if (!is_array($headers)) { |
|
111 | - $headers =& $this->headers; |
|
110 | + if ( ! is_array($headers)) { |
|
111 | + $headers = & $this->headers; |
|
112 | 112 | } |
113 | 113 | if (isset($headers[$name])) { |
114 | 114 | return $headers[$name]; |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * @throws SocketException |
148 | 148 | */ |
149 | 149 | public function parseResponse($message) { |
150 | - if (!is_string($message)) { |
|
150 | + if ( ! is_string($message)) { |
|
151 | 151 | throw new SocketException(__d('cake_dev', 'Invalid response.')); |
152 | 152 | } |
153 | 153 | |
154 | - if (!preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) { |
|
154 | + if ( ! preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) { |
|
155 | 155 | throw new SocketException(__d('cake_dev', 'Invalid HTTP response.')); |
156 | 156 | } |
157 | 157 | |
158 | 158 | list(, $statusLine, $header) = $match; |
159 | 159 | $this->raw = $message; |
160 | - $this->body = (string)substr($message, strlen($match[0])); |
|
160 | + $this->body = (string) substr($message, strlen($match[0])); |
|
161 | 161 | |
162 | 162 | if (preg_match("/(.+) ([0-9]{3})\s*([^ ]*)\r\n/DU", $statusLine, $match)) { |
163 | 163 | $this->httpVersion = $match[1]; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | $decoded = $this->_decodeBody($this->body, $transferEncoding); |
171 | 171 | $this->body = $decoded['body']; |
172 | 172 | |
173 | - if (!empty($decoded['header'])) { |
|
174 | - $this->headers = $this->_parseHeader($this->_buildHeader($this->headers) . $this->_buildHeader($decoded['header'])); |
|
173 | + if ( ! empty($decoded['header'])) { |
|
174 | + $this->headers = $this->_parseHeader($this->_buildHeader($this->headers).$this->_buildHeader($decoded['header'])); |
|
175 | 175 | } |
176 | 176 | |
177 | - if (!empty($this->headers)) { |
|
177 | + if ( ! empty($this->headers)) { |
|
178 | 178 | $this->cookies = $this->parseCookies($this->headers); |
179 | 179 | } |
180 | 180 | } |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | * @return mixed Array of response headers and body or false. |
189 | 189 | */ |
190 | 190 | protected function _decodeBody($body, $encoding = 'chunked') { |
191 | - if (!is_string($body)) { |
|
191 | + if ( ! is_string($body)) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | if (empty($encoding)) { |
195 | 195 | return array('body' => $body, 'header' => false); |
196 | 196 | } |
197 | - $decodeMethod = '_decode' . Inflector::camelize(str_replace('-', '_', $encoding)) . 'Body'; |
|
197 | + $decodeMethod = '_decode'.Inflector::camelize(str_replace('-', '_', $encoding)).'Body'; |
|
198 | 198 | |
199 | - if (!is_callable(array(&$this, $decodeMethod))) { |
|
199 | + if ( ! is_callable(array(&$this, $decodeMethod))) { |
|
200 | 200 | return array('body' => $body, 'header' => false); |
201 | 201 | } |
202 | 202 | return $this->{$decodeMethod}($body); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @throws SocketException |
212 | 212 | */ |
213 | 213 | protected function _decodeChunkedBody($body) { |
214 | - if (!is_string($body)) { |
|
214 | + if ( ! is_string($body)) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $chunkLength = null; |
220 | 220 | |
221 | 221 | while ($chunkLength !== 0) { |
222 | - if (!preg_match('/^([0-9a-f]+) *(?:;(.+)=(.+))?(?:\r\n|\n)/iU', $body, $match)) { |
|
222 | + if ( ! preg_match('/^([0-9a-f]+) *(?:;(.+)=(.+))?(?:\r\n|\n)/iU', $body, $match)) { |
|
223 | 223 | throw new SocketException(__d('cake_dev', 'HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.')); |
224 | 224 | } |
225 | 225 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | $entityHeader = false; |
249 | - if (!empty($body)) { |
|
249 | + if ( ! empty($body)) { |
|
250 | 250 | $entityHeader = $this->_parseHeader($body); |
251 | 251 | } |
252 | 252 | return array('body' => $decodedBody, 'header' => $entityHeader); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | protected function _parseHeader($header) { |
262 | 262 | if (is_array($header)) { |
263 | 263 | return $header; |
264 | - } elseif (!is_string($header)) { |
|
264 | + } elseif ( ! is_string($header)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | |
277 | 277 | $field = $this->_unescapeToken($field); |
278 | 278 | |
279 | - if (!isset($header[$field])) { |
|
279 | + if ( ! isset($header[$field])) { |
|
280 | 280 | $header[$field] = $value; |
281 | 281 | } else { |
282 | - $header[$field] = array_merge((array)$header[$field], (array)$value); |
|
282 | + $header[$field] = array_merge((array) $header[$field], (array) $value); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | return $header; |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function parseCookies($header) { |
295 | 295 | $cookieHeader = $this->getHeader('Set-Cookie', $header); |
296 | - if (!$cookieHeader) { |
|
296 | + if ( ! $cookieHeader) { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
300 | 300 | $cookies = array(); |
301 | - foreach ((array)$cookieHeader as $cookie) { |
|
301 | + foreach ((array) $cookieHeader as $cookie) { |
|
302 | 302 | if (strpos($cookie, '";"') !== false) { |
303 | 303 | $cookie = str_replace('";"', "{__cookie_replace__}", $cookie); |
304 | 304 | $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie)); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | $key = strtolower($key); |
321 | - if (!isset($cookies[$name][$key])) { |
|
321 | + if ( ! isset($cookies[$name][$key])) { |
|
322 | 322 | $cookies[$name][$key] = $value; |
323 | 323 | } |
324 | 324 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @return string Unescaped token |
335 | 335 | */ |
336 | 336 | protected function _unescapeToken($token, $chars = null) { |
337 | - $regex = '/"([' . implode('', $this->_tokenEscapeChars(true, $chars)) . '])"/'; |
|
337 | + $regex = '/"(['.implode('', $this->_tokenEscapeChars(true, $chars)).'])"/'; |
|
338 | 338 | $token = preg_replace($regex, '\\1', $token); |
339 | 339 | return $token; |
340 | 340 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @return array Escape chars |
348 | 348 | */ |
349 | 349 | protected function _tokenEscapeChars($hex = true, $chars = null) { |
350 | - if (!empty($chars)) { |
|
350 | + if ( ! empty($chars)) { |
|
351 | 351 | $escape = $chars; |
352 | 352 | } else { |
353 | 353 | $escape = array('"', "(", ")", "<", ">", "@", ",", ";", ":", "\\", "/", "[", "]", "?", "=", "{", "}", " "); |
@@ -357,11 +357,11 @@ discard block |
||
357 | 357 | $escape[] = chr(127); |
358 | 358 | } |
359 | 359 | |
360 | - if (!$hex) { |
|
360 | + if ( ! $hex) { |
|
361 | 361 | return $escape; |
362 | 362 | } |
363 | 363 | foreach ($escape as $key => $char) { |
364 | - $escape[$key] = '\\x' . str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); |
|
364 | + $escape[$key] = '\\x'.str_pad(dechex(ord($char)), 2, '0', STR_PAD_LEFT); |
|
365 | 365 | } |
366 | 366 | return $escape; |
367 | 367 | } |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | if ($this->raw[$firstLineLength] === "\r") { |
390 | 390 | $header = null; |
391 | 391 | } else { |
392 | - $header = substr($this->raw, $firstLineLength, strpos($this->raw, "\r\n\r\n") - $firstLineLength) . "\r\n"; |
|
392 | + $header = substr($this->raw, $firstLineLength, strpos($this->raw, "\r\n\r\n") - $firstLineLength)."\r\n"; |
|
393 | 393 | } |
394 | 394 | return array( |
395 | - 'status-line' => $this->httpVersion . ' ' . $this->code . ' ' . $this->reasonPhrase . "\r\n", |
|
395 | + 'status-line' => $this->httpVersion.' '.$this->code.' '.$this->reasonPhrase."\r\n", |
|
396 | 396 | 'header' => $header, |
397 | 397 | 'body' => $this->body, |
398 | 398 | 'response' => $this->raw |
@@ -239,7 +239,7 @@ |
||
239 | 239 | * Load controller and return controller class name |
240 | 240 | * |
241 | 241 | * @param CakeRequest $request |
242 | - * @return string|boolean Name of controller class name |
|
242 | + * @return string|false Name of controller class name |
|
243 | 243 | */ |
244 | 244 | protected function _loadController($request) { |
245 | 245 | $pluginName = $pluginPath = $controller = null; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return CakeEventManager |
65 | 65 | */ |
66 | 66 | public function getEventManager() { |
67 | - if (!$this->_eventManager) { |
|
67 | + if ( ! $this->_eventManager) { |
|
68 | 68 | $this->_eventManager = new CakeEventManager(); |
69 | 69 | $this->_eventManager->attach($this); |
70 | 70 | $this->_attachFilters($this->_eventManager); |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | } |
102 | 102 | if (is_string($filter['callable'])) { |
103 | 103 | list($plugin, $callable) = pluginSplit($filter['callable'], true); |
104 | - App::uses($callable, $plugin . 'Routing/Filter'); |
|
105 | - if (!class_exists($callable)) { |
|
104 | + App::uses($callable, $plugin.'Routing/Filter'); |
|
105 | + if ( ! class_exists($callable)) { |
|
106 | 106 | throw new MissingDispatcherFilterException($callable); |
107 | 107 | } |
108 | 108 | $manager->attach(new $callable); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if (isset($filter['priority'])) { |
113 | 113 | $options = array('priority' => $filter['priority']); |
114 | 114 | } |
115 | - $manager->attach($filter['callable'], 'Dispatcher.' . $on . 'Dispatch', $options); |
|
115 | + $manager->attach($filter['callable'], 'Dispatcher.'.$on.'Dispatch', $options); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | |
151 | 151 | $controller = $this->_getController($request, $response); |
152 | 152 | |
153 | - if (!($controller instanceof Controller)) { |
|
153 | + if ( ! ($controller instanceof Controller)) { |
|
154 | 154 | throw new MissingControllerException(array( |
155 | - 'class' => Inflector::camelize($request->params['controller']) . 'Controller', |
|
155 | + 'class' => Inflector::camelize($request->params['controller']).'Controller', |
|
156 | 156 | 'plugin' => empty($request->params['plugin']) ? null : Inflector::camelize($request->params['plugin']) |
157 | 157 | )); |
158 | 158 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | if ($render && $controller->autoRender) { |
192 | 192 | $response = $controller->render(); |
193 | - } elseif (!($result instanceof CakeResponse) && $response->body() === null) { |
|
193 | + } elseif ( ! ($result instanceof CakeResponse) && $response->body() === null) { |
|
194 | 194 | $response->body($result); |
195 | 195 | } |
196 | 196 | $controller->shutdownProcess(); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $params = Router::parse($request->url); |
212 | 212 | $request->addParams($params); |
213 | 213 | |
214 | - if (!empty($event->data['additionalParams'])) { |
|
214 | + if ( ! empty($event->data['additionalParams'])) { |
|
215 | 215 | $request->addParams($event->data['additionalParams']); |
216 | 216 | } |
217 | 217 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | protected function _getController($request, $response) { |
227 | 227 | $ctrlClass = $this->_loadController($request); |
228 | - if (!$ctrlClass) { |
|
228 | + if ( ! $ctrlClass) { |
|
229 | 229 | return false; |
230 | 230 | } |
231 | 231 | $reflection = new ReflectionClass($ctrlClass); |
@@ -243,18 +243,18 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function _loadController($request) { |
245 | 245 | $pluginName = $pluginPath = $controller = null; |
246 | - if (!empty($request->params['plugin'])) { |
|
246 | + if ( ! empty($request->params['plugin'])) { |
|
247 | 247 | $pluginName = $controller = Inflector::camelize($request->params['plugin']); |
248 | - $pluginPath = $pluginName . '.'; |
|
248 | + $pluginPath = $pluginName.'.'; |
|
249 | 249 | } |
250 | - if (!empty($request->params['controller'])) { |
|
250 | + if ( ! empty($request->params['controller'])) { |
|
251 | 251 | $controller = Inflector::camelize($request->params['controller']); |
252 | 252 | } |
253 | - if ($pluginPath . $controller) { |
|
254 | - $class = $controller . 'Controller'; |
|
253 | + if ($pluginPath.$controller) { |
|
254 | + $class = $controller.'Controller'; |
|
255 | 255 | App::uses('AppController', 'Controller'); |
256 | - App::uses($pluginName . 'AppController', $pluginPath . 'Controller'); |
|
257 | - App::uses($class, $pluginPath . 'Controller'); |
|
256 | + App::uses($pluginName.'AppController', $pluginPath.'Controller'); |
|
257 | + App::uses($class, $pluginPath.'Controller'); |
|
258 | 258 | if (class_exists($class)) { |
259 | 259 | return $class; |
260 | 260 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * Modifies defaults property so all necessary keys are set |
110 | 110 | * and populates $this->names with the named routing elements. |
111 | 111 | * |
112 | - * @return array Returns a string regular expression of the compiled route. |
|
112 | + * @return string Returns a string regular expression of the compiled route. |
|
113 | 113 | */ |
114 | 114 | public function compile() { |
115 | 115 | if ($this->compiled()) { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * Currently implemented rule types are controller, action and match that can be combined with each other. |
333 | 333 | * |
334 | 334 | * @param string $val The value of the named parameter |
335 | - * @param array $rule The rule(s) to apply, can also be a match string |
|
335 | + * @param string $rule The rule(s) to apply, can also be a match string |
|
336 | 336 | * @param string $context An array with additional context information (controller / action) |
337 | 337 | * @return boolean |
338 | 338 | */ |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * This method handles the reverse routing or conversion of URL arrays into string URLs. |
394 | 394 | * |
395 | 395 | * @param array $url An array of parameters to check matching with. |
396 | - * @return mixed Either a string URL for the parameters if they match or false. |
|
396 | + * @return false|string Either a string URL for the parameters if they match or false. |
|
397 | 397 | */ |
398 | 398 | public function match($url) { |
399 | 399 | if (!$this->compiled()) { |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function __construct($template, $defaults = array(), $options = array()) { |
92 | 92 | $this->template = $template; |
93 | - $this->defaults = (array)$defaults; |
|
94 | - $this->options = (array)$options; |
|
93 | + $this->defaults = (array) $defaults; |
|
94 | + $this->options = (array) $options; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | 102 | public function compiled() { |
103 | - return !empty($this->_compiledRoute); |
|
103 | + return ! empty($this->_compiledRoute); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -139,20 +139,20 @@ discard block |
||
139 | 139 | |
140 | 140 | preg_match_all('#:([A-Za-z0-9_-]+[A-Z0-9a-z])#', $route, $namedElements); |
141 | 141 | foreach ($namedElements[1] as $i => $name) { |
142 | - $search = '\\' . $namedElements[0][$i]; |
|
142 | + $search = '\\'.$namedElements[0][$i]; |
|
143 | 143 | if (isset($this->options[$name])) { |
144 | 144 | $option = null; |
145 | 145 | if ($name !== 'plugin' && array_key_exists($name, $this->defaults)) { |
146 | 146 | $option = '?'; |
147 | 147 | } |
148 | - $slashParam = '/\\' . $namedElements[0][$i]; |
|
148 | + $slashParam = '/\\'.$namedElements[0][$i]; |
|
149 | 149 | if (strpos($parsed, $slashParam) !== false) { |
150 | - $routeParams[$slashParam] = '(?:/(?P<' . $name . '>' . $this->options[$name] . ')' . $option . ')' . $option; |
|
150 | + $routeParams[$slashParam] = '(?:/(?P<'.$name.'>'.$this->options[$name].')'.$option.')'.$option; |
|
151 | 151 | } else { |
152 | - $routeParams[$search] = '(?:(?P<' . $name . '>' . $this->options[$name] . ')' . $option . ')' . $option; |
|
152 | + $routeParams[$search] = '(?:(?P<'.$name.'>'.$this->options[$name].')'.$option.')'.$option; |
|
153 | 153 | } |
154 | 154 | } else { |
155 | - $routeParams[$search] = '(?:(?P<' . $name . '>[^/]+))'; |
|
155 | + $routeParams[$search] = '(?:(?P<'.$name.'>[^/]+))'; |
|
156 | 156 | } |
157 | 157 | $names[] = $name; |
158 | 158 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | } |
167 | 167 | krsort($routeParams); |
168 | 168 | $parsed = str_replace(array_keys($routeParams), array_values($routeParams), $parsed); |
169 | - $this->_compiledRoute = '#^' . $parsed . '[/]*$#'; |
|
169 | + $this->_compiledRoute = '#^'.$parsed.'[/]*$#'; |
|
170 | 170 | $this->keys = $names; |
171 | 171 | |
172 | 172 | // Remove defaults that are also keys. They can cause match failures |
@@ -189,23 +189,23 @@ discard block |
||
189 | 189 | * @return mixed Boolean false on failure, otherwise an array or parameters |
190 | 190 | */ |
191 | 191 | public function parse($url) { |
192 | - if (!$this->compiled()) { |
|
192 | + if ( ! $this->compiled()) { |
|
193 | 193 | $this->compile(); |
194 | 194 | } |
195 | - if (!preg_match($this->_compiledRoute, urldecode($url), $route)) { |
|
195 | + if ( ! preg_match($this->_compiledRoute, urldecode($url), $route)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | foreach ($this->defaults as $key => $val) { |
199 | - $key = (string)$key; |
|
199 | + $key = (string) $key; |
|
200 | 200 | if ($key[0] === '[' && preg_match('/^\[(\w+)\]$/', $key, $header)) { |
201 | 201 | if (isset($this->_headerMap[$header[1]])) { |
202 | 202 | $header = $this->_headerMap[$header[1]]; |
203 | 203 | } else { |
204 | - $header = 'http_' . $header[1]; |
|
204 | + $header = 'http_'.$header[1]; |
|
205 | 205 | } |
206 | 206 | $header = strtoupper($header); |
207 | 207 | |
208 | - $val = (array)$val; |
|
208 | + $val = (array) $val; |
|
209 | 209 | $h = false; |
210 | 210 | |
211 | 211 | foreach ($val as $v) { |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $h = true; |
214 | 214 | } |
215 | 215 | } |
216 | - if (!$h) { |
|
216 | + if ( ! $h) { |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | } |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | $namedConfig = Router::namedConfig(); |
277 | 277 | $greedy = $namedConfig['greedyNamed']; |
278 | 278 | $rules = $namedConfig['rules']; |
279 | - if (!empty($this->options['named'])) { |
|
279 | + if ( ! empty($this->options['named'])) { |
|
280 | 280 | $greedy = isset($this->options['greedyNamed']) && $this->options['greedyNamed'] === true; |
281 | - foreach ((array)$this->options['named'] as $key => $val) { |
|
281 | + foreach ((array) $this->options['named'] as $key => $val) { |
|
282 | 282 | if (is_numeric($key)) { |
283 | 283 | $rules[$val] = true; |
284 | 284 | continue; |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; |
296 | - if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { |
|
296 | + if (( ! isset($this->options['named']) || ! empty($this->options['named'])) && $separatorIsPresent) { |
|
297 | 297 | list($key, $val) = explode($namedConfig['separator'], $param, 2); |
298 | 298 | $hasRule = isset($rules[$key]); |
299 | - $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context)); |
|
299 | + $passIt = ( ! $hasRule && ! $greedy) || ($hasRule && ! $this->_matchNamed($val, $rules[$key], $context)); |
|
300 | 300 | if ($passIt) { |
301 | 301 | $pass[] = $param; |
302 | 302 | } else { |
@@ -343,25 +343,25 @@ discard block |
||
343 | 343 | if (is_string($rule)) { |
344 | 344 | $rule = array('match' => $rule); |
345 | 345 | } |
346 | - if (!is_array($rule)) { |
|
346 | + if ( ! is_array($rule)) { |
|
347 | 347 | return false; |
348 | 348 | } |
349 | 349 | |
350 | 350 | $controllerMatches = ( |
351 | - !isset($rule['controller'], $context['controller']) || |
|
352 | - in_array($context['controller'], (array)$rule['controller']) |
|
351 | + ! isset($rule['controller'], $context['controller']) || |
|
352 | + in_array($context['controller'], (array) $rule['controller']) |
|
353 | 353 | ); |
354 | - if (!$controllerMatches) { |
|
354 | + if ( ! $controllerMatches) { |
|
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | $actionMatches = ( |
358 | - !isset($rule['action'], $context['action']) || |
|
359 | - in_array($context['action'], (array)$rule['action']) |
|
358 | + ! isset($rule['action'], $context['action']) || |
|
359 | + in_array($context['action'], (array) $rule['action']) |
|
360 | 360 | ); |
361 | - if (!$actionMatches) { |
|
361 | + if ( ! $actionMatches) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | - return (!isset($rule['match']) || preg_match('/' . $rule['match'] . '/', $val)); |
|
364 | + return ( ! isset($rule['match']) || preg_match('/'.$rule['match'].'/', $val)); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | * @return array An array with persistent parameters applied. |
375 | 375 | */ |
376 | 376 | public function persistParams($url, $params) { |
377 | - if (empty($this->options['persist']) || !is_array($this->options['persist'])) { |
|
377 | + if (empty($this->options['persist']) || ! is_array($this->options['persist'])) { |
|
378 | 378 | return $url; |
379 | 379 | } |
380 | 380 | foreach ($this->options['persist'] as $persistKey) { |
381 | - if (array_key_exists($persistKey, $params) && !isset($url[$persistKey])) { |
|
381 | + if (array_key_exists($persistKey, $params) && ! isset($url[$persistKey])) { |
|
382 | 382 | $url[$persistKey] = $params[$persistKey]; |
383 | 383 | } |
384 | 384 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @return mixed Either a string URL for the parameters if they match or false. |
397 | 397 | */ |
398 | 398 | public function match($url) { |
399 | - if (!$this->compiled()) { |
|
399 | + if ( ! $this->compiled()) { |
|
400 | 400 | $this->compile(); |
401 | 401 | } |
402 | 402 | $defaults = $this->defaults; |
@@ -451,27 +451,27 @@ discard block |
||
451 | 451 | if ( |
452 | 452 | ($greedyNamed || isset($allowedNamedParams[$key])) && |
453 | 453 | ($value !== false && $value !== null) && |
454 | - (!in_array($key, $prefixes)) |
|
454 | + ( ! in_array($key, $prefixes)) |
|
455 | 455 | ) { |
456 | 456 | $named[$key] = $value; |
457 | 457 | continue; |
458 | 458 | } |
459 | 459 | |
460 | 460 | // keys that don't exist are different. |
461 | - if (!$defaultExists && !empty($value)) { |
|
461 | + if ( ! $defaultExists && ! empty($value)) { |
|
462 | 462 | return false; |
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | 466 | //if a not a greedy route, no extra params are allowed. |
467 | - if (!$this->_greedy && (!empty($pass) || !empty($named))) { |
|
467 | + if ( ! $this->_greedy && ( ! empty($pass) || ! empty($named))) { |
|
468 | 468 | return false; |
469 | 469 | } |
470 | 470 | |
471 | 471 | //check patterns for routed params |
472 | - if (!empty($this->options)) { |
|
472 | + if ( ! empty($this->options)) { |
|
473 | 473 | foreach ($this->options as $key => $pattern) { |
474 | - if (array_key_exists($key, $url) && !preg_match('#^' . $pattern . '$#', $url[$key])) { |
|
474 | + if (array_key_exists($key, $url) && ! preg_match('#^'.$pattern.'$#', $url[$key])) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | */ |
491 | 491 | protected function _writeUrl($params) { |
492 | 492 | if (isset($params['prefix'])) { |
493 | - $prefixed = $params['prefix'] . '_'; |
|
493 | + $prefixed = $params['prefix'].'_'; |
|
494 | 494 | } |
495 | 495 | if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) { |
496 | 496 | $params['action'] = substr($params['action'], strlen($prefixed)); |
@@ -504,23 +504,23 @@ discard block |
||
504 | 504 | $namedConfig = Router::namedConfig(); |
505 | 505 | $separator = $namedConfig['separator']; |
506 | 506 | |
507 | - if (!empty($params['named']) && is_array($params['named'])) { |
|
507 | + if ( ! empty($params['named']) && is_array($params['named'])) { |
|
508 | 508 | $named = array(); |
509 | 509 | foreach ($params['named'] as $key => $value) { |
510 | 510 | if (is_array($value)) { |
511 | 511 | $flat = Hash::flatten($value, '%5D%5B'); |
512 | 512 | foreach ($flat as $namedKey => $namedValue) { |
513 | - $named[] = $key . "%5B{$namedKey}%5D" . $separator . rawurlencode($namedValue); |
|
513 | + $named[] = $key."%5B{$namedKey}%5D".$separator.rawurlencode($namedValue); |
|
514 | 514 | } |
515 | 515 | } else { |
516 | - $named[] = $key . $separator . rawurlencode($value); |
|
516 | + $named[] = $key.$separator.rawurlencode($value); |
|
517 | 517 | } |
518 | 518 | } |
519 | - $params['pass'] = $params['pass'] . '/' . implode('/', $named); |
|
519 | + $params['pass'] = $params['pass'].'/'.implode('/', $named); |
|
520 | 520 | } |
521 | 521 | $out = $this->template; |
522 | 522 | |
523 | - if (!empty($this->keys)) { |
|
523 | + if ( ! empty($this->keys)) { |
|
524 | 524 | $search = $replace = array(); |
525 | 525 | |
526 | 526 | foreach ($this->keys as $key) { |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | } elseif (strpos($out, $key) != strlen($out) - strlen($key)) { |
531 | 531 | $key .= '/'; |
532 | 532 | } |
533 | - $search[] = ':' . $key; |
|
533 | + $search[] = ':'.$key; |
|
534 | 534 | $replace[] = $string; |
535 | 535 | } |
536 | 536 | $out = str_replace($search, $replace, $out); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * controller parameter |
29 | 29 | * |
30 | 30 | * @param string $url The URL to parse |
31 | - * @return mixed false on failure, or an array of request parameters |
|
31 | + * @return boolean false on failure, or an array of request parameters |
|
32 | 32 | */ |
33 | 33 | public function parse($url) { |
34 | 34 | $params = parent::parse($url); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * are not the same the match is an auto fail. |
45 | 45 | * |
46 | 46 | * @param array $url Array of parameters to convert to a string. |
47 | - * @return mixed either false or a string URL. |
|
47 | + * @return false|string either false or a string URL. |
|
48 | 48 | */ |
49 | 49 | public function match($url) { |
50 | 50 | if (isset($url['controller']) && isset($url['plugin']) && $url['plugin'] != $url['controller']) { |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | public function parse($url) { |
34 | 34 | $params = parent::parse($url); |
35 | - if (!$params) { |
|
35 | + if ( ! $params) { |
|
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | $params['controller'] = $params['plugin']; |