@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param string $aro ARO The requesting object identifier. |
125 | 125 | * @param string $aco ACO The controlled object identifier. |
126 | 126 | * @param string $action Action (defaults to *) |
127 | - * @return boolean Success |
|
127 | + * @return boolean|null Success |
|
128 | 128 | */ |
129 | 129 | public function allow($aro, $aco, $action = "*") { |
130 | 130 | return $this->Aco->access($this->Aro->resolve($aro), $aco, $action, 'allow'); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string $aro ARO The requesting object identifier. |
137 | 137 | * @param string $aco ACO The controlled object identifier. |
138 | 138 | * @param string $action Action (defaults to *) |
139 | - * @return boolean Success |
|
139 | + * @return boolean|null Success |
|
140 | 140 | */ |
141 | 141 | public function deny($aro, $aco, $action = "*") { |
142 | 142 | return $this->Aco->access($this->Aro->resolve($aro), $aco, $action, 'deny'); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function __construct() { |
70 | 70 | $this->options = array( |
71 | 71 | 'policy' => self::DENY, |
72 | - 'config' => APP . 'Config' . DS . 'acl.php', |
|
72 | + 'config' => APP.'Config'.DS.'acl.php', |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | public function initialize(Component $Component) { |
83 | - if (!empty($Component->settings['adapter'])) { |
|
83 | + if ( ! empty($Component->settings['adapter'])) { |
|
84 | 84 | $this->options = array_merge($this->options, $Component->settings['adapter']); |
85 | 85 | } |
86 | 86 | |
87 | 87 | App::uses('PhpReader', 'Configure'); |
88 | - $Reader = new PhpReader(dirname($this->options['config']) . DS); |
|
88 | + $Reader = new PhpReader(dirname($this->options['config']).DS); |
|
89 | 89 | $config = $Reader->read(basename($this->options['config'])); |
90 | 90 | $this->build($config); |
91 | 91 | $Component->Aco = $this->Aco; |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | throw new AclException(__d('cake_dev', 'Neither "allow" nor "deny" rules were provided in configuration.')); |
109 | 109 | } |
110 | 110 | |
111 | - $rules['allow'] = !empty($config['rules']['allow']) ? $config['rules']['allow'] : array(); |
|
112 | - $rules['deny'] = !empty($config['rules']['deny']) ? $config['rules']['deny'] : array(); |
|
113 | - $roles = !empty($config['roles']) ? $config['roles'] : array(); |
|
114 | - $map = !empty($config['map']) ? $config['map'] : array(); |
|
115 | - $alias = !empty($config['alias']) ? $config['alias'] : array(); |
|
111 | + $rules['allow'] = ! empty($config['rules']['allow']) ? $config['rules']['allow'] : array(); |
|
112 | + $rules['deny'] = ! empty($config['rules']['deny']) ? $config['rules']['deny'] : array(); |
|
113 | + $roles = ! empty($config['roles']) ? $config['roles'] : array(); |
|
114 | + $map = ! empty($config['map']) ? $config['map'] : array(); |
|
115 | + $alias = ! empty($config['alias']) ? $config['alias'] : array(); |
|
116 | 116 | |
117 | 117 | $this->Aro = new PhpAro($roles, $map, $alias); |
118 | 118 | $this->Aco = new PhpAco($rules); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $prioritizedAros = $this->Aro->roles($aro); |
169 | 169 | |
170 | 170 | if ($action && $action !== "*") { |
171 | - $aco .= '/' . $action; |
|
171 | + $aco .= '/'.$action; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | $path = $this->Aco->path($aco); |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | |
180 | 180 | foreach ($path as $node) { |
181 | 181 | foreach ($prioritizedAros as $aros) { |
182 | - if (!empty($node['allow'])) { |
|
182 | + if ( ! empty($node['allow'])) { |
|
183 | 183 | $allow = $allow || count(array_intersect($node['allow'], $aros)); |
184 | 184 | } |
185 | 185 | |
186 | - if (!empty($node['deny'])) { |
|
187 | - $allow = $allow && !count(array_intersect($node['deny'], $aros)); |
|
186 | + if ( ! empty($node['deny'])) { |
|
187 | + $allow = $allow && ! count(array_intersect($node['deny'], $aros)); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $root = $this->_tree; |
245 | 245 | $stack = array(array($root, 0)); |
246 | 246 | |
247 | - while (!empty($stack)) { |
|
247 | + while ( ! empty($stack)) { |
|
248 | 248 | list($root, $level) = array_pop($stack); |
249 | 249 | |
250 | 250 | if (empty($path[$level])) { |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | foreach ($root as $node => $elements) { |
255 | - $pattern = '/^' . str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node) . '$/'; |
|
255 | + $pattern = '/^'.str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node).'$/'; |
|
256 | 256 | |
257 | 257 | if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) { |
258 | 258 | // merge allow/denies with $path of current level |
259 | 259 | foreach (array('allow', 'deny') as $policy) { |
260 | - if (!empty($elements[$policy])) { |
|
260 | + if ( ! empty($elements[$policy])) { |
|
261 | 261 | if (empty($path[$level][$policy])) { |
262 | 262 | $path[$level][$policy] = array(); |
263 | 263 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | // traverse |
269 | - if (!empty($elements['children']) && isset($aco[$level + 1])) { |
|
269 | + if ( ! empty($elements['children']) && isset($aco[$level + 1])) { |
|
270 | 270 | array_push($stack, array($elements['children'], $level + 1)); |
271 | 271 | } |
272 | 272 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $tree = &$root; |
293 | 293 | |
294 | 294 | foreach ($aco as $i => $node) { |
295 | - if (!isset($tree[$node])) { |
|
295 | + if ( ! isset($tree[$node])) { |
|
296 | 296 | $tree[$node] = array( |
297 | 297 | 'children' => array(), |
298 | 298 | ); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @param array $aliases |
413 | 413 | */ |
414 | 414 | public function __construct(array $aro = array(), array $map = array(), array $aliases = array()) { |
415 | - if (!empty($map)) { |
|
415 | + if ( ! empty($map)) { |
|
416 | 416 | $this->map = $map; |
417 | 417 | } |
418 | 418 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $aro = $this->resolve($aro); |
436 | 436 | $stack = array(array($aro, 0)); |
437 | 437 | |
438 | - while (!empty($stack)) { |
|
438 | + while ( ! empty($stack)) { |
|
439 | 439 | list($element, $depth) = array_pop($stack); |
440 | 440 | $aros[$depth][] = $element; |
441 | 441 | |
@@ -463,24 +463,24 @@ discard block |
||
463 | 463 | |
464 | 464 | if (is_array($aro)) { |
465 | 465 | if (isset($aro['model']) && isset($aro['foreign_key']) && $aro['model'] === $aroGroup) { |
466 | - $mapped = $aroGroup . '/' . $aro['foreign_key']; |
|
466 | + $mapped = $aroGroup.'/'.$aro['foreign_key']; |
|
467 | 467 | } elseif (isset($aro[$model][$field])) { |
468 | - $mapped = $aroGroup . '/' . $aro[$model][$field]; |
|
468 | + $mapped = $aroGroup.'/'.$aro[$model][$field]; |
|
469 | 469 | } elseif (isset($aro[$field])) { |
470 | - $mapped = $aroGroup . '/' . $aro[$field]; |
|
470 | + $mapped = $aroGroup.'/'.$aro[$field]; |
|
471 | 471 | } |
472 | 472 | } elseif (is_string($aro)) { |
473 | 473 | $aro = ltrim($aro, '/'); |
474 | 474 | |
475 | 475 | if (strpos($aro, '/') === false) { |
476 | - $mapped = $aroGroup . '/' . $aro; |
|
476 | + $mapped = $aroGroup.'/'.$aro; |
|
477 | 477 | } else { |
478 | 478 | list($aroModel, $aroValue) = explode('/', $aro, 2); |
479 | 479 | |
480 | 480 | $aroModel = Inflector::camelize($aroModel); |
481 | 481 | |
482 | 482 | if ($aroModel === $model || $aroModel === $aroGroup) { |
483 | - $mapped = $aroGroup . '/' . $aroValue; |
|
483 | + $mapped = $aroGroup.'/'.$aroValue; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | // is there a matching alias defined (e.g. Role/1 => Role/admin)? |
493 | - if (!empty($this->aliases[$mapped])) { |
|
493 | + if ( ! empty($this->aliases[$mapped])) { |
|
494 | 494 | return $this->aliases[$mapped]; |
495 | 495 | } |
496 | 496 | } |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public function addRole(array $aro) { |
507 | 507 | foreach ($aro as $role => $inheritedRoles) { |
508 | - if (!isset($this->_tree[$role])) { |
|
508 | + if ( ! isset($this->_tree[$role])) { |
|
509 | 509 | $this->_tree[$role] = array(); |
510 | 510 | } |
511 | 511 | |
512 | - if (!empty($inheritedRoles)) { |
|
512 | + if ( ! empty($inheritedRoles)) { |
|
513 | 513 | if (is_string($inheritedRoles)) { |
514 | 514 | $inheritedRoles = array_map('trim', explode(',', $inheritedRoles)); |
515 | 515 | } |
@@ -522,14 +522,14 @@ discard block |
||
522 | 522 | $path = ''; |
523 | 523 | |
524 | 524 | foreach ($roles as $roleDependencies) { |
525 | - $path .= implode('|', (array)$roleDependencies) . ' -> '; |
|
525 | + $path .= implode('|', (array) $roleDependencies).' -> '; |
|
526 | 526 | } |
527 | 527 | |
528 | - trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path . $role)); |
|
528 | + trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path.$role)); |
|
529 | 529 | continue; |
530 | 530 | } |
531 | 531 | |
532 | - if (!isset($this->_tree[$dependency])) { |
|
532 | + if ( ! isset($this->_tree[$dependency])) { |
|
533 | 533 | $this->_tree[$dependency] = array(); |
534 | 534 | } |
535 | 535 |
@@ -199,7 +199,7 @@ |
||
199 | 199 | * systems like basic and digest auth. |
200 | 200 | * |
201 | 201 | * @param CakeRequest $request Request object. |
202 | - * @return mixed Either false or an array of user information |
|
202 | + * @return boolean Either false or an array of user information |
|
203 | 203 | */ |
204 | 204 | public function getUser(CakeRequest $request) { |
205 | 205 | return false; |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | $conditions = $username; |
98 | 98 | } else { |
99 | 99 | $conditions = array( |
100 | - $model . '.' . $fields['username'] => $username |
|
100 | + $model.'.'.$fields['username'] => $username |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | - if (!empty($this->settings['scope'])) { |
|
104 | + if ( ! empty($this->settings['scope'])) { |
|
105 | 105 | $conditions = array_merge($conditions, $this->settings['scope']); |
106 | 106 | } |
107 | 107 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | $user = $result[$model]; |
119 | 119 | if ($password !== null) { |
120 | - if (!$this->passwordHasher()->check($password, $user[$fields['password']])) { |
|
120 | + if ( ! $this->passwordHasher()->check($password, $user[$fields['password']])) { |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | unset($user[$fields['password']]); |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | unset($config['className']); |
149 | 149 | } |
150 | 150 | list($plugin, $class) = pluginSplit($class, true); |
151 | - $className = $class . 'PasswordHasher'; |
|
152 | - App::uses($className, $plugin . 'Controller/Component/Auth'); |
|
153 | - if (!class_exists($className)) { |
|
151 | + $className = $class.'PasswordHasher'; |
|
152 | + App::uses($className, $plugin.'Controller/Component/Auth'); |
|
153 | + if ( ! class_exists($className)) { |
|
154 | 154 | throw new CakeException(__d('cake_dev', 'Password hasher class "%s" was not found.', $class)); |
155 | 155 | } |
156 | - if (!is_subclass_of($className, 'AbstractPasswordHasher')) { |
|
156 | + if ( ! is_subclass_of($className, 'AbstractPasswordHasher')) { |
|
157 | 157 | throw new CakeException(__d('cake_dev', 'Password hasher must extend AbstractPasswordHasher class.')); |
158 | 158 | } |
159 | 159 | $this->_passwordHasher = new $className($config); |
@@ -291,7 +291,6 @@ |
||
291 | 291 | /** |
292 | 292 | * Returns true if given variable is set in cookie. |
293 | 293 | * |
294 | - * @param string $var Variable name to check for |
|
295 | 294 | * @return boolean True if variable is there |
296 | 295 | */ |
297 | 296 | public function check($key = null) { |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $this->_encrypted = $encrypt; |
224 | 224 | $this->_expire($expires); |
225 | 225 | |
226 | - if (!is_array($key)) { |
|
226 | + if ( ! is_array($key)) { |
|
227 | 227 | $key = array($key => $value); |
228 | 228 | } |
229 | 229 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $firstName = $names[0]; |
236 | 236 | $isMultiValue = (is_array($value) || count($names) > 1); |
237 | 237 | |
238 | - if (!isset($this->_values[$this->name][$firstName]) && $isMultiValue) { |
|
238 | + if ( ! isset($this->_values[$this->name][$firstName]) && $isMultiValue) { |
|
239 | 239 | $this->_values[$this->name][$firstName] = array(); |
240 | 240 | } |
241 | 241 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } else { |
249 | 249 | $this->_values[$this->name][$firstName] = $value; |
250 | 250 | } |
251 | - $this->_write('[' . $firstName . ']', $this->_values[$this->name][$firstName]); |
|
251 | + $this->_write('['.$firstName.']', $this->_values[$this->name][$firstName]); |
|
252 | 252 | } |
253 | 253 | $this->_encrypted = true; |
254 | 254 | } |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | $names = explode('.', $key, 2); |
279 | 279 | $key = $names[0]; |
280 | 280 | } |
281 | - if (!isset($this->_values[$this->name][$key])) { |
|
281 | + if ( ! isset($this->_values[$this->name][$key])) { |
|
282 | 282 | return null; |
283 | 283 | } |
284 | 284 | |
285 | - if (!empty($names[1])) { |
|
285 | + if ( ! empty($names[1])) { |
|
286 | 286 | return Hash::get($this->_values[$this->name][$key], $names[1]); |
287 | 287 | } |
288 | 288 | return $this->_values[$this->name][$key]; |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | if (isset($this->_values[$this->name][$names[0]])) { |
339 | 339 | $this->_values[$this->name][$names[0]] = Hash::remove($this->_values[$this->name][$names[0]], $names[1]); |
340 | 340 | } |
341 | - $this->_delete('[' . implode('][', $names) . ']'); |
|
341 | + $this->_delete('['.implode('][', $names).']'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | 'cipher', |
381 | 381 | 'rijndael' |
382 | 382 | ); |
383 | - if (!in_array($type, $availableTypes)) { |
|
383 | + if ( ! in_array($type, $availableTypes)) { |
|
384 | 384 | trigger_error(__d('cake_dev', 'You must use cipher or rijndael for cookie encryption type'), E_USER_WARNING); |
385 | 385 | $type = 'cipher'; |
386 | 386 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | return $this->_expires; |
406 | 406 | } |
407 | 407 | $this->_reset = $this->_expires; |
408 | - if (!$expires) { |
|
408 | + if ( ! $expires) { |
|
409 | 409 | return $this->_expires = 0; |
410 | 410 | } |
411 | 411 | $now = new DateTime(); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | */ |
427 | 427 | protected function _write($name, $value) { |
428 | 428 | $this->_response->cookie(array( |
429 | - 'name' => $this->name . $name, |
|
429 | + 'name' => $this->name.$name, |
|
430 | 430 | 'value' => $this->_encrypt($value), |
431 | 431 | 'expire' => $this->_expires, |
432 | 432 | 'path' => $this->path, |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'httpOnly' => $this->httpOnly |
436 | 436 | )); |
437 | 437 | |
438 | - if (!empty($this->_reset)) { |
|
438 | + if ( ! empty($this->_reset)) { |
|
439 | 439 | $this->_expires = $this->_reset; |
440 | 440 | $this->_reset = null; |
441 | 441 | } |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | protected function _delete($name) { |
451 | 451 | $this->_response->cookie(array( |
452 | - 'name' => $this->name . $name, |
|
452 | + 'name' => $this->name.$name, |
|
453 | 453 | 'value' => '', |
454 | 454 | 'expire' => time() - 42000, |
455 | 455 | 'path' => $this->path, |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | |
473 | 473 | if ($this->_encrypted === true) { |
474 | 474 | $type = $this->_type; |
475 | - $value = "Q2FrZQ==." . base64_encode(Security::$type($value, $this->key, 'encrypt')); |
|
475 | + $value = "Q2FrZQ==.".base64_encode(Security::$type($value, $this->key, 'encrypt')); |
|
476 | 476 | } |
477 | 477 | return $value; |
478 | 478 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $decrypted = array(); |
488 | 488 | $type = $this->_type; |
489 | 489 | |
490 | - foreach ((array)$values as $name => $value) { |
|
490 | + foreach ((array) $values as $name => $value) { |
|
491 | 491 | if (is_array($value)) { |
492 | 492 | foreach ($value as $key => $val) { |
493 | 493 | $pos = strpos($val, 'Q2FrZQ==.'); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | $array = array(); |
538 | 538 | foreach (explode(',', $string) as $pair) { |
539 | 539 | $key = explode('|', $pair); |
540 | - if (!isset($key[1])) { |
|
540 | + if ( ! isset($key[1])) { |
|
541 | 541 | return $key[0]; |
542 | 542 | } |
543 | 543 | $array[$key[0]] = $key[1]; |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * Check if HTTP methods are required |
356 | 356 | * |
357 | 357 | * @param Controller $controller Instantiating controller |
358 | - * @return boolean true if $method is required |
|
358 | + * @return null|boolean true if $method is required |
|
359 | 359 | */ |
360 | 360 | protected function _methodsRequired(Controller $controller) { |
361 | 361 | foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * Check if access requires secure connection |
379 | 379 | * |
380 | 380 | * @param Controller $controller Instantiating controller |
381 | - * @return boolean true if secure connection required |
|
381 | + * @return null|boolean true if secure connection required |
|
382 | 382 | */ |
383 | 383 | protected function _secureRequired(Controller $controller) { |
384 | 384 | if (is_array($this->requireSecure) && !empty($this->requireSecure)) { |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * Check if authentication is required |
400 | 400 | * |
401 | 401 | * @param Controller $controller Instantiating controller |
402 | - * @return boolean true if authentication required |
|
402 | + * @return null|boolean true if authentication required |
|
403 | 403 | */ |
404 | 404 | protected function _authRequired(Controller $controller) { |
405 | 405 | if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) { |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @param Controller $controller Controller to run callback on |
612 | 612 | * @param string $method Method to execute |
613 | - * @param array $params Parameters to send to method |
|
613 | + * @param string[] $params Parameters to send to method |
|
614 | 614 | * @return mixed Controller callback method's response |
615 | 615 | * @throws BadRequestException When a the blackholeCallback is not callable. |
616 | 616 | */ |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | $isPost = $this->request->is(array('post', 'put')); |
228 | 228 | $isNotRequestAction = ( |
229 | - !isset($controller->request->params['requested']) || |
|
229 | + ! isset($controller->request->params['requested']) || |
|
230 | 230 | $controller->request->params['requested'] != 1 |
231 | 231 | ); |
232 | 232 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | return $this->blackHole($controller, 'auth'); |
235 | 235 | } |
236 | 236 | |
237 | - if (!in_array($this->_action, (array)$this->unlockedActions) && $isPost && $isNotRequestAction) { |
|
237 | + if ( ! in_array($this->_action, (array) $this->unlockedActions) && $isPost && $isNotRequestAction) { |
|
238 | 238 | if ($this->validatePost && $this->_validatePost($controller) === false) { |
239 | 239 | return $this->blackHole($controller, 'auth'); |
240 | 240 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @throws BadRequestException |
332 | 332 | */ |
333 | 333 | public function blackHole(Controller $controller, $error = '') { |
334 | - if (!$this->blackHoleCallback) { |
|
334 | + if ( ! $this->blackHoleCallback) { |
|
335 | 335 | throw new BadRequestException(__d('cake_dev', 'The request has been black-holed')); |
336 | 336 | } |
337 | 337 | return $this->_callback($controller, $this->blackHoleCallback, array($error)); |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | if (isset($actions[0]) && is_array($actions[0])) { |
349 | 349 | $actions = $actions[0]; |
350 | 350 | } |
351 | - $this->{'require' . $method} = (empty($actions)) ? array('*') : $actions; |
|
351 | + $this->{'require'.$method} = (empty($actions)) ? array('*') : $actions; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | */ |
360 | 360 | protected function _methodsRequired(Controller $controller) { |
361 | 361 | foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { |
362 | - $property = 'require' . $method; |
|
363 | - if (is_array($this->$property) && !empty($this->$property)) { |
|
362 | + $property = 'require'.$method; |
|
363 | + if (is_array($this->$property) && ! empty($this->$property)) { |
|
364 | 364 | $require = $this->$property; |
365 | 365 | if (in_array($this->_action, $require) || $this->$property === array('*')) { |
366 | - if (!$this->request->is($method)) { |
|
367 | - if (!$this->blackHole($controller, $method)) { |
|
366 | + if ( ! $this->request->is($method)) { |
|
367 | + if ( ! $this->blackHole($controller, $method)) { |
|
368 | 368 | return null; |
369 | 369 | } |
370 | 370 | } |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | * @return boolean true if secure connection required |
382 | 382 | */ |
383 | 383 | protected function _secureRequired(Controller $controller) { |
384 | - if (is_array($this->requireSecure) && !empty($this->requireSecure)) { |
|
384 | + if (is_array($this->requireSecure) && ! empty($this->requireSecure)) { |
|
385 | 385 | $requireSecure = $this->requireSecure; |
386 | 386 | |
387 | 387 | if (in_array($this->_action, $requireSecure) || $this->requireSecure === array('*')) { |
388 | - if (!$this->request->is('ssl')) { |
|
389 | - if (!$this->blackHole($controller, 'secure')) { |
|
388 | + if ( ! $this->request->is('ssl')) { |
|
389 | + if ( ! $this->blackHole($controller, 'secure')) { |
|
390 | 390 | return null; |
391 | 391 | } |
392 | 392 | } |
@@ -402,12 +402,12 @@ discard block |
||
402 | 402 | * @return boolean true if authentication required |
403 | 403 | */ |
404 | 404 | protected function _authRequired(Controller $controller) { |
405 | - if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) { |
|
405 | + if (is_array($this->requireAuth) && ! empty($this->requireAuth) && ! empty($this->request->data)) { |
|
406 | 406 | $requireAuth = $this->requireAuth; |
407 | 407 | |
408 | 408 | if (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth === array('*')) { |
409 | - if (!isset($controller->request->data['_Token'])) { |
|
410 | - if (!$this->blackHole($controller, 'auth')) { |
|
409 | + if ( ! isset($controller->request->data['_Token'])) { |
|
410 | + if ( ! $this->blackHole($controller, 'auth')) { |
|
411 | 411 | return null; |
412 | 412 | } |
413 | 413 | } |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | $tData = $this->Session->read('_Token'); |
417 | 417 | |
418 | 418 | if ( |
419 | - !empty($tData['allowedControllers']) && |
|
420 | - !in_array($this->request->params['controller'], $tData['allowedControllers']) || |
|
421 | - !empty($tData['allowedActions']) && |
|
422 | - !in_array($this->request->params['action'], $tData['allowedActions']) |
|
419 | + ! empty($tData['allowedControllers']) && |
|
420 | + ! in_array($this->request->params['controller'], $tData['allowedControllers']) || |
|
421 | + ! empty($tData['allowedActions']) && |
|
422 | + ! in_array($this->request->params['action'], $tData['allowedActions']) |
|
423 | 423 | ) { |
424 | - if (!$this->blackHole($controller, 'auth')) { |
|
424 | + if ( ! $this->blackHole($controller, 'auth')) { |
|
425 | 425 | return null; |
426 | 426 | } |
427 | 427 | } |
428 | 428 | } else { |
429 | - if (!$this->blackHole($controller, 'auth')) { |
|
429 | + if ( ! $this->blackHole($controller, 'auth')) { |
|
430 | 430 | return null; |
431 | 431 | } |
432 | 432 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | } |
448 | 448 | $data = $controller->request->data; |
449 | 449 | |
450 | - if (!isset($data['_Token']) || !isset($data['_Token']['fields']) || !isset($data['_Token']['unlocked'])) { |
|
450 | + if ( ! isset($data['_Token']) || ! isset($data['_Token']['fields']) || ! isset($data['_Token']['unlocked'])) { |
|
451 | 451 | return false; |
452 | 452 | } |
453 | 453 | |
@@ -475,18 +475,18 @@ discard block |
||
475 | 475 | unset($fieldList[$i]); |
476 | 476 | } |
477 | 477 | } |
478 | - if (!empty($multi)) { |
|
478 | + if ( ! empty($multi)) { |
|
479 | 479 | $fieldList += array_unique($multi); |
480 | 480 | } |
481 | 481 | |
482 | 482 | $unlockedFields = array_unique( |
483 | - array_merge((array)$this->disabledFields, (array)$this->unlockedFields, $unlocked) |
|
483 | + array_merge((array) $this->disabledFields, (array) $this->unlockedFields, $unlocked) |
|
484 | 484 | ); |
485 | 485 | |
486 | 486 | foreach ($fieldList as $i => $key) { |
487 | 487 | $isLocked = (is_array($locked) && in_array($key, $locked)); |
488 | 488 | |
489 | - if (!empty($unlockedFields)) { |
|
489 | + if ( ! empty($unlockedFields)) { |
|
490 | 490 | foreach ($unlockedFields as $off) { |
491 | 491 | $off = explode('.', $off); |
492 | 492 | $field = array_values(array_intersect(explode('.', $key), $off)); |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | $tokenData = array(); |
546 | 546 | if ($this->Session->check('_Token')) { |
547 | 547 | $tokenData = $this->Session->read('_Token'); |
548 | - if (!empty($tokenData['csrfTokens']) && is_array($tokenData['csrfTokens'])) { |
|
548 | + if ( ! empty($tokenData['csrfTokens']) && is_array($tokenData['csrfTokens'])) { |
|
549 | 549 | $token['csrfTokens'] = $this->_expireTokens($tokenData['csrfTokens']); |
550 | 550 | } |
551 | 551 | } |
552 | 552 | if ($this->csrfUseOnce || empty($token['csrfTokens'])) { |
553 | 553 | $token['csrfTokens'][$authKey] = strtotime($this->csrfExpires); |
554 | 554 | } |
555 | - if (!$this->csrfUseOnce) { |
|
555 | + if ( ! $this->csrfUseOnce) { |
|
556 | 556 | $csrfTokens = array_keys($token['csrfTokens']); |
557 | 557 | $token['key'] = $csrfTokens[0]; |
558 | 558 | } |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $requestToken = $controller->request->data('_Token.key'); |
578 | 578 | if (isset($token['csrfTokens'][$requestToken]) && $token['csrfTokens'][$requestToken] >= time()) { |
579 | 579 | if ($this->csrfUseOnce) { |
580 | - $this->Session->delete('_Token.csrfTokens.' . $requestToken); |
|
580 | + $this->Session->delete('_Token.csrfTokens.'.$requestToken); |
|
581 | 581 | } |
582 | 582 | return true; |
583 | 583 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @throws BadRequestException When a the blackholeCallback is not callable. |
616 | 616 | */ |
617 | 617 | protected function _callback(Controller $controller, $method, $params = array()) { |
618 | - if (!is_callable(array($controller, $method))) { |
|
618 | + if ( ! is_callable(array($controller, $method))) { |
|
619 | 619 | throw new BadRequestException(__d('cake_dev', 'The request has been black-holed')); |
620 | 620 | } |
621 | 621 | return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params); |
@@ -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) { |
@@ -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 | ) { |