@@ -34,7 +34,7 @@ |
||
34 | 34 | * Get / Set the userAgent |
35 | 35 | * |
36 | 36 | * @param string $userAgent Set the userAgent |
37 | - * @return void |
|
37 | + * @return string |
|
38 | 38 | */ |
39 | 39 | public function userAgent($userAgent = null) { |
40 | 40 | return CakeSession::userAgent($userAgent); |
@@ -123,7 +123,7 @@ |
||
123 | 123 | * @link http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html#creating-notification-messages |
124 | 124 | */ |
125 | 125 | public function setFlash($message, $element = 'default', $params = array(), $key = 'flash') { |
126 | - CakeSession::write('Message.' . $key, compact('message', 'element', 'params')); |
|
126 | + CakeSession::write('Message.'.$key, compact('message', 'element', 'params')); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -629,7 +629,7 @@ |
||
629 | 629 | * see Controller::loadModel(); for more info. |
630 | 630 | * Loads Components and prepares them for initialization. |
631 | 631 | * |
632 | - * @return mixed true if models found and instance created. |
|
632 | + * @return boolean true if models found and instance created. |
|
633 | 633 | * @see Controller::loadModel() |
634 | 634 | * @link http://book.cakephp.org/2.0/en/controllers.html#Controller::constructClasses |
635 | 635 | * @throws MissingModelException |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $this->name = substr(get_class($this), 0, -10); |
321 | 321 | } |
322 | 322 | |
323 | - if (!$this->viewPath) { |
|
323 | + if ( ! $this->viewPath) { |
|
324 | 324 | $this->viewPath = $this->name; |
325 | 325 | } |
326 | 326 | |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | |
372 | 372 | if ($name === $this->modelClass) { |
373 | 373 | list($plugin, $class) = pluginSplit($name, true); |
374 | - if (!$plugin) { |
|
375 | - $plugin = $this->plugin ? $this->plugin . '.' : null; |
|
374 | + if ( ! $plugin) { |
|
375 | + $plugin = $this->plugin ? $this->plugin.'.' : null; |
|
376 | 376 | } |
377 | - return $this->loadModel($plugin . $this->modelClass); |
|
377 | + return $this->loadModel($plugin.$this->modelClass); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | return false; |
@@ -459,10 +459,10 @@ discard block |
||
459 | 459 | $this->passedArgs = array_merge($request->params['pass'], $request->params['named']); |
460 | 460 | } |
461 | 461 | |
462 | - if (!empty($request->params['return']) && $request->params['return'] == 1) { |
|
462 | + if ( ! empty($request->params['return']) && $request->params['return'] == 1) { |
|
463 | 463 | $this->autoRender = false; |
464 | 464 | } |
465 | - if (!empty($request->params['bare'])) { |
|
465 | + if ( ! empty($request->params['bare'])) { |
|
466 | 466 | $this->autoLayout = false; |
467 | 467 | } |
468 | 468 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | |
484 | 484 | if ($this->_isPrivateAction($method, $request)) { |
485 | 485 | throw new PrivateActionException(array( |
486 | - 'controller' => $this->name . "Controller", |
|
486 | + 'controller' => $this->name."Controller", |
|
487 | 487 | 'action' => $request->params['action'] |
488 | 488 | )); |
489 | 489 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | return $this->_getScaffold($request); |
495 | 495 | } |
496 | 496 | throw new MissingActionException(array( |
497 | - 'controller' => $this->name . "Controller", |
|
497 | + 'controller' => $this->name."Controller", |
|
498 | 498 | 'action' => $request->params['action'] |
499 | 499 | )); |
500 | 500 | } |
@@ -511,12 +511,12 @@ discard block |
||
511 | 511 | protected function _isPrivateAction(ReflectionMethod $method, CakeRequest $request) { |
512 | 512 | $privateAction = ( |
513 | 513 | $method->name[0] === '_' || |
514 | - !$method->isPublic() || |
|
515 | - !in_array($method->name, $this->methods) |
|
514 | + ! $method->isPublic() || |
|
515 | + ! in_array($method->name, $this->methods) |
|
516 | 516 | ); |
517 | 517 | $prefixes = Router::prefixes(); |
518 | 518 | |
519 | - if (!$privateAction && !empty($prefixes)) { |
|
519 | + if ( ! $privateAction && ! empty($prefixes)) { |
|
520 | 520 | if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) { |
521 | 521 | list($prefix) = explode('_', $request->params['action']); |
522 | 522 | $privateAction = in_array($prefix, $prefixes); |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | $pluginVars = array(); |
548 | 548 | $appVars = array(); |
549 | 549 | |
550 | - if (!empty($this->plugin)) { |
|
551 | - $pluginController = $this->plugin . 'AppController'; |
|
552 | - if (!is_subclass_of($this, $pluginController)) { |
|
550 | + if ( ! empty($this->plugin)) { |
|
551 | + $pluginController = $this->plugin.'AppController'; |
|
552 | + if ( ! is_subclass_of($this, $pluginController)) { |
|
553 | 553 | $pluginController = null; |
554 | 554 | } |
555 | - $pluginDot = $this->plugin . '.'; |
|
555 | + $pluginDot = $this->plugin.'.'; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | if ($pluginController) { |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | $this->_mergeVars($merge, $pluginController); |
561 | 561 | } |
562 | 562 | |
563 | - if ($mergeParent || !empty($pluginController)) { |
|
563 | + if ($mergeParent || ! empty($pluginController)) { |
|
564 | 564 | $appVars = get_class_vars($this->_mergeParent); |
565 | 565 | $merge = array('components', 'helpers'); |
566 | 566 | $this->_mergeVars($merge, $this->_mergeParent, true); |
@@ -570,10 +570,10 @@ discard block |
||
570 | 570 | $this->uses = false; |
571 | 571 | } |
572 | 572 | if ($this->uses === true) { |
573 | - $this->uses = array($pluginDot . $this->modelClass); |
|
573 | + $this->uses = array($pluginDot.$this->modelClass); |
|
574 | 574 | } |
575 | 575 | if (isset($appVars['uses']) && $appVars['uses'] === $this->uses) { |
576 | - array_unshift($this->uses, $pluginDot . $this->modelClass); |
|
576 | + array_unshift($this->uses, $pluginDot.$this->modelClass); |
|
577 | 577 | } |
578 | 578 | if ($pluginController) { |
579 | 579 | $pluginVars = get_class_vars($pluginController); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @return void |
598 | 598 | */ |
599 | 599 | protected function _mergeUses($merge) { |
600 | - if (!isset($merge['uses'])) { |
|
600 | + if ( ! isset($merge['uses'])) { |
|
601 | 601 | return; |
602 | 602 | } |
603 | 603 | if ($merge['uses'] === true) { |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | public function constructClasses() { |
638 | 638 | $this->_mergeControllerVars(); |
639 | 639 | if ($this->uses) { |
640 | - $this->uses = (array)$this->uses; |
|
640 | + $this->uses = (array) $this->uses; |
|
641 | 641 | list(, $this->modelClass) = pluginSplit(reset($this->uses)); |
642 | 642 | } |
643 | 643 | $this->Components->init($this); |
@@ -726,17 +726,17 @@ discard block |
||
726 | 726 | $modelClass = $this->modelClass; |
727 | 727 | } |
728 | 728 | |
729 | - $this->uses = ($this->uses) ? (array)$this->uses : array(); |
|
730 | - if (!in_array($modelClass, $this->uses, true)) { |
|
729 | + $this->uses = ($this->uses) ? (array) $this->uses : array(); |
|
730 | + if ( ! in_array($modelClass, $this->uses, true)) { |
|
731 | 731 | $this->uses[] = $modelClass; |
732 | 732 | } |
733 | 733 | |
734 | 734 | list($plugin, $modelClass) = pluginSplit($modelClass, true); |
735 | 735 | |
736 | 736 | $this->{$modelClass} = ClassRegistry::init(array( |
737 | - 'class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id |
|
737 | + 'class' => $plugin.$modelClass, 'alias' => $modelClass, 'id' => $id |
|
738 | 738 | )); |
739 | - if (!$this->{$modelClass}) { |
|
739 | + if ( ! $this->{$modelClass}) { |
|
740 | 740 | throw new MissingModelException($modelClass); |
741 | 741 | } |
742 | 742 | return true; |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | $errors = array_merge($errors, $object->invalidFields()); |
912 | 912 | } |
913 | 913 | |
914 | - return $this->validationErrors = (!empty($errors) ? $errors : false); |
|
914 | + return $this->validationErrors = ( ! empty($errors) ? $errors : false); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | /** |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | return $this->response; |
931 | 931 | } |
932 | 932 | |
933 | - if (!empty($this->uses) && is_array($this->uses)) { |
|
933 | + if ( ! empty($this->uses) && is_array($this->uses)) { |
|
934 | 934 | foreach ($this->uses as $model) { |
935 | 935 | list($plugin, $className) = pluginSplit($model); |
936 | 936 | $this->request->params['models'][$className] = compact('plugin', 'className'); |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | $className = get_class($currentObject); |
947 | 947 | list($plugin) = pluginSplit(App::location($className)); |
948 | 948 | $this->request->params['models'][$currentObject->alias] = compact('plugin', 'className'); |
949 | - $this->View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors; |
|
949 | + $this->View->validationErrors[$currentObject->alias] = & $currentObject->validationErrors; |
|
950 | 950 | } |
951 | 951 | } |
952 | 952 | |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | * @link http://book.cakephp.org/2.0/en/controllers.html#Controller::referer |
965 | 965 | */ |
966 | 966 | public function referer($default = null, $local = false) { |
967 | - if (!$this->request) { |
|
967 | + if ( ! $this->request) { |
|
968 | 968 | return '/'; |
969 | 969 | } |
970 | 970 | |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | * @deprecated Will be removed in 3.0. |
1022 | 1022 | */ |
1023 | 1023 | public function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive = false) { |
1024 | - if (!is_array($data) || empty($data)) { |
|
1025 | - if (!empty($this->request->data)) { |
|
1024 | + if ( ! is_array($data) || empty($data)) { |
|
1025 | + if ( ! empty($this->request->data)) { |
|
1026 | 1026 | $data = $this->request->data; |
1027 | 1027 | } else { |
1028 | 1028 | return null; |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | $arrayOp = is_array($op); |
1038 | 1038 | foreach ($data as $model => $fields) { |
1039 | 1039 | foreach ($fields as $field => $value) { |
1040 | - $key = $model . '.' . $field; |
|
1040 | + $key = $model.'.'.$field; |
|
1041 | 1041 | $fieldOp = $op; |
1042 | 1042 | if ($arrayOp) { |
1043 | 1043 | if (array_key_exists($key, $op)) { |
@@ -1053,10 +1053,10 @@ discard block |
||
1053 | 1053 | } |
1054 | 1054 | $fieldOp = strtoupper(trim($fieldOp)); |
1055 | 1055 | if ($fieldOp === 'LIKE') { |
1056 | - $key = $key . ' LIKE'; |
|
1057 | - $value = '%' . $value . '%'; |
|
1056 | + $key = $key.' LIKE'; |
|
1057 | + $value = '%'.$value.'%'; |
|
1058 | 1058 | } elseif ($fieldOp && $fieldOp !== '=') { |
1059 | - $key = $key . ' ' . $fieldOp; |
|
1059 | + $key = $key.' '.$fieldOp; |
|
1060 | 1060 | } |
1061 | 1061 | $cond[$key] = $value; |
1062 | 1062 | } |
@@ -1234,8 +1234,8 @@ discard block |
||
1234 | 1234 | $viewClass = $this->viewClass; |
1235 | 1235 | if ($this->viewClass !== 'View') { |
1236 | 1236 | list($plugin, $viewClass) = pluginSplit($viewClass, true); |
1237 | - $viewClass = $viewClass . 'View'; |
|
1238 | - App::uses($viewClass, $plugin . 'View'); |
|
1237 | + $viewClass = $viewClass.'View'; |
|
1238 | + App::uses($viewClass, $plugin.'View'); |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | return new $viewClass($this); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * Renders a view action of scaffolded model. |
156 | 156 | * |
157 | 157 | * @param CakeRequest $request Request Object for scaffolding |
158 | - * @return mixed A rendered view of a row from Models database table |
|
158 | + * @return null|CakeResponse A rendered view of a row from Models database table |
|
159 | 159 | * @throws NotFoundException |
160 | 160 | */ |
161 | 161 | protected function _scaffoldView(CakeRequest $request) { |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | /** |
181 | 181 | * Renders index action of scaffolded model. |
182 | 182 | * |
183 | - * @param array $params Parameters for scaffolding |
|
184 | - * @return mixed A rendered view listing rows from Models database table |
|
183 | + * @param CakeRequest $params Parameters for scaffolding |
|
184 | + * @return null|CakeResponse A rendered view listing rows from Models database table |
|
185 | 185 | */ |
186 | 186 | protected function _scaffoldIndex($params) { |
187 | 187 | if ($this->controller->beforeScaffold('index')) { |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * Performs a delete on given scaffolded Model. |
286 | 286 | * |
287 | 287 | * @param CakeRequest $request Request for scaffolding |
288 | - * @return mixed Success on delete, error if delete fails |
|
288 | + * @return null|CakeResponse Success on delete, error if delete fails |
|
289 | 289 | * @throws MethodNotAllowedException When HTTP method is not a DELETE |
290 | 290 | * @throws NotFoundException When id being deleted does not exist. |
291 | 291 | */ |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | /** |
336 | 336 | * Show a scaffold error |
337 | 337 | * |
338 | - * @return mixed A rendered view showing the error |
|
338 | + * @return CakeResponse A rendered view showing the error |
|
339 | 339 | */ |
340 | 340 | protected function _scaffoldError() { |
341 | 341 | return $this->controller->render('error', $this->layout); |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | $this->modelClass = $controller->modelClass; |
119 | 119 | $this->modelKey = $controller->modelKey; |
120 | 120 | |
121 | - if (!is_object($this->controller->{$this->modelClass})) { |
|
121 | + if ( ! is_object($this->controller->{$this->modelClass})) { |
|
122 | 122 | throw new MissingModelException($this->modelClass); |
123 | 123 | } |
124 | 124 | |
125 | 125 | $this->ScaffoldModel = $this->controller->{$this->modelClass}; |
126 | 126 | $this->scaffoldTitle = Inflector::humanize(Inflector::underscore($this->viewPath)); |
127 | 127 | $this->scaffoldActions = $controller->scaffold; |
128 | - $title = __d('cake', 'Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle; |
|
128 | + $title = __d('cake', 'Scaffold :: ').Inflector::humanize($request->action).' :: '.$this->scaffoldTitle; |
|
129 | 129 | $modelClass = $this->controller->modelClass; |
130 | 130 | $primaryKey = $this->ScaffoldModel->primaryKey; |
131 | 131 | $displayField = $this->ScaffoldModel->displayField; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | if (isset($request->params['pass'][0])) { |
164 | 164 | $this->ScaffoldModel->id = $request->params['pass'][0]; |
165 | 165 | } |
166 | - if (!$this->ScaffoldModel->exists()) { |
|
166 | + if ( ! $this->ScaffoldModel->exists()) { |
|
167 | 167 | throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelKey))); |
168 | 168 | } |
169 | 169 | $this->ScaffoldModel->recursive = 1; |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | if (isset($request->params['pass'][0])) { |
231 | 231 | $this->ScaffoldModel->id = $request['pass'][0]; |
232 | 232 | } |
233 | - if (!$this->ScaffoldModel->exists()) { |
|
233 | + if ( ! $this->ScaffoldModel->exists()) { |
|
234 | 234 | throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelKey))); |
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | - if (!empty($request->data)) { |
|
238 | + if ( ! empty($request->data)) { |
|
239 | 239 | if ($action === 'create') { |
240 | 240 | $this->ScaffoldModel->create(); |
241 | 241 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | protected function _scaffoldDelete(CakeRequest $request) { |
293 | 293 | if ($this->controller->beforeScaffold('delete')) { |
294 | - if (!$request->is('post')) { |
|
294 | + if ( ! $request->is('post')) { |
|
295 | 295 | throw new MethodNotAllowedException(); |
296 | 296 | } |
297 | 297 | $id = false; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $id = $request->params['pass'][0]; |
300 | 300 | } |
301 | 301 | $this->ScaffoldModel->id = $id; |
302 | - if (!$this->ScaffoldModel->exists()) { |
|
302 | + if ( ! $this->ScaffoldModel->exists()) { |
|
303 | 303 | throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelClass))); |
304 | 304 | } |
305 | 305 | if ($this->ScaffoldModel->delete()) { |
@@ -361,22 +361,22 @@ discard block |
||
361 | 361 | $this->scaffoldActions = array( |
362 | 362 | 'index', 'list', 'view', 'add', 'create', 'edit', 'update', 'delete' |
363 | 363 | ); |
364 | - } elseif (!empty($prefixes) && in_array($scaffoldPrefix, $prefixes)) { |
|
364 | + } elseif ( ! empty($prefixes) && in_array($scaffoldPrefix, $prefixes)) { |
|
365 | 365 | $this->scaffoldActions = array( |
366 | - $scaffoldPrefix . '_index', |
|
367 | - $scaffoldPrefix . '_list', |
|
368 | - $scaffoldPrefix . '_view', |
|
369 | - $scaffoldPrefix . '_add', |
|
370 | - $scaffoldPrefix . '_create', |
|
371 | - $scaffoldPrefix . '_edit', |
|
372 | - $scaffoldPrefix . '_update', |
|
373 | - $scaffoldPrefix . '_delete' |
|
366 | + $scaffoldPrefix.'_index', |
|
367 | + $scaffoldPrefix.'_list', |
|
368 | + $scaffoldPrefix.'_view', |
|
369 | + $scaffoldPrefix.'_add', |
|
370 | + $scaffoldPrefix.'_create', |
|
371 | + $scaffoldPrefix.'_edit', |
|
372 | + $scaffoldPrefix.'_update', |
|
373 | + $scaffoldPrefix.'_delete' |
|
374 | 374 | ); |
375 | 375 | } |
376 | 376 | |
377 | 377 | if (in_array($request->params['action'], $this->scaffoldActions)) { |
378 | - if (!empty($prefixes)) { |
|
379 | - $request->params['action'] = str_replace($scaffoldPrefix . '_', '', $request->params['action']); |
|
378 | + if ( ! empty($prefixes)) { |
|
379 | + $request->params['action'] = str_replace($scaffoldPrefix.'_', '', $request->params['action']); |
|
380 | 380 | } |
381 | 381 | switch ($request->params['action']) { |
382 | 382 | case 'index': |
@@ -394,7 +394,7 @@ |
||
394 | 394 | * `App::core('Cache/Engine'); will return the full path to the cache engines package` |
395 | 395 | * |
396 | 396 | * @param string $type |
397 | - * @return array full path to package |
|
397 | + * @return string[] full path to package |
|
398 | 398 | * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::core |
399 | 399 | */ |
400 | 400 | public static function core($type) { |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::path |
218 | 218 | */ |
219 | 219 | public static function path($type, $plugin = null) { |
220 | - if (!empty(self::$legacy[$type])) { |
|
220 | + if ( ! empty(self::$legacy[$type])) { |
|
221 | 221 | $type = self::$legacy[$type]; |
222 | 222 | } |
223 | 223 | |
224 | - if (!empty($plugin)) { |
|
224 | + if ( ! empty($plugin)) { |
|
225 | 225 | $path = array(); |
226 | 226 | $pluginPath = self::pluginPath($plugin); |
227 | 227 | $packageFormat = self::_packageFormat(); |
228 | - if (!empty($packageFormat[$type])) { |
|
228 | + if ( ! empty($packageFormat[$type])) { |
|
229 | 229 | foreach ($packageFormat[$type] as $f) { |
230 | 230 | $path[] = sprintf($f, $pluginPath); |
231 | 231 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | return $path; |
234 | 234 | } |
235 | 235 | |
236 | - if (!isset(self::$_packages[$type])) { |
|
236 | + if ( ! isset(self::$_packages[$type])) { |
|
237 | 237 | return array(); |
238 | 238 | } |
239 | 239 | return self::$_packages[$type]; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | //Provides Backwards compatibility for old-style package names |
279 | 279 | $legacyPaths = array(); |
280 | 280 | foreach ($paths as $type => $path) { |
281 | - if (!empty(self::$legacy[$type])) { |
|
281 | + if ( ! empty(self::$legacy[$type])) { |
|
282 | 282 | $type = self::$legacy[$type]; |
283 | 283 | } |
284 | 284 | $legacyPaths[$type] = $path; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | if ($mode === App::RESET) { |
289 | 289 | foreach ($paths as $type => $new) { |
290 | - self::$_packages[$type] = (array)$new; |
|
290 | + self::$_packages[$type] = (array) $new; |
|
291 | 291 | self::objects($type, null, false); |
292 | 292 | } |
293 | 293 | return; |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | foreach ($defaults as $type => $default) { |
331 | - if (!empty(self::$_packages[$type])) { |
|
331 | + if ( ! empty(self::$_packages[$type])) { |
|
332 | 332 | $path = self::$_packages[$type]; |
333 | 333 | } else { |
334 | 334 | $path = $default; |
335 | 335 | } |
336 | 336 | |
337 | - if (!empty($paths[$type])) { |
|
338 | - $newPath = (array)$paths[$type]; |
|
337 | + if ( ! empty($paths[$type])) { |
|
338 | + $newPath = (array) $paths[$type]; |
|
339 | 339 | |
340 | 340 | if ($mode === App::PREPEND) { |
341 | 341 | $path = array_merge($newPath, $path); |
@@ -377,13 +377,13 @@ discard block |
||
377 | 377 | * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::themePath |
378 | 378 | */ |
379 | 379 | public static function themePath($theme) { |
380 | - $themeDir = 'Themed' . DS . Inflector::camelize($theme); |
|
380 | + $themeDir = 'Themed'.DS.Inflector::camelize($theme); |
|
381 | 381 | foreach (self::$_packages['View'] as $path) { |
382 | - if (is_dir($path . $themeDir)) { |
|
383 | - return $path . $themeDir . DS; |
|
382 | + if (is_dir($path.$themeDir)) { |
|
383 | + return $path.$themeDir.DS; |
|
384 | 384 | } |
385 | 385 | } |
386 | - return self::$_packages['View'][0] . $themeDir . DS; |
|
386 | + return self::$_packages['View'][0].$themeDir.DS; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::core |
399 | 399 | */ |
400 | 400 | public static function core($type) { |
401 | - return array(CAKE . str_replace('/', DS, $type) . DS); |
|
401 | + return array(CAKE.str_replace('/', DS, $type).DS); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | */ |
427 | 427 | public static function objects($type, $path = null, $cache = true) { |
428 | 428 | if (empty(self::$_objects) && $cache === true) { |
429 | - self::$_objects = (array)Cache::read('object_map', '_cake_core_'); |
|
429 | + self::$_objects = (array) Cache::read('object_map', '_cake_core_'); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $extension = '/\.php$/'; |
@@ -444,36 +444,36 @@ discard block |
||
444 | 444 | |
445 | 445 | list($plugin, $type) = pluginSplit($type); |
446 | 446 | |
447 | - if (isset(self::$legacy[$type . 's'])) { |
|
448 | - $type = self::$legacy[$type . 's']; |
|
447 | + if (isset(self::$legacy[$type.'s'])) { |
|
448 | + $type = self::$legacy[$type.'s']; |
|
449 | 449 | } |
450 | 450 | |
451 | - if ($type === 'file' && !$path) { |
|
451 | + if ($type === 'file' && ! $path) { |
|
452 | 452 | return false; |
453 | 453 | } elseif ($type === 'file') { |
454 | 454 | $extension = '/\.php$/'; |
455 | - $name = $type . str_replace(DS, '', $path); |
|
455 | + $name = $type.str_replace(DS, '', $path); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $cacheLocation = empty($plugin) ? 'app' : $plugin; |
459 | 459 | |
460 | - if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) { |
|
460 | + if ($cache !== true || ! isset(self::$_objects[$cacheLocation][$name])) { |
|
461 | 461 | $objects = array(); |
462 | 462 | |
463 | 463 | if (empty($path)) { |
464 | 464 | $path = self::path($type, $plugin); |
465 | 465 | } |
466 | 466 | |
467 | - foreach ((array)$path as $dir) { |
|
467 | + foreach ((array) $path as $dir) { |
|
468 | 468 | if ($dir != APP && is_dir($dir)) { |
469 | 469 | $files = new RegexIterator(new DirectoryIterator($dir), $extension); |
470 | 470 | foreach ($files as $file) { |
471 | 471 | $fileName = basename($file); |
472 | - if (!$file->isDot() && $fileName[0] !== '.') { |
|
472 | + if ( ! $file->isDot() && $fileName[0] !== '.') { |
|
473 | 473 | $isDir = $file->isDir(); |
474 | 474 | if ($isDir && $includeDirectories) { |
475 | 475 | $objects[] = $fileName; |
476 | - } elseif (!$includeDirectories && !$isDir) { |
|
476 | + } elseif ( ! $includeDirectories && ! $isDir) { |
|
477 | 477 | $objects[] = substr($fileName, 0, -4); |
478 | 478 | } |
479 | 479 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * @return boolean |
531 | 531 | */ |
532 | 532 | public static function load($className) { |
533 | - if (!isset(self::$_classMap[$className])) { |
|
533 | + if ( ! isset(self::$_classMap[$className])) { |
|
534 | 534 | return false; |
535 | 535 | } |
536 | 536 | if (strpos($className, '..') !== false) { |
@@ -548,18 +548,18 @@ discard block |
||
548 | 548 | |
549 | 549 | if (empty($plugin)) { |
550 | 550 | $appLibs = empty(self::$_packages['Lib']) ? APPLIBS : current(self::$_packages['Lib']); |
551 | - $paths[] = $appLibs . $package . DS; |
|
552 | - $paths[] = APP . $package . DS; |
|
553 | - $paths[] = CAKE . $package . DS; |
|
551 | + $paths[] = $appLibs.$package.DS; |
|
552 | + $paths[] = APP.$package.DS; |
|
553 | + $paths[] = CAKE.$package.DS; |
|
554 | 554 | } else { |
555 | 555 | $pluginPath = self::pluginPath($plugin); |
556 | - $paths[] = $pluginPath . 'Lib' . DS . $package . DS; |
|
557 | - $paths[] = $pluginPath . $package . DS; |
|
556 | + $paths[] = $pluginPath.'Lib'.DS.$package.DS; |
|
557 | + $paths[] = $pluginPath.$package.DS; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $normalizedClassName = str_replace('\\', DS, $className); |
561 | 561 | foreach ($paths as $path) { |
562 | - $file = $path . $normalizedClassName . '.php'; |
|
562 | + $file = $path.$normalizedClassName.'.php'; |
|
563 | 563 | if (file_exists($file)) { |
564 | 564 | self::_map($file, $className, $plugin); |
565 | 565 | return include $file; |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::location |
578 | 578 | */ |
579 | 579 | public static function location($className) { |
580 | - if (!empty(self::$_classMap[$className])) { |
|
580 | + if ( ! empty(self::$_classMap[$className])) { |
|
581 | 581 | return self::$_classMap[$className]; |
582 | 582 | } |
583 | 583 | return null; |
@@ -612,13 +612,13 @@ discard block |
||
612 | 612 | extract($parent, EXTR_OVERWRITE); |
613 | 613 | } |
614 | 614 | |
615 | - if (!$name && !$file) { |
|
615 | + if ( ! $name && ! $file) { |
|
616 | 616 | return false; |
617 | 617 | } |
618 | 618 | |
619 | 619 | if (is_array($name)) { |
620 | 620 | foreach ($name as $class) { |
621 | - if (!App::import(compact('type', 'parent', 'search', 'file', 'return') + array('name' => $class))) { |
|
621 | + if ( ! App::import(compact('type', 'parent', 'search', 'file', 'return') + array('name' => $class))) { |
|
622 | 622 | return false; |
623 | 623 | } |
624 | 624 | } |
@@ -627,21 +627,21 @@ discard block |
||
627 | 627 | |
628 | 628 | $originalType = strtolower($type); |
629 | 629 | $specialPackage = in_array($originalType, array('file', 'vendor')); |
630 | - if (!$specialPackage && isset(self::$legacy[$originalType . 's'])) { |
|
631 | - $type = self::$legacy[$originalType . 's']; |
|
630 | + if ( ! $specialPackage && isset(self::$legacy[$originalType.'s'])) { |
|
631 | + $type = self::$legacy[$originalType.'s']; |
|
632 | 632 | } |
633 | 633 | list($plugin, $name) = pluginSplit($name); |
634 | - if (!empty($plugin)) { |
|
635 | - if (!CakePlugin::loaded($plugin)) { |
|
634 | + if ( ! empty($plugin)) { |
|
635 | + if ( ! CakePlugin::loaded($plugin)) { |
|
636 | 636 | return false; |
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | - if (!$specialPackage) { |
|
640 | + if ( ! $specialPackage) { |
|
641 | 641 | return self::_loadClass($name, $plugin, $type, $originalType, $parent); |
642 | 642 | } |
643 | 643 | |
644 | - if ($originalType === 'file' && !empty($file)) { |
|
644 | + if ($originalType === 'file' && ! empty($file)) { |
|
645 | 645 | return self::_loadFile($name, $plugin, $search, $file, $return); |
646 | 646 | } |
647 | 647 | |
@@ -680,14 +680,14 @@ discard block |
||
680 | 680 | } |
681 | 681 | App::uses($extends, $extendType); |
682 | 682 | if ($plugin && in_array($originalType, array('controller', 'model'))) { |
683 | - App::uses($plugin . $extends, $plugin . '.' . $type); |
|
683 | + App::uses($plugin.$extends, $plugin.'.'.$type); |
|
684 | 684 | } |
685 | 685 | } |
686 | 686 | if ($plugin) { |
687 | 687 | $plugin .= '.'; |
688 | 688 | } |
689 | 689 | $name = Inflector::camelize($name); |
690 | - App::uses($name, $plugin . $type); |
|
690 | + App::uses($name, $plugin.$type); |
|
691 | 691 | return class_exists($name); |
692 | 692 | } |
693 | 693 | |
@@ -705,11 +705,11 @@ discard block |
||
705 | 705 | $mapped = self::_mapped($name, $plugin); |
706 | 706 | if ($mapped) { |
707 | 707 | $file = $mapped; |
708 | - } elseif (!empty($search)) { |
|
708 | + } elseif ( ! empty($search)) { |
|
709 | 709 | foreach ($search as $path) { |
710 | 710 | $found = false; |
711 | - if (file_exists($path . $file)) { |
|
712 | - $file = $path . $file; |
|
711 | + if (file_exists($path.$file)) { |
|
712 | + $file = $path.$file; |
|
713 | 713 | $found = true; |
714 | 714 | break; |
715 | 715 | } |
@@ -718,13 +718,13 @@ discard block |
||
718 | 718 | } |
719 | 719 | } |
720 | 720 | } |
721 | - if (!empty($file) && file_exists($file)) { |
|
721 | + if ( ! empty($file) && file_exists($file)) { |
|
722 | 722 | self::_map($file, $name, $plugin); |
723 | 723 | $returnValue = include $file; |
724 | 724 | if ($return) { |
725 | 725 | return $returnValue; |
726 | 726 | } |
727 | - return (bool)$returnValue; |
|
727 | + return (bool) $returnValue; |
|
728 | 728 | } |
729 | 729 | return false; |
730 | 730 | } |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | */ |
741 | 741 | protected static function _loadVendor($name, $plugin, $file, $ext) { |
742 | 742 | if ($mapped = self::_mapped($name, $plugin)) { |
743 | - return (bool)include_once $mapped; |
|
743 | + return (bool) include_once $mapped; |
|
744 | 744 | } |
745 | 745 | $fileTries = array(); |
746 | 746 | $paths = ($plugin) ? App::path('vendors', $plugin) : App::path('vendors'); |
@@ -748,17 +748,17 @@ discard block |
||
748 | 748 | $ext = 'php'; |
749 | 749 | } |
750 | 750 | if (empty($file)) { |
751 | - $fileTries[] = $name . '.' . $ext; |
|
752 | - $fileTries[] = Inflector::underscore($name) . '.' . $ext; |
|
751 | + $fileTries[] = $name.'.'.$ext; |
|
752 | + $fileTries[] = Inflector::underscore($name).'.'.$ext; |
|
753 | 753 | } else { |
754 | 754 | $fileTries[] = $file; |
755 | 755 | } |
756 | 756 | |
757 | 757 | foreach ($fileTries as $file) { |
758 | 758 | foreach ($paths as $path) { |
759 | - if (file_exists($path . $file)) { |
|
760 | - self::_map($path . $file, $name, $plugin); |
|
761 | - return (bool)include $path . $file; |
|
759 | + if (file_exists($path.$file)) { |
|
760 | + self::_map($path.$file, $name, $plugin); |
|
761 | + return (bool) include $path.$file; |
|
762 | 762 | } |
763 | 763 | } |
764 | 764 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * @return void |
772 | 772 | */ |
773 | 773 | public static function init() { |
774 | - self::$_map += (array)Cache::read('file_map', '_cake_core_'); |
|
774 | + self::$_map += (array) Cache::read('file_map', '_cake_core_'); |
|
775 | 775 | register_shutdown_function(array('App', 'shutdown')); |
776 | 776 | } |
777 | 777 | |
@@ -786,15 +786,15 @@ discard block |
||
786 | 786 | protected static function _map($file, $name, $plugin = null) { |
787 | 787 | $key = $name; |
788 | 788 | if ($plugin) { |
789 | - $key = 'plugin.' . $name; |
|
789 | + $key = 'plugin.'.$name; |
|
790 | 790 | } |
791 | 791 | if ($plugin && empty(self::$_map[$name])) { |
792 | 792 | self::$_map[$key] = $file; |
793 | 793 | } |
794 | - if (!$plugin && empty(self::$_map['plugin.' . $name])) { |
|
794 | + if ( ! $plugin && empty(self::$_map['plugin.'.$name])) { |
|
795 | 795 | self::$_map[$key] = $file; |
796 | 796 | } |
797 | - if (!self::$bootstrapping) { |
|
797 | + if ( ! self::$bootstrapping) { |
|
798 | 798 | self::$_cacheChange = true; |
799 | 799 | } |
800 | 800 | } |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | protected static function _mapped($name, $plugin = null) { |
810 | 810 | $key = $name; |
811 | 811 | if ($plugin) { |
812 | - $key = 'plugin.' . $name; |
|
812 | + $key = 'plugin.'.$name; |
|
813 | 813 | } |
814 | 814 | return isset(self::$_map[$key]) ? self::$_map[$key] : false; |
815 | 815 | } |
@@ -823,60 +823,60 @@ discard block |
||
823 | 823 | if (empty(self::$_packageFormat)) { |
824 | 824 | self::$_packageFormat = array( |
825 | 825 | 'Model' => array( |
826 | - '%s' . 'Model' . DS |
|
826 | + '%s'.'Model'.DS |
|
827 | 827 | ), |
828 | 828 | 'Model/Behavior' => array( |
829 | - '%s' . 'Model' . DS . 'Behavior' . DS |
|
829 | + '%s'.'Model'.DS.'Behavior'.DS |
|
830 | 830 | ), |
831 | 831 | 'Model/Datasource' => array( |
832 | - '%s' . 'Model' . DS . 'Datasource' . DS |
|
832 | + '%s'.'Model'.DS.'Datasource'.DS |
|
833 | 833 | ), |
834 | 834 | 'Model/Datasource/Database' => array( |
835 | - '%s' . 'Model' . DS . 'Datasource' . DS . 'Database' . DS |
|
835 | + '%s'.'Model'.DS.'Datasource'.DS.'Database'.DS |
|
836 | 836 | ), |
837 | 837 | 'Model/Datasource/Session' => array( |
838 | - '%s' . 'Model' . DS . 'Datasource' . DS . 'Session' . DS |
|
838 | + '%s'.'Model'.DS.'Datasource'.DS.'Session'.DS |
|
839 | 839 | ), |
840 | 840 | 'Controller' => array( |
841 | - '%s' . 'Controller' . DS |
|
841 | + '%s'.'Controller'.DS |
|
842 | 842 | ), |
843 | 843 | 'Controller/Component' => array( |
844 | - '%s' . 'Controller' . DS . 'Component' . DS |
|
844 | + '%s'.'Controller'.DS.'Component'.DS |
|
845 | 845 | ), |
846 | 846 | 'Controller/Component/Auth' => array( |
847 | - '%s' . 'Controller' . DS . 'Component' . DS . 'Auth' . DS |
|
847 | + '%s'.'Controller'.DS.'Component'.DS.'Auth'.DS |
|
848 | 848 | ), |
849 | 849 | 'Controller/Component/Acl' => array( |
850 | - '%s' . 'Controller' . DS . 'Component' . DS . 'Acl' . DS |
|
850 | + '%s'.'Controller'.DS.'Component'.DS.'Acl'.DS |
|
851 | 851 | ), |
852 | 852 | 'View' => array( |
853 | - '%s' . 'View' . DS |
|
853 | + '%s'.'View'.DS |
|
854 | 854 | ), |
855 | 855 | 'View/Helper' => array( |
856 | - '%s' . 'View' . DS . 'Helper' . DS |
|
856 | + '%s'.'View'.DS.'Helper'.DS |
|
857 | 857 | ), |
858 | 858 | 'Console' => array( |
859 | - '%s' . 'Console' . DS |
|
859 | + '%s'.'Console'.DS |
|
860 | 860 | ), |
861 | 861 | 'Console/Command' => array( |
862 | - '%s' . 'Console' . DS . 'Command' . DS |
|
862 | + '%s'.'Console'.DS.'Command'.DS |
|
863 | 863 | ), |
864 | 864 | 'Console/Command/Task' => array( |
865 | - '%s' . 'Console' . DS . 'Command' . DS . 'Task' . DS |
|
865 | + '%s'.'Console'.DS.'Command'.DS.'Task'.DS |
|
866 | 866 | ), |
867 | 867 | 'Lib' => array( |
868 | - '%s' . 'Lib' . DS |
|
868 | + '%s'.'Lib'.DS |
|
869 | 869 | ), |
870 | 870 | 'Locale' => array( |
871 | - '%s' . 'Locale' . DS |
|
871 | + '%s'.'Locale'.DS |
|
872 | 872 | ), |
873 | 873 | 'Vendor' => array( |
874 | - '%s' . 'Vendor' . DS, |
|
875 | - dirname(dirname(CAKE)) . DS . 'vendors' . DS, |
|
874 | + '%s'.'Vendor'.DS, |
|
875 | + dirname(dirname(CAKE)).DS.'vendors'.DS, |
|
876 | 876 | ), |
877 | 877 | 'Plugin' => array( |
878 | - APP . 'Plugin' . DS, |
|
879 | - dirname(dirname(CAKE)) . DS . 'plugins' . DS |
|
878 | + APP.'Plugin'.DS, |
|
879 | + dirname(dirname(CAKE)).DS.'plugins'.DS |
|
880 | 880 | ) |
881 | 881 | ); |
882 | 882 | } |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | */ |
910 | 910 | protected static function _checkFatalError() { |
911 | 911 | $lastError = error_get_last(); |
912 | - if (!is_array($lastError)) { |
|
912 | + if ( ! is_array($lastError)) { |
|
913 | 913 | return; |
914 | 914 | } |
915 | 915 | |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | } else { |
924 | 924 | $errorHandler = Configure::read('Error.handler'); |
925 | 925 | } |
926 | - if (!is_callable($errorHandler)) { |
|
926 | + if ( ! is_callable($errorHandler)) { |
|
927 | 927 | return; |
928 | 928 | } |
929 | 929 | call_user_func($errorHandler, $lastError['type'], $lastError['message'], $lastError['file'], $lastError['line'], array()); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param string $key name of configuration resource to load. |
288 | 288 | * @param string $config Name of the configured reader to use to read the resource identified by $key. |
289 | 289 | * @param boolean $merge if config files should be merged instead of simply overridden |
290 | - * @return mixed false if file not found, void if load successful. |
|
290 | + * @return boolean false if file not found, void if load successful. |
|
291 | 291 | * @throws ConfigureException Will throw any exceptions the reader raises. |
292 | 292 | */ |
293 | 293 | public static function load($key, $config = 'default', $merge = true) { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @param string $key The identifier to create in the config adapter. |
330 | 330 | * This could be a filename or a cache key depending on the adapter being used. |
331 | 331 | * @param string $config The name of the configured adapter to dump data with. |
332 | - * @param array $keys The name of the top-level keys you want to dump. |
|
332 | + * @param string[] $keys The name of the top-level keys you want to dump. |
|
333 | 333 | * This allows you save only some data stored in Configure. |
334 | 334 | * @return boolean success |
335 | 335 | * @throws ConfigureException if the adapter does not implement a `dump` method. |
@@ -425,12 +425,12 @@ |
||
425 | 425 | return true; |
426 | 426 | } |
427 | 427 | /** |
428 | - * Set the error and exception handlers. |
|
429 | - * |
|
430 | - * @param array $error The Error handling configuration. |
|
431 | - * @param array $exception The exception handling configuration. |
|
432 | - * @return void |
|
433 | - */ |
|
428 | + * Set the error and exception handlers. |
|
429 | + * |
|
430 | + * @param array $error The Error handling configuration. |
|
431 | + * @param array $exception The exception handling configuration. |
|
432 | + * @return void |
|
433 | + */ |
|
434 | 434 | protected static function _setErrorHandlers($error, $exception) { |
435 | 435 | $level = -1; |
436 | 436 | if (isset($error['level'])) { |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | if ($boot) { |
70 | 70 | self::_appDefaults(); |
71 | 71 | |
72 | - if (!include APP . 'Config' . DS . 'core.php') { |
|
72 | + if ( ! include APP.'Config'.DS.'core.php') { |
|
73 | 73 | trigger_error(__d('cake_dev', |
74 | 74 | "Can't find application core file. Please create %s, and make sure it is readable by PHP.", |
75 | - APP . 'Config' . DS . 'core.php'), |
|
75 | + APP.'Config'.DS.'core.php'), |
|
76 | 76 | E_USER_ERROR |
77 | 77 | ); |
78 | 78 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | ); |
90 | 90 | self::_setErrorHandlers($error, $exception); |
91 | 91 | |
92 | - if (!include APP . 'Config' . DS . 'bootstrap.php') { |
|
92 | + if ( ! include APP.'Config'.DS.'bootstrap.php') { |
|
93 | 93 | trigger_error(__d('cake_dev', |
94 | 94 | "Can't find application bootstrap file. Please create %s, and make sure it is readable by PHP.", |
95 | - APP . 'Config' . DS . 'bootstrap.php'), |
|
95 | + APP.'Config'.DS.'bootstrap.php'), |
|
96 | 96 | E_USER_ERROR |
97 | 97 | ); |
98 | 98 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return void |
117 | 117 | */ |
118 | 118 | protected static function _appDefaults() { |
119 | - self::write('App', (array)self::read('App') + array( |
|
119 | + self::write('App', (array) self::read('App') + array( |
|
120 | 120 | 'base' => false, |
121 | 121 | 'baseUrl' => false, |
122 | 122 | 'dir' => APP_DIR, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return boolean True if write was successful |
151 | 151 | */ |
152 | 152 | public static function write($config, $value = null) { |
153 | - if (!is_array($config)) { |
|
153 | + if ( ! is_array($config)) { |
|
154 | 154 | $config = array($config => $value); |
155 | 155 | } |
156 | 156 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @return boolean Success |
259 | 259 | */ |
260 | 260 | public static function drop($name) { |
261 | - if (!isset(self::$_readers[$name])) { |
|
261 | + if ( ! isset(self::$_readers[$name])) { |
|
262 | 262 | return false; |
263 | 263 | } |
264 | 264 | unset(self::$_readers[$name]); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public static function load($key, $config = 'default', $merge = true) { |
294 | 294 | $reader = self::_getReader($config); |
295 | - if (!$reader) { |
|
295 | + if ( ! $reader) { |
|
296 | 296 | return false; |
297 | 297 | } |
298 | 298 | $values = $reader->read($key); |
@@ -336,17 +336,17 @@ discard block |
||
336 | 336 | */ |
337 | 337 | public static function dump($key, $config = 'default', $keys = array()) { |
338 | 338 | $reader = self::_getReader($config); |
339 | - if (!$reader) { |
|
339 | + if ( ! $reader) { |
|
340 | 340 | throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config)); |
341 | 341 | } |
342 | - if (!method_exists($reader, 'dump')) { |
|
342 | + if ( ! method_exists($reader, 'dump')) { |
|
343 | 343 | throw new ConfigureException(__d('cake_dev', 'The "%s" adapter, does not have a %s method.', $config, 'dump()')); |
344 | 344 | } |
345 | 345 | $values = self::$_values; |
346 | - if (!empty($keys) && is_array($keys)) { |
|
346 | + if ( ! empty($keys) && is_array($keys)) { |
|
347 | 347 | $values = array_intersect_key($values, array_flip($keys)); |
348 | 348 | } |
349 | - return (bool)$reader->dump($key, $values); |
|
349 | + return (bool) $reader->dump($key, $values); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @return mixed Reader instance or false |
358 | 358 | */ |
359 | 359 | protected static function _getReader($config) { |
360 | - if (!isset(self::$_readers[$config])) { |
|
360 | + if ( ! isset(self::$_readers[$config])) { |
|
361 | 361 | if ($config !== 'default') { |
362 | 362 | return false; |
363 | 363 | } |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | * @return string Current version of CakePHP |
376 | 376 | */ |
377 | 377 | public static function version() { |
378 | - if (!isset(self::$_values['Cake']['version'])) { |
|
379 | - require CAKE . 'Config' . DS . 'config.php'; |
|
378 | + if ( ! isset(self::$_values['Cake']['version'])) { |
|
379 | + require CAKE.'Config'.DS.'config.php'; |
|
380 | 380 | self::write($config); |
381 | 381 | } |
382 | 382 | return self::$_values['Cake']['version']; |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | error_reporting($error['level']); |
438 | 438 | $level = $error['level']; |
439 | 439 | } |
440 | - if (!empty($error['handler'])) { |
|
440 | + if ( ! empty($error['handler'])) { |
|
441 | 441 | set_error_handler($error['handler'], $level); |
442 | 442 | } |
443 | - if (!empty($exception['handler'])) { |
|
443 | + if ( ! empty($exception['handler'])) { |
|
444 | 444 | set_exception_handler($exception['handler']); |
445 | 445 | } |
446 | 446 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * POST and GET data can be simulated in requestAction. Use `$extra['url']` for |
62 | 62 | * GET data. The `$extra['data']` parameter allows POST data simulation. |
63 | 63 | * |
64 | - * @param string|array $url String or array-based URL. Unlike other URL arrays in CakePHP, this |
|
64 | + * @param string $url String or array-based URL. Unlike other URL arrays in CakePHP, this |
|
65 | 65 | * URL will not automatically handle passed and named arguments in the $url parameter. |
66 | 66 | * @param array $extra if array includes the key "return" it sets the AutoRender to true. Can |
67 | 67 | * also be used to submit GET/POST data, and named/passed arguments. |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * Stop execution of the current script. Wraps exit() making |
140 | 140 | * testing easier. |
141 | 141 | * |
142 | - * @param integer|string $status see http://php.net/exit for values |
|
142 | + * @param integer $status see http://php.net/exit for values |
|
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | protected function _stop($status = 0) { |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
|
4 | - * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
5 | - * |
|
6 | - * Licensed under The MIT License |
|
7 | - * For full copyright and license information, please see the LICENSE.txt |
|
8 | - * Redistributions of files must retain the above copyright notice. |
|
9 | - * |
|
10 | - * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
11 | - * @link http://cakephp.org CakePHP(tm) Project |
|
12 | - * @package Cake.Core |
|
13 | - * @since CakePHP(tm) v 0.2.9 |
|
14 | - * @license http://www.opensource.org/licenses/mit-license.php MIT License |
|
15 | - */ |
|
3 | + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
|
4 | + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
5 | + * |
|
6 | + * Licensed under The MIT License |
|
7 | + * For full copyright and license information, please see the LICENSE.txt |
|
8 | + * Redistributions of files must retain the above copyright notice. |
|
9 | + * |
|
10 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
11 | + * @link http://cakephp.org CakePHP(tm) Project |
|
12 | + * @package Cake.Core |
|
13 | + * @since CakePHP(tm) v 0.2.9 |
|
14 | + * @license http://www.opensource.org/licenses/mit-license.php MIT License |
|
15 | + */ |
|
16 | 16 | |
17 | 17 | App::uses('CakeLog', 'Log'); |
18 | 18 | App::uses('Dispatcher', 'Routing'); |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | unset($extra[$index]); |
79 | 79 | } |
80 | 80 | $arrayUrl = is_array($url); |
81 | - if ($arrayUrl && !isset($extra['url'])) { |
|
81 | + if ($arrayUrl && ! isset($extra['url'])) { |
|
82 | 82 | $extra['url'] = array(); |
83 | 83 | } |
84 | - if ($arrayUrl && !isset($extra['data'])) { |
|
84 | + if ($arrayUrl && ! isset($extra['data'])) { |
|
85 | 85 | $extra['data'] = array(); |
86 | 86 | } |
87 | 87 | $extra = array_merge(array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return boolean Success of log write |
158 | 158 | */ |
159 | 159 | public function log($msg, $type = LOG_ERR, $scope = null) { |
160 | - if (!is_string($msg)) { |
|
160 | + if ( ! is_string($msg)) { |
|
161 | 161 | $msg = print_r($msg, true); |
162 | 162 | } |
163 | 163 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return void |
173 | 173 | */ |
174 | 174 | protected function _set($properties = array()) { |
175 | - if (is_array($properties) && !empty($properties)) { |
|
175 | + if (is_array($properties) && ! empty($properties)) { |
|
176 | 176 | $vars = get_object_vars($this); |
177 | 177 | foreach ($properties as $key => $val) { |
178 | 178 | if (array_key_exists($key, $vars)) { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | foreach ($properties as $var) { |
200 | 200 | if ( |
201 | 201 | isset($classProperties[$var]) && |
202 | - !empty($classProperties[$var]) && |
|
202 | + ! empty($classProperties[$var]) && |
|
203 | 203 | is_array($this->{$var}) && |
204 | 204 | $this->{$var} != $classProperties[$var] |
205 | 205 | ) { |
@@ -122,7 +122,7 @@ |
||
122 | 122 | * @param string $plural Plural string (if any) |
123 | 123 | * @param string $domain Domain The domain of the translation. Domains are often used by plugin translations. |
124 | 124 | * If null, the default domain will be used. |
125 | - * @param string $category Category The integer value of the category to use. |
|
125 | + * @param integer $category Category The integer value of the category to use. |
|
126 | 126 | * @param integer $count Count Count is used with $plural to choose the correct plural form. |
127 | 127 | * @param string $language Language to translate string to. |
128 | 128 | * If null it checks for language in session followed by Config.language configuration variable. |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public static function getInstance() { |
110 | 110 | static $instance = array(); |
111 | - if (!$instance) { |
|
111 | + if ( ! $instance) { |
|
112 | 112 | $instance[0] = new I18n(); |
113 | 113 | } |
114 | 114 | return $instance[0]; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - if (($_this->_lang && $_this->_lang !== $language) || !$_this->_lang) { |
|
155 | + if (($_this->_lang && $_this->_lang !== $language) || ! $_this->_lang) { |
|
156 | 156 | $lang = $_this->l10n->get($language); |
157 | 157 | $_this->_lang = $lang; |
158 | 158 | } |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | throw new CakeException(__d('cake_dev', 'You cannot use "" as a domain.')); |
165 | 165 | } |
166 | 166 | |
167 | - $_this->domain = $domain . '_' . $_this->l10n->lang; |
|
167 | + $_this->domain = $domain.'_'.$_this->l10n->lang; |
|
168 | 168 | |
169 | - if (!isset($_this->_domains[$domain][$_this->_lang])) { |
|
169 | + if ( ! isset($_this->_domains[$domain][$_this->_lang])) { |
|
170 | 170 | $_this->_domains[$domain][$_this->_lang] = Cache::read($_this->domain, '_cake_core_'); |
171 | 171 | } |
172 | 172 | |
173 | - if (!isset($_this->_domains[$domain][$_this->_lang][$_this->category])) { |
|
173 | + if ( ! isset($_this->_domains[$domain][$_this->_lang][$_this->category])) { |
|
174 | 174 | $_this->_bindTextDomain($domain); |
175 | 175 | Cache::write($_this->domain, $_this->_domains[$domain][$_this->_lang], '_cake_core_'); |
176 | 176 | } |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | return $_this->_translateTime($singular, $domain); |
180 | 180 | } |
181 | 181 | |
182 | - if (!isset($count)) { |
|
182 | + if ( ! isset($count)) { |
|
183 | 183 | $plurals = 0; |
184 | - } elseif (!empty($_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"]) && $_this->_noLocale === false) { |
|
184 | + } elseif ( ! empty($_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"]) && $_this->_noLocale === false) { |
|
185 | 185 | $header = $_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"]; |
186 | 186 | $plurals = $_this->_pluralGuess($header, $count); |
187 | 187 | } else { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if (!empty($_this->_domains[$domain][$_this->_lang][$_this->category][$singular])) { |
|
195 | + if ( ! empty($_this->_domains[$domain][$_this->_lang][$_this->category][$singular])) { |
|
196 | 196 | if (($trans = $_this->_domains[$domain][$_this->_lang][$_this->category][$singular]) || ($plurals) && ($trans = $_this->_domains[$domain][$_this->_lang][$_this->category][$plural])) { |
197 | 197 | if (is_array($trans)) { |
198 | 198 | if (isset($trans[$plurals])) { |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } else { |
201 | 201 | trigger_error( |
202 | 202 | __d('cake_dev', |
203 | - 'Missing plural form translation for "%s" in "%s" domain, "%s" locale. ' . |
|
203 | + 'Missing plural form translation for "%s" in "%s" domain, "%s" locale. '. |
|
204 | 204 | ' Check your po file for correct plurals and valid Plural-Forms header.', |
205 | 205 | $singular, |
206 | 206 | $domain, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - if (!empty($plurals)) { |
|
220 | + if ( ! empty($plurals)) { |
|
221 | 221 | return $plural; |
222 | 222 | } |
223 | 223 | return $singular; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return integer plural match |
252 | 252 | */ |
253 | 253 | protected function _pluralGuess($header, $n) { |
254 | - if (!is_string($header) || $header === "nplurals=1;plural=0;" || !isset($header[0])) { |
|
254 | + if ( ! is_string($header) || $header === "nplurals=1;plural=0;" || ! isset($header[0])) { |
|
255 | 255 | return 0; |
256 | 256 | } |
257 | 257 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | $searchPaths = App::path('locales'); |
306 | 306 | $plugins = CakePlugin::loaded(); |
307 | 307 | |
308 | - if (!empty($plugins)) { |
|
308 | + if ( ! empty($plugins)) { |
|
309 | 309 | foreach ($plugins as $plugin) { |
310 | 310 | $pluginDomain = Inflector::underscore($plugin); |
311 | 311 | if ($pluginDomain === $domain) { |
312 | - $searchPaths[] = CakePlugin::path($plugin) . 'Locale' . DS; |
|
312 | + $searchPaths[] = CakePlugin::path($plugin).'Locale'.DS; |
|
313 | 313 | $searchPaths = array_reverse($searchPaths); |
314 | 314 | break; |
315 | 315 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | |
319 | 319 | foreach ($searchPaths as $directory) { |
320 | 320 | foreach ($this->l10n->languagePath as $lang) { |
321 | - $localeDef = $directory . $lang . DS . $this->category; |
|
321 | + $localeDef = $directory.$lang.DS.$this->category; |
|
322 | 322 | if (is_file($localeDef)) { |
323 | 323 | $definitions = self::loadLocaleDefinition($localeDef); |
324 | 324 | if ($definitions !== false) { |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | if ($core) { |
332 | - $app = $directory . $lang . DS . $this->category . DS . 'core'; |
|
332 | + $app = $directory.$lang.DS.$this->category.DS.'core'; |
|
333 | 333 | $translations = false; |
334 | 334 | |
335 | - if (is_file($app . '.mo')) { |
|
336 | - $translations = self::loadMo($app . '.mo'); |
|
335 | + if (is_file($app.'.mo')) { |
|
336 | + $translations = self::loadMo($app.'.mo'); |
|
337 | 337 | } |
338 | - if ($translations === false && is_file($app . '.po')) { |
|
339 | - $translations = self::loadPo($app . '.po'); |
|
338 | + if ($translations === false && is_file($app.'.po')) { |
|
339 | + $translations = self::loadPo($app.'.po'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | if ($translations !== false) { |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | - $file = $directory . $lang . DS . $this->category . DS . $domain; |
|
350 | + $file = $directory.$lang.DS.$this->category.DS.$domain; |
|
351 | 351 | $translations = false; |
352 | 352 | |
353 | - if (is_file($file . '.mo')) { |
|
354 | - $translations = self::loadMo($file . '.mo'); |
|
353 | + if (is_file($file.'.mo')) { |
|
354 | + $translations = self::loadMo($file.'.mo'); |
|
355 | 355 | } |
356 | - if ($translations === false && is_file($file . '.po')) { |
|
357 | - $translations = self::loadPo($file . '.po'); |
|
356 | + if ($translations === false && is_file($file.'.po')) { |
|
357 | + $translations = self::loadPo($file.'.po'); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | if ($translations !== false) { |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $header = unpack('L1magic/L1version/L1count/L1o_msg/L1o_trn', $header); |
412 | 412 | extract($header); |
413 | 413 | |
414 | - if ((dechex($magic) === '950412de' || dechex($magic) === 'ffffffff950412de') && !$version) { |
|
414 | + if ((dechex($magic) === '950412de' || dechex($magic) === 'ffffffff950412de') && ! $version) { |
|
415 | 415 | for ($n = 0; $n < $count; $n++) { |
416 | 416 | $r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8)); |
417 | 417 | $msgid = substr($data, $r["offs"], $r["len"]); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $translations[$msgid] = $msgstr; |
430 | 430 | |
431 | 431 | if (isset($msgid_plural)) { |
432 | - $translations[$msgid_plural] =& $translations[$msgid]; |
|
432 | + $translations[$msgid_plural] = & $translations[$msgid]; |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | * @return mixed Array of translations on success or false on failure |
447 | 447 | */ |
448 | 448 | public static function loadPo($filename) { |
449 | - if (!$file = fopen($filename, 'r')) { |
|
449 | + if ( ! $file = fopen($filename, 'r')) { |
|
450 | 450 | return false; |
451 | 451 | } |
452 | 452 | |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | $type = 7; |
493 | 493 | } elseif (preg_match("/^\"(.*)\"$/i", $line, $regs) && $type == 7 && $translationKey) { |
494 | 494 | $translations[$translationKey][$plural] .= stripcslashes($regs[1]); |
495 | - } elseif (preg_match("/msgstr[[:space:]]+\"(.+)\"$/i", $line, $regs) && $type == 2 && !$translationKey) { |
|
495 | + } elseif (preg_match("/msgstr[[:space:]]+\"(.+)\"$/i", $line, $regs) && $type == 2 && ! $translationKey) { |
|
496 | 496 | $header .= stripcslashes($regs[1]); |
497 | 497 | $type = 5; |
498 | - } elseif (preg_match("/msgstr[[:space:]]+\"\"$/i", $line, $regs) && !$translationKey) { |
|
498 | + } elseif (preg_match("/msgstr[[:space:]]+\"\"$/i", $line, $regs) && ! $translationKey) { |
|
499 | 499 | $header = ''; |
500 | 500 | $type = 5; |
501 | 501 | } elseif (preg_match("/^\"(.*)\"$/i", $line, $regs) && $type == 5) { |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | $translationKey = ''; |
507 | 507 | $plural = 0; |
508 | 508 | } |
509 | - } while (!feof($file)); |
|
509 | + } while ( ! feof($file)); |
|
510 | 510 | fclose($file); |
511 | 511 | |
512 | 512 | $merge[''] = $header; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return mixed Array of definitions on success or false on failure |
521 | 521 | */ |
522 | 522 | public static function loadLocaleDefinition($filename) { |
523 | - if (!$file = fopen($filename, 'r')) { |
|
523 | + if ( ! $file = fopen($filename, 'r')) { |
|
524 | 524 | return false; |
525 | 525 | } |
526 | 526 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | $currentToken = $parts[0]; |
550 | 550 | $value = $parts[1]; |
551 | 551 | } elseif ($count === 1) { |
552 | - $value = is_array($value) ? $parts[0] : $value . $parts[0]; |
|
552 | + $value = is_array($value) ? $parts[0] : $value.$parts[0]; |
|
553 | 553 | } else { |
554 | 554 | continue; |
555 | 555 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | continue; |
561 | 561 | } |
562 | 562 | |
563 | - $mustEscape = array($escape . ',', $escape . ';', $escape . '<', $escape . '>', $escape . $escape); |
|
563 | + $mustEscape = array($escape.',', $escape.';', $escape.'<', $escape.'>', $escape.$escape); |
|
564 | 564 | $replacements = array_map('crc32', $mustEscape); |
565 | 565 | $value = str_replace($mustEscape, $replacements, $value); |
566 | 566 | $value = explode(';', $value); |
@@ -589,12 +589,12 @@ discard block |
||
589 | 589 | */ |
590 | 590 | protected function _parseLiteralValue($string) { |
591 | 591 | $string = $string[1]; |
592 | - if (substr($string, 0, 2) === $this->_escape . 'x') { |
|
593 | - $delimiter = $this->_escape . 'x'; |
|
592 | + if (substr($string, 0, 2) === $this->_escape.'x') { |
|
593 | + $delimiter = $this->_escape.'x'; |
|
594 | 594 | return implode('', array_map('chr', array_map('hexdec', array_filter(explode($delimiter, $string))))); |
595 | 595 | } |
596 | - if (substr($string, 0, 2) === $this->_escape . 'd') { |
|
597 | - $delimiter = $this->_escape . 'd'; |
|
596 | + if (substr($string, 0, 2) === $this->_escape.'d') { |
|
597 | + $delimiter = $this->_escape.'d'; |
|
598 | 598 | return implode('', array_map('chr', array_filter(explode($delimiter, $string)))); |
599 | 599 | } |
600 | 600 | if ($string[0] === $this->_escape && isset($string[1]) && is_numeric($string[1])) { |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @return mixed translated format string if only value or array of translated strings for corresponding format. |
620 | 620 | */ |
621 | 621 | protected function _translateTime($format, $domain) { |
622 | - if (!empty($this->_domains[$domain][$this->_lang]['LC_TIME'][$format])) { |
|
622 | + if ( ! empty($this->_domains[$domain][$this->_lang]['LC_TIME'][$format])) { |
|
623 | 623 | if (($trans = $this->_domains[$domain][$this->_lang][$this->category][$format])) { |
624 | 624 | return $trans; |
625 | 625 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * the method will get the settings from L10n::_setLanguage(); |
345 | 345 | * |
346 | 346 | * @param string $language Language (if null will use DEFAULT_LANGUAGE if defined) |
347 | - * @return mixed |
|
347 | + * @return string|null |
|
348 | 348 | */ |
349 | 349 | public function get($language = null) { |
350 | 350 | if ($language !== null) { |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * If $language is null it will use the L10n::$default if defined |
363 | 363 | * |
364 | 364 | * @param string $language Language (if null will use L10n::$default if defined) |
365 | - * @return mixed |
|
365 | + * @return string|null |
|
366 | 366 | */ |
367 | 367 | protected function _setLanguage($language = null) { |
368 | 368 | $catalog = false; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | return $this->_setLanguage($language); |
352 | 352 | } |
353 | 353 | |
354 | - if (!$this->_autoLanguage()) { |
|
354 | + if ( ! $this->_autoLanguage()) { |
|
355 | 355 | $this->_setLanguage(); |
356 | 356 | } |
357 | 357 | return $this->lang; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $catalog = $this->catalog($language); |
371 | 371 | } |
372 | 372 | |
373 | - if (!$catalog && $this->default) { |
|
373 | + if ( ! $catalog && $this->default) { |
|
374 | 374 | $language = $this->default; |
375 | 375 | $catalog = $this->catalog($language); |
376 | 376 | } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | if ($this->default && $language !== $this->default) { |
394 | 394 | $catalog = $this->catalog($this->default); |
395 | 395 | $fallback = $catalog['localeFallback']; |
396 | - if (!in_array($fallback, $this->languagePath)) { |
|
396 | + if ( ! in_array($fallback, $this->languagePath)) { |
|
397 | 397 | $this->languagePath[] = $fallback; |
398 | 398 | } |
399 | 399 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. |
136 | 136 | * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, |
137 | 137 | * Default value is false. |
138 | - * @return integer|boolean The portion of $haystack, or false if $needle is not found. |
|
138 | + * @return string|false The portion of $haystack, or false if $needle is not found. |
|
139 | 139 | */ |
140 | 140 | public static function stristr($haystack, $needle, $part = false) { |
141 | 141 | $php = (PHP_VERSION < 5.3); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. |
254 | 254 | * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, |
255 | 255 | * Default value is false. |
256 | - * @return string|boolean The portion of $haystack. or false if $needle is not found. |
|
256 | + * @return string|false The portion of $haystack. or false if $needle is not found. |
|
257 | 257 | */ |
258 | 258 | public static function strrchr($haystack, $needle, $part = false) { |
259 | 259 | $check = Multibyte::utf8($haystack); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. |
314 | 314 | * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, |
315 | 315 | * Default value is false. |
316 | - * @return string|boolean The portion of $haystack. or false if $needle is not found. |
|
316 | + * @return string|false The portion of $haystack. or false if $needle is not found. |
|
317 | 317 | */ |
318 | 318 | public static function strrichr($haystack, $needle, $part = false) { |
319 | 319 | $check = Multibyte::strtoupper($haystack); |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. |
476 | 476 | * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, |
477 | 477 | * Default value is FALSE. |
478 | - * @return string|boolean The portion of $haystack, or true if $needle is not found. |
|
478 | + * @return string|false The portion of $haystack, or true if $needle is not found. |
|
479 | 479 | */ |
480 | 480 | public static function strstr($haystack, $needle, $part = false) { |
481 | 481 | $php = (PHP_VERSION < 5.3); |
@@ -166,22 +166,22 @@ discard block |
||
166 | 166 | $found = true; |
167 | 167 | } |
168 | 168 | } |
169 | - if (!$found) { |
|
169 | + if ( ! $found) { |
|
170 | 170 | $parts[] = $haystack[$position]; |
171 | 171 | unset($haystack[$position]); |
172 | 172 | } |
173 | 173 | $position++; |
174 | 174 | } |
175 | 175 | |
176 | - if ($found && $part && !empty($parts)) { |
|
176 | + if ($found && $part && ! empty($parts)) { |
|
177 | 177 | return Multibyte::ascii($parts); |
178 | - } elseif ($found && !empty($haystack)) { |
|
178 | + } elseif ($found && ! empty($haystack)) { |
|
179 | 179 | return Multibyte::ascii($haystack); |
180 | 180 | } |
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - if (!$php) { |
|
184 | + if ( ! $php) { |
|
185 | 185 | return stristr($haystack, $needle, $part); |
186 | 186 | } |
187 | 187 | return stristr($haystack, $needle); |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | - if (!$found && isset($haystack[$position])) { |
|
292 | + if ( ! $found && isset($haystack[$position])) { |
|
293 | 293 | $parts[] = $haystack[$position]; |
294 | 294 | unset($haystack[$position]); |
295 | 295 | } |
296 | 296 | $position++; |
297 | 297 | } |
298 | 298 | |
299 | - if ($found && $part && !empty($parts)) { |
|
299 | + if ($found && $part && ! empty($parts)) { |
|
300 | 300 | return Multibyte::ascii($parts); |
301 | - } elseif ($found && !empty($haystack)) { |
|
301 | + } elseif ($found && ! empty($haystack)) { |
|
302 | 302 | return Multibyte::ascii($haystack); |
303 | 303 | } |
304 | 304 | return false; |
@@ -351,16 +351,16 @@ discard block |
||
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | - if (!$found && isset($haystack[$position])) { |
|
354 | + if ( ! $found && isset($haystack[$position])) { |
|
355 | 355 | $parts[] = $haystack[$position]; |
356 | 356 | unset($haystack[$position]); |
357 | 357 | } |
358 | 358 | $position++; |
359 | 359 | } |
360 | 360 | |
361 | - if ($found && $part && !empty($parts)) { |
|
361 | + if ($found && $part && ! empty($parts)) { |
|
362 | 362 | return Multibyte::ascii($parts); |
363 | - } elseif ($found && !empty($haystack)) { |
|
363 | + } elseif ($found && ! empty($haystack)) { |
|
364 | 364 | return Multibyte::ascii($haystack); |
365 | 365 | } |
366 | 366 | return false; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
405 | + if ( ! $offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
406 | 406 | $matches[$needle[0]] = $matches[$needle[0]] - 1; |
407 | 407 | } elseif ($i === $needleCount) { |
408 | 408 | $found = true; |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
455 | - if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
455 | + if ( ! $offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { |
|
456 | 456 | $matches[$needle[0]] = $matches[$needle[0]] - 1; |
457 | 457 | } elseif ($i === $needleCount) { |
458 | 458 | $found = true; |
@@ -504,22 +504,22 @@ discard block |
||
504 | 504 | $found = true; |
505 | 505 | } |
506 | 506 | } |
507 | - if (!$found) { |
|
507 | + if ( ! $found) { |
|
508 | 508 | $parts[] = $haystack[$position]; |
509 | 509 | unset($haystack[$position]); |
510 | 510 | } |
511 | 511 | $position++; |
512 | 512 | } |
513 | 513 | |
514 | - if ($found && $part && !empty($parts)) { |
|
514 | + if ($found && $part && ! empty($parts)) { |
|
515 | 515 | return Multibyte::ascii($parts); |
516 | - } elseif ($found && !empty($haystack)) { |
|
516 | + } elseif ($found && ! empty($haystack)) { |
|
517 | 517 | return Multibyte::ascii($haystack); |
518 | 518 | } |
519 | 519 | return false; |
520 | 520 | } |
521 | 521 | |
522 | - if (!$php) { |
|
522 | + if ( ! $php) { |
|
523 | 523 | return strstr($haystack, $needle, $part); |
524 | 524 | } |
525 | 525 | return strstr($haystack, $needle); |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | $matched = false; |
553 | 553 | $keys = self::_find($char, 'upper'); |
554 | 554 | |
555 | - if (!empty($keys)) { |
|
555 | + if ( ! empty($keys)) { |
|
556 | 556 | foreach ($keys as $key => $value) { |
557 | 557 | if ($keys[$key]['upper'] == $char && count($keys[$key]['lower'][0]) === 1) { |
558 | 558 | $lowerCase[] = $keys[$key]['lower'][0]; |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | $keys = self::_find($char); |
600 | 600 | $keyCount = count($keys); |
601 | 601 | |
602 | - if (!empty($keys)) { |
|
602 | + if ( ! empty($keys)) { |
|
603 | 603 | foreach ($keys as $key => $value) { |
604 | 604 | $matched = false; |
605 | 605 | $replace = 0; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | } |
651 | 651 | } |
652 | 652 | } |
653 | - if ($matched === false && !in_array($char, $replaced, true)) { |
|
653 | + if ($matched === false && ! in_array($char, $replaced, true)) { |
|
654 | 654 | $upperCase[] = $char; |
655 | 655 | } |
656 | 656 | } |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * @return string |
733 | 733 | */ |
734 | 734 | public static function mimeEncode($string, $charset = null, $newline = "\r\n") { |
735 | - if (!Multibyte::checkMultibyte($string) && strlen($string) < 75) { |
|
735 | + if ( ! Multibyte::checkMultibyte($string) && strlen($string) < 75) { |
|
736 | 736 | return $string; |
737 | 737 | } |
738 | 738 | |
@@ -741,9 +741,9 @@ discard block |
||
741 | 741 | } |
742 | 742 | $charset = strtoupper($charset); |
743 | 743 | |
744 | - $start = '=?' . $charset . '?B?'; |
|
744 | + $start = '=?'.$charset.'?B?'; |
|
745 | 745 | $end = '?='; |
746 | - $spacer = $end . $newline . ' ' . $start; |
|
746 | + $spacer = $end.$newline.' '.$start; |
|
747 | 747 | |
748 | 748 | $length = 75 - strlen($start) - strlen($end); |
749 | 749 | $length = $length - ($length % 4); |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | $maxchars = floor(($length * 3) / 4); |
753 | 753 | $stringLength = strlen($string); |
754 | 754 | while ($stringLength > $maxchars) { |
755 | - $i = (int)$maxchars; |
|
755 | + $i = (int) $maxchars; |
|
756 | 756 | $test = ord($string[$i]); |
757 | 757 | while ($test >= 128 && $test <= 191) { |
758 | 758 | $i--; |
@@ -766,9 +766,9 @@ discard block |
||
766 | 766 | $string = implode($spacer, $parts); |
767 | 767 | } else { |
768 | 768 | $string = chunk_split(base64_encode($string), $length, $spacer); |
769 | - $string = preg_replace('/' . preg_quote($spacer) . '$/', '', $string); |
|
769 | + $string = preg_replace('/'.preg_quote($spacer).'$/', '', $string); |
|
770 | 770 | } |
771 | - return $start . $string . $end; |
|
771 | + return $start.$string.$end; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
@@ -828,21 +828,21 @@ discard block |
||
828 | 828 | */ |
829 | 829 | protected static function _find($char, $type = 'lower') { |
830 | 830 | $found = array(); |
831 | - if (!isset(self::$_codeRange[$char])) { |
|
831 | + if ( ! isset(self::$_codeRange[$char])) { |
|
832 | 832 | $range = self::_codepoint($char); |
833 | 833 | if ($range === false) { |
834 | 834 | return null; |
835 | 835 | } |
836 | - if (!Configure::configured('_cake_core_')) { |
|
836 | + if ( ! Configure::configured('_cake_core_')) { |
|
837 | 837 | App::uses('PhpReader', 'Configure'); |
838 | - Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS)); |
|
838 | + Configure::config('_cake_core_', new PhpReader(CAKE.'Config'.DS)); |
|
839 | 839 | } |
840 | - Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); |
|
840 | + Configure::load('unicode'.DS.'casefolding'.DS.$range, '_cake_core_'); |
|
841 | 841 | self::$_caseFold[$range] = Configure::read($range); |
842 | 842 | Configure::delete($range); |
843 | 843 | } |
844 | 844 | |
845 | - if (!self::$_codeRange[$char]) { |
|
845 | + if ( ! self::$_codeRange[$char]) { |
|
846 | 846 | return null; |
847 | 847 | } |
848 | 848 | self::$_table = self::$_codeRange[$char]; |