@@ -9,7 +9,7 @@ |
||
9 | 9 | * |
10 | 10 | * @param Model $model Model |
11 | 11 | * @param array $query Query |
12 | - * @return mixed |
|
12 | + * @return boolean |
|
13 | 13 | */ |
14 | 14 | public function beforeFind(Model $model, $query) { |
15 | 15 | $db = $model->getDataSource(); |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | App::build(array( |
3 | - 'Model' => array(App::pluginPath('EagerLoader') . 'Test' . DS . 'test_app' . DS . 'Model' . DS), |
|
4 | - 'Model/Behavior' => array(App::pluginPath('EagerLoader') . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Behavior' . DS), |
|
3 | + 'Model' => array(App::pluginPath('EagerLoader').'Test'.DS.'test_app'.DS.'Model'.DS), |
|
4 | + 'Model/Behavior' => array(App::pluginPath('EagerLoader').'Test'.DS.'test_app'.DS.'Model'.DS.'Behavior'.DS), |
|
5 | 5 | ), true); |
6 | 6 | |
7 | 7 | App::uses('ConnectionManager', 'Model'); |
8 | 8 | ConnectionManager::create('test_external', array( |
9 | 9 | 'datasource' => 'Database/Sqlite', |
10 | - 'database' => TMP . 'tests' . DS . 'test_external.db', |
|
10 | + 'database' => TMP.'tests'.DS.'test_external.db', |
|
11 | 11 | ))->cacheSources = false; |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once App::pluginPath('EagerLoader') . 'Test' . DS . 'bootstrap.php'; |
|
2 | +require_once App::pluginPath('EagerLoader').'Test'.DS.'bootstrap.php'; |
|
3 | 3 | |
4 | 4 | class EagerLoaderBehaviorTest extends CakeTestCase { |
5 | 5 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once App::pluginPath('EagerLoader') . 'Test' . DS . 'bootstrap.php'; |
|
2 | +require_once App::pluginPath('EagerLoader').'Test'.DS.'bootstrap.php'; |
|
3 | 3 | |
4 | 4 | App::uses('EagerLoader', 'EagerLoader.Model'); |
5 | 5 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'alias' => 'User', |
192 | 192 | 'conditions' => array( |
193 | 193 | array('Article.user_id' => array(1, 2, 3)), |
194 | - array('Article.user_id' => (object)array('type' => 'identifier', 'value' => 'User.id')), |
|
194 | + array('Article.user_id' => (object) array('type' => 'identifier', 'value' => 'User.id')), |
|
195 | 195 | ), |
196 | 196 | ), |
197 | 197 | ), |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | '(CASE WHEN Category.parent_id = 0 THEN 1 ELSE 0 END) AS Category__is_root', |
792 | 792 | ), |
793 | 793 | 'conditions' => array( |
794 | - (object)array( |
|
794 | + (object) array( |
|
795 | 795 | 'type' => 'expression', |
796 | 796 | 'value' => '(CASE WHEN Category.parent_id = 0 THEN 1 ELSE 0 END) = 0', |
797 | 797 | ) |
@@ -830,8 +830,8 @@ discard block |
||
830 | 830 | 'target' => $target, |
831 | 831 | 'alias' => $target->alias, |
832 | 832 | 'parentAlias' => $parent->alias, |
833 | - 'aliasPath' => $parent->alias . '.' . $target->alias, |
|
834 | - 'propertyPath' => $parent->alias . '.' . $target->alias, |
|
833 | + 'aliasPath' => $parent->alias.'.'.$target->alias, |
|
834 | + 'propertyPath' => $parent->alias.'.'.$target->alias, |
|
835 | 835 | ); |
836 | 836 | |
837 | 837 | if (isset($meta['habtmAlias'])) { |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | public static function suite() { |
13 | 13 | $suite = new CakeTestSuite('All Tests'); |
14 | - $suite->addTestDirectoryRecursive(App::pluginPath('EagerLoader') . 'Test' . DS . 'Case' . DS); |
|
14 | + $suite->addTestDirectoryRecursive(App::pluginPath('EagerLoader').'Test'.DS.'Case'.DS); |
|
15 | 15 | return $suite; |
16 | 16 | } |
17 | 17 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | $class = get_class($db); |
79 | - $cache =& $class::$methodCache['fields']; |
|
79 | + $cache = & $class::$methodCache['fields']; |
|
80 | 80 | if (!is_array($cache) || count($cache) >= 1000) { |
81 | 81 | $cache = array(); |
82 | 82 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $db = $model->getDataSource(); |
126 | 126 | $value = $db->value($this->id); |
127 | - $name = $db->name('EagerLoaderModel' . '__' . 'id'); |
|
127 | + $name = $db->name('EagerLoaderModel'.'__'.'id'); |
|
128 | 128 | $query['fields'][] = "($value) AS $name"; |
129 | 129 | $query['callbacks'] = true; |
130 | 130 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $assocResults = array_merge($assocResults, $eachAssocResults); |
256 | 256 | } |
257 | 257 | } else { |
258 | - $options['fields'][] = '(' . $db->name($assocAlias . '.' . $assocKey) . ') AS ' . $db->name('EagerLoaderModel' . '__' . 'assoc_id'); |
|
258 | + $options['fields'][] = '('.$db->name($assocAlias.'.'.$assocKey).') AS '.$db->name('EagerLoaderModel'.'__'.'assoc_id'); |
|
259 | 259 | $options['conditions'][] = array("$assocAlias.$assocKey" => $ids); |
260 | 260 | $assocResults = $db->read($target, $options); |
261 | 261 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | $assoc = array(); |
280 | 280 | foreach ($assocResults as $assocResult) { |
281 | - if ((string)$result[$parentAlias][$parentKey] === (string)$assocResult['EagerLoaderModel']['assoc_id']) { |
|
281 | + if ((string) $result[$parentAlias][$parentKey] === (string) $assocResult['EagerLoaderModel']['assoc_id']) { |
|
282 | 282 | $assoc[] = $assocResult[$alias]; |
283 | 283 | } |
284 | 284 | } |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | if ($result[$alias][$targetKey] === null) { |
308 | 308 | // Remove NULL association created by LEFT JOIN |
309 | 309 | if (empty($eager)) { |
310 | - $assocResults[$n] = array( $alias => array() ); |
|
310 | + $assocResults[$n] = array($alias => array()); |
|
311 | 311 | } |
312 | 312 | } else { |
313 | - $assocResults[$n] = array( $alias => $result[$alias] ); |
|
313 | + $assocResults[$n] = array($alias => $result[$alias]); |
|
314 | 314 | } |
315 | 315 | unset($result[$alias]); |
316 | 316 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @return array |
342 | 342 | */ |
343 | 343 | private function mergeAssocResult(array $result, array $assoc, $propertyPath) { // @codingStandardsIgnoreLine |
344 | - return Hash::insert($result, $propertyPath, $assoc + (array)Hash::get($result, $propertyPath)); |
|
344 | + return Hash::insert($result, $propertyPath, $assoc + (array) Hash::get($result, $propertyPath)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | 'contain' => array(), |
357 | 357 | ); |
358 | 358 | |
359 | - $contain = (array)$contain; |
|
359 | + $contain = (array) $contain; |
|
360 | 360 | foreach ($contain as $key => $val) { |
361 | 361 | if (is_int($key)) { |
362 | 362 | $key = $val; |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | $expanded = Hash::expand(array($key => $val)); |
369 | 369 | list($key, $val) = each($expanded); |
370 | 370 | } |
371 | - $ref =& $result['contain'][$key]; |
|
372 | - $ref = Hash::merge((array)$ref, $this->reformatContain($val)); |
|
371 | + $ref = & $result['contain'][$key]; |
|
372 | + $ref = Hash::merge((array) $ref, $this->reformatContain($val)); |
|
373 | 373 | } else { |
374 | 374 | $result['options'][$key] = $val; |
375 | 375 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $query['fields'] = $db->fields($model, null, array(), false); |
399 | 399 | } |
400 | 400 | |
401 | - $query['fields'] = (array)$query['fields']; |
|
401 | + $query['fields'] = (array) $query['fields']; |
|
402 | 402 | foreach ($query['fields'] as &$field) { |
403 | 403 | if ($model->isVirtualField($field)) { |
404 | 404 | $fields = $db->fields($model, null, array($field), false); |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | } |
410 | 410 | unset($field); |
411 | 411 | |
412 | - $query['conditions'] = (array)$query['conditions']; |
|
412 | + $query['conditions'] = (array) $query['conditions']; |
|
413 | 413 | foreach ($query['conditions'] as $key => $val) { |
414 | 414 | if ($model->hasField($key)) { |
415 | 415 | unset($query['conditions'][$key]); |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | $order = array(); |
426 | - foreach ((array)$query['order'] as $key => $val) { |
|
426 | + foreach ((array) $query['order'] as $key => $val) { |
|
427 | 427 | if (is_int($key)) { |
428 | 428 | $val = $this->normalizeField($model, $val); |
429 | 429 | } else { |
@@ -445,12 +445,12 @@ discard block |
||
445 | 445 | */ |
446 | 446 | private function normalizeField(Model $model, $field) { // @codingStandardsIgnoreLine |
447 | 447 | if ($model->hasField($field)) { |
448 | - $field = $model->alias . '.' . $field; |
|
448 | + $field = $model->alias.'.'.$field; |
|
449 | 449 | } elseif ($model->isVirtualField($field)) { |
450 | 450 | $db = $model->getDataSource(); |
451 | 451 | $field = $model->getVirtualField($field); |
452 | 452 | $field = $db->dispatchMethod('_quoteFields', array($field)); |
453 | - $field = '(' . $field . ')'; |
|
453 | + $field = '('.$field.')'; |
|
454 | 454 | } |
455 | 455 | return $field; |
456 | 456 | } |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | ); |
522 | 522 | } |
523 | 523 | |
524 | - $aliasPath = $context['aliasPath'] . '.' . $alias; |
|
525 | - $propertyPath = ($context['propertyPath'] ? $context['propertyPath'] . '.' : '') . $alias; |
|
524 | + $aliasPath = $context['aliasPath'].'.'.$alias; |
|
525 | + $propertyPath = ($context['propertyPath'] ? $context['propertyPath'].'.' : '').$alias; |
|
526 | 526 | |
527 | 527 | $types = $parent->getAssociated(); |
528 | 528 | if (!isset($types[$alias])) { |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | ); |
573 | 573 | |
574 | 574 | if ($this->isExternal($context, $meta)) { |
575 | - $meta['propertyPath'] = ($context['propertyPath'] ? $parentAlias . '.' : '') . $alias; |
|
575 | + $meta['propertyPath'] = ($context['propertyPath'] ? $parentAlias.'.' : '').$alias; |
|
576 | 576 | $meta['external'] = true; |
577 | 577 | |
578 | 578 | $context['root'] = $aliasPath; |