Browse Source

Removing setters for prperties in EagerLoadable, fixing indentation

Also removed a parameter in a function that is not used anymore
Jose Lorenzo Rodriguez 11 years ago
parent
commit
6f46952aa8
3 changed files with 19 additions and 48 deletions
  1. 12 40
      src/ORM/EagerLoadable.php
  2. 5 6
      src/ORM/EagerLoader.php
  3. 2 2
      tests/TestCase/ORM/QueryRegressionTest.php

+ 12 - 40
src/ORM/EagerLoadable.php

@@ -137,56 +137,35 @@ class EagerLoadable
     }
 
     /**
-     * Sets the Association class instance to use for loading the records.
+     * Gets the Association class instance to use for loading the records.
      *
-     * If called with no arguments it returns the current
-     * value.
-     *
-     * @param \Cake\ORM\Association|null $instance The value to set.
      * @return \Cake\ORM\Association|null
      */
-    public function instance($instance = null)
+    public function instance()
     {
-        if ($instance === null) {
-            return $this->_instance;
-        }
-        $this->_instance = $instance;
+        return $this->_instance;
     }
 
     /**
-     * Sets a dotted separated string representing the path of associations
+     * Gets a dotted separated string representing the path of associations
      * that should be followed to fetch this level.
      *
-     * If called with no arguments it returns the current
-     * value.
-     *
-     * @param string|null $path The value to set.
      * @return string|null
      */
-    public function aliasPath($path = null)
+    public function aliasPath()
     {
-        if ($path === null) {
-            return $this->_aliasPath;
-        }
-        $this->_aliasPath = $path;
+        return $this->_aliasPath;
     }
 
     /**
-     * Sets a dotted separated string representing the path of entity properties
+     * Gets a dotted separated string representing the path of entity properties
      * in which results for this level should be placed.
      *
-     * If called with no arguments it returns the current
-     * value.
-     *
-     * @param string|null $path The value to set.
      * @return string|null
      */
-    public function propertyPath($path = null)
+    public function propertyPath()
     {
-        if ($path === null) {
-            return $this->_propertyPath;
-        }
-        $this->_propertyPath = $path;
+        return $this->_propertyPath;
     }
 
     /**
@@ -225,21 +204,14 @@ class EagerLoadable
     }
 
     /**
-     * Sets weather or not this level was meant for a
+     * Gets weather or not this level was meant for a
      * "matching" fetch operation.
      *
-     * If called with no arguments it returns the current
-     * value.
-     *
-     * @param bool|null $matching The value to set.
      * @return bool|null
      */
-    public function forMatching($matching = null)
+    public function forMatching()
     {
-        if ($matching === null) {
-            return $this->_forMatching;
-        }
-        $this->_forMatching = $matching;
+        return $this->_forMatching;
     }
 
     /**

+ 5 - 6
src/ORM/EagerLoader.php

@@ -404,13 +404,13 @@ class EagerLoader
     protected function _fixStrategies()
     {
         foreach ($this->_aliasList as $aliases) {
-            foreach ($aliases as $alias => $configs) {
+            foreach ($aliases as $configs) {
                 if (count($configs) < 2) {
                     continue;
                 }
                 foreach ($configs as $loadable) {
                     if (strpos($loadable->aliasPath(), '.')) {
-                        $this->_correctStrategy($loadable, $alias);
+                        $this->_correctStrategy($loadable);
                     }
                 }
             }
@@ -421,11 +421,10 @@ class EagerLoader
      * Changes the association fetching strategy if required because of duplicate
      * under the same direct associations chain
      *
-     * @param \Cake\ORM\EagerLoader $loadable The association config
-     * @param string $alias the name of the association to evaluate
+     * @param \Cake\ORM\EagerLoadable $loadable The association config
      * @return void
      */
-    protected function _correctStrategy($loadable, $alias)
+    protected function _correctStrategy($loadable)
     {
         $config = $loadable->config();
         $currentStrategy = isset($config['strategy']) ?
@@ -465,7 +464,7 @@ class EagerLoader
             }
 
             if ($inMatching) {
-                $this->_correctStrategy($loadable, $table);
+                $this->_correctStrategy($loadable);
             }
 
             $loadable->canBeJoined(false);

+ 2 - 2
tests/TestCase/ORM/QueryRegressionTest.php

@@ -691,8 +691,8 @@ class QueryRegressionTest extends TestCase
             ->matching('Articles.Tags', function ($q) {
                 return $q->where(['Tags.id' => 2]);
             })
-                ->contain('Articles.Authors')
-                ->first();
+            ->contain('Articles.Authors')
+            ->first();
 
         $this->assertNotNull($result->article->author);
     }