@@ -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 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $db = $model->getDataSource(); |
| 114 | 114 | $value = $db->value($this->id); |
| 115 | - $name = $db->name('EagerLoaderModel' . '__' . 'id'); |
|
| 115 | + $name = $db->name('EagerLoaderModel'.'__'.'id'); |
|
| 116 | 116 | $query['fields'][] = "($value) AS $name"; |
| 117 | 117 | $query['callbacks'] = true; |
| 118 | 118 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $assocResults = array_merge($assocResults, $eachAssocResults); |
| 244 | 244 | } |
| 245 | 245 | } else { |
| 246 | - $options['fields'][] = '(' . $db->name($assocAlias . '.' . $assocKey) . ') AS ' . $db->name('EagerLoaderModel' . '__' . 'assoc_id'); |
|
| 246 | + $options['fields'][] = '('.$db->name($assocAlias.'.'.$assocKey).') AS '.$db->name('EagerLoaderModel'.'__'.'assoc_id'); |
|
| 247 | 247 | $options['conditions'][] = array("$assocAlias.$assocKey" => $ids); |
| 248 | 248 | $assocResults = $db->read($target, $options); |
| 249 | 249 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | foreach ($results as &$result) { |
| 263 | 263 | $assoc = array(); |
| 264 | 264 | foreach ($assocResults as $assocResult) { |
| 265 | - if ((string)$result[$parentAlias][$parentKey] === (string)$assocResult['EagerLoaderModel']['assoc_id']) { |
|
| 265 | + if ((string) $result[$parentAlias][$parentKey] === (string) $assocResult['EagerLoaderModel']['assoc_id']) { |
|
| 266 | 266 | $assoc[] = $assocResult[$alias]; |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -291,10 +291,10 @@ discard block |
||
| 291 | 291 | if ($result[$alias][$targetKey] === null) { |
| 292 | 292 | // Remove NULL association created by LEFT JOIN |
| 293 | 293 | if (empty($eager)) { |
| 294 | - $assocResults[$n] = array( $alias => array() ); |
|
| 294 | + $assocResults[$n] = array($alias => array()); |
|
| 295 | 295 | } |
| 296 | 296 | } else { |
| 297 | - $assocResults[$n] = array( $alias => $result[$alias] ); |
|
| 297 | + $assocResults[$n] = array($alias => $result[$alias]); |
|
| 298 | 298 | } |
| 299 | 299 | unset($result[$alias]); |
| 300 | 300 | } |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @return array |
| 326 | 326 | */ |
| 327 | 327 | private function mergeAssocResult(array $result, array $assoc, $propertyPath) { // @codingStandardsIgnoreLine |
| 328 | - return Hash::insert($result, $propertyPath, $assoc + (array)Hash::get($result, $propertyPath)); |
|
| 328 | + return Hash::insert($result, $propertyPath, $assoc + (array) Hash::get($result, $propertyPath)); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | 'contain' => array(), |
| 341 | 341 | ); |
| 342 | 342 | |
| 343 | - $contain = (array)$contain; |
|
| 343 | + $contain = (array) $contain; |
|
| 344 | 344 | foreach ($contain as $key => $val) { |
| 345 | 345 | if (is_int($key)) { |
| 346 | 346 | $key = $val; |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | $expanded = Hash::expand(array($key => $val)); |
| 353 | 353 | list($key, $val) = each($expanded); |
| 354 | 354 | } |
| 355 | - $ref =& $result['contain'][$key]; |
|
| 356 | - $ref = Hash::merge((array)$ref, $this->reformatContain($val)); |
|
| 355 | + $ref = & $result['contain'][$key]; |
|
| 356 | + $ref = Hash::merge((array) $ref, $this->reformatContain($val)); |
|
| 357 | 357 | } else { |
| 358 | 358 | $result['options'][$key] = $val; |
| 359 | 359 | } |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | $query['fields'] = $db->fields($model, null, array(), false); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - $query['fields'] = (array)$query['fields']; |
|
| 385 | + $query['fields'] = (array) $query['fields']; |
|
| 386 | 386 | foreach ($query['fields'] as &$field) { |
| 387 | 387 | if ($model->isVirtualField($field)) { |
| 388 | 388 | $fields = $db->fields($model, null, array($field), false); |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | unset($field); |
| 395 | 395 | |
| 396 | - $query['conditions'] = (array)$query['conditions']; |
|
| 396 | + $query['conditions'] = (array) $query['conditions']; |
|
| 397 | 397 | foreach ($query['conditions'] as $key => $val) { |
| 398 | 398 | if ($model->hasField($key)) { |
| 399 | 399 | unset($query['conditions'][$key]); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | $order = array(); |
| 410 | - foreach ((array)$query['order'] as $key => $val) { |
|
| 410 | + foreach ((array) $query['order'] as $key => $val) { |
|
| 411 | 411 | if (is_int($key)) { |
| 412 | 412 | $val = $this->normalizeField($model, $val); |
| 413 | 413 | } else { |
@@ -429,12 +429,12 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | private function normalizeField(Model $model, $field) { // @codingStandardsIgnoreLine |
| 431 | 431 | if ($model->hasField($field)) { |
| 432 | - $field = $model->alias . '.' . $field; |
|
| 432 | + $field = $model->alias.'.'.$field; |
|
| 433 | 433 | } elseif ($model->isVirtualField($field)) { |
| 434 | 434 | $db = $model->getDataSource(); |
| 435 | 435 | $field = $model->getVirtualField($field); |
| 436 | 436 | $field = $db->dispatchMethod('_quoteFields', array($field)); |
| 437 | - $field = '(' . $field . ')'; |
|
| 437 | + $field = '('.$field.')'; |
|
| 438 | 438 | } |
| 439 | 439 | return $field; |
| 440 | 440 | } |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | ); |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $aliasPath = $context['aliasPath'] . '.' . $alias; |
|
| 509 | - $propertyPath = ($context['propertyPath'] ? $context['propertyPath'] . '.' : '') . $alias; |
|
| 508 | + $aliasPath = $context['aliasPath'].'.'.$alias; |
|
| 509 | + $propertyPath = ($context['propertyPath'] ? $context['propertyPath'].'.' : '').$alias; |
|
| 510 | 510 | |
| 511 | 511 | $types = $parent->getAssociated(); |
| 512 | 512 | if (!isset($types[$alias])) { |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | ); |
| 557 | 557 | |
| 558 | 558 | if ($this->isExternal($context, $meta)) { |
| 559 | - $meta['propertyPath'] = ($context['propertyPath'] ? $parentAlias . '.' : '') . $alias; |
|
| 559 | + $meta['propertyPath'] = ($context['propertyPath'] ? $parentAlias.'.' : '').$alias; |
|
| 560 | 560 | $meta['external'] = true; |
| 561 | 561 | |
| 562 | 562 | $context['root'] = $aliasPath; |