Skip to content

Commit 6f46952

Browse files
committed
Removing setters for prperties in EagerLoadable, fixing indentation
Also removed a parameter in a function that is not used anymore
1 parent 0d511f2 commit 6f46952

File tree

3 files changed

+19
-48
lines changed

3 files changed

+19
-48
lines changed

src/ORM/EagerLoadable.php

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -137,56 +137,35 @@ public function associations()
137137
}
138138

139139
/**
140-
* Sets the Association class instance to use for loading the records.
140+
* Gets the Association class instance to use for loading the records.
141141
*
142-
* If called with no arguments it returns the current
143-
* value.
144-
*
145-
* @param \Cake\ORM\Association|null $instance The value to set.
146142
* @return \Cake\ORM\Association|null
147143
*/
148-
public function instance($instance = null)
144+
public function instance()
149145
{
150-
if ($instance === null) {
151-
return $this->_instance;
152-
}
153-
$this->_instance = $instance;
146+
return $this->_instance;
154147
}
155148

156149
/**
157-
* Sets a dotted separated string representing the path of associations
150+
* Gets a dotted separated string representing the path of associations
158151
* that should be followed to fetch this level.
159152
*
160-
* If called with no arguments it returns the current
161-
* value.
162-
*
163-
* @param string|null $path The value to set.
164153
* @return string|null
165154
*/
166-
public function aliasPath($path = null)
155+
public function aliasPath()
167156
{
168-
if ($path === null) {
169-
return $this->_aliasPath;
170-
}
171-
$this->_aliasPath = $path;
157+
return $this->_aliasPath;
172158
}
173159

174160
/**
175-
* Sets a dotted separated string representing the path of entity properties
161+
* Gets a dotted separated string representing the path of entity properties
176162
* in which results for this level should be placed.
177163
*
178-
* If called with no arguments it returns the current
179-
* value.
180-
*
181-
* @param string|null $path The value to set.
182164
* @return string|null
183165
*/
184-
public function propertyPath($path = null)
166+
public function propertyPath()
185167
{
186-
if ($path === null) {
187-
return $this->_propertyPath;
188-
}
189-
$this->_propertyPath = $path;
168+
return $this->_propertyPath;
190169
}
191170

192171
/**
@@ -225,21 +204,14 @@ public function config(array $config = null)
225204
}
226205

227206
/**
228-
* Sets weather or not this level was meant for a
207+
* Gets weather or not this level was meant for a
229208
* "matching" fetch operation.
230209
*
231-
* If called with no arguments it returns the current
232-
* value.
233-
*
234-
* @param bool|null $matching The value to set.
235210
* @return bool|null
236211
*/
237-
public function forMatching($matching = null)
212+
public function forMatching()
238213
{
239-
if ($matching === null) {
240-
return $this->_forMatching;
241-
}
242-
$this->_forMatching = $matching;
214+
return $this->_forMatching;
243215
}
244216

245217
/**

src/ORM/EagerLoader.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,13 @@ protected function _normalizeContain(Table $parent, $alias, $options, $paths)
404404
protected function _fixStrategies()
405405
{
406406
foreach ($this->_aliasList as $aliases) {
407-
foreach ($aliases as $alias => $configs) {
407+
foreach ($aliases as $configs) {
408408
if (count($configs) < 2) {
409409
continue;
410410
}
411411
foreach ($configs as $loadable) {
412412
if (strpos($loadable->aliasPath(), '.')) {
413-
$this->_correctStrategy($loadable, $alias);
413+
$this->_correctStrategy($loadable);
414414
}
415415
}
416416
}
@@ -421,11 +421,10 @@ protected function _fixStrategies()
421421
* Changes the association fetching strategy if required because of duplicate
422422
* under the same direct associations chain
423423
*
424-
* @param \Cake\ORM\EagerLoader $loadable The association config
425-
* @param string $alias the name of the association to evaluate
424+
* @param \Cake\ORM\EagerLoadable $loadable The association config
426425
* @return void
427426
*/
428-
protected function _correctStrategy($loadable, $alias)
427+
protected function _correctStrategy($loadable)
429428
{
430429
$config = $loadable->config();
431430
$currentStrategy = isset($config['strategy']) ?
@@ -465,7 +464,7 @@ protected function _resolveJoins($associations, $matching = [])
465464
}
466465

467466
if ($inMatching) {
468-
$this->_correctStrategy($loadable, $table);
467+
$this->_correctStrategy($loadable);
469468
}
470469

471470
$loadable->canBeJoined(false);

tests/TestCase/ORM/QueryRegressionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,8 @@ public function testFindMatchingOverwrite2()
691691
->matching('Articles.Tags', function ($q) {
692692
return $q->where(['Tags.id' => 2]);
693693
})
694-
->contain('Articles.Authors')
695-
->first();
694+
->contain('Articles.Authors')
695+
->first();
696696

697697
$this->assertNotNull($result->article->author);
698698
}

0 commit comments

Comments
 (0)