فهرست منبع

merged branch schmittjoh/sessionRename (PR #1705)

Commits
-------

5e80c68 fixes a naming inconsistency
8cfca15 added change to upgrade file
4123ec4 updated some missing references

Discussion
----------

Fix inconsistent naming

---------------------------------------------------------------------------

by jalliot at 2011/07/15 08:15:01 -0700

I think you forgot one commit (the one effectively changing Session and that you reverted in the main repo)

---------------------------------------------------------------------------

by schmittjoh at 2011/07/15 09:07:17 -0700

You're right, fixed now.
Fabien Potencier 14 سال پیش
والد
کامیت
8e1f420e12

+ 5 - 0
UPDATE.md

@@ -71,6 +71,11 @@ RC4 to RC5
 * To avoid hidden naming collisions, the AbstractType does not try to define
   the name of form types magically. You now need to implement the `getName()`
   method explicitly when creating a custom type.
+  
+* Renamed some methods to follow the naming conventions:
+
+    Session::getAttributes() -> Session::all()
+    Session::setAttributes() -> Session::replace()
 
 RC3 to RC4
 ----------

+ 2 - 2
src/Symfony/Component/HttpFoundation/Session.php

@@ -117,7 +117,7 @@ class Session implements \Serializable
      *
      * @return array Attributes
      */
-    public function getAttributes()
+    public function all()
     {
         return $this->attributes;
     }
@@ -127,7 +127,7 @@ class Session implements \Serializable
      *
      * @param array $attributes Attributes
      */
-    public function setAttributes(array $attributes)
+    public function replace(array $attributes)
     {
         if (false === $this->started) {
             $this->start();

+ 1 - 1
src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

@@ -64,7 +64,7 @@ class RequestDataCollector extends DataCollector
             'request_cookies'    => $request->cookies->all(),
             'request_attributes' => $attributes,
             'response_headers'   => $responseHeaders,
-            'session_attributes' => $request->hasSession() ? $request->getSession()->getAttributes() : array(),
+            'session_attributes' => $request->hasSession() ? $request->getSession()->all() : array(),
         );
     }
 

+ 6 - 6
tests/Symfony/Tests/Component/HttpFoundation/SessionTest.php

@@ -74,7 +74,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->session->hasFlash('foo'));
     }
 
-    public function testAttribute()
+    public function testAll()
     {
         $this->assertFalse($this->session->has('foo'));
         $this->assertNull($this->session->get('foo'));
@@ -97,13 +97,13 @@ class SessionTest extends \PHPUnit_Framework_TestCase
 
         $this->session = $this->getSession();
 
-        $this->session->setAttributes($attrs);
+        $this->session->replace($attrs);
 
-        $this->assertSame($attrs, $this->session->getAttributes());
+        $this->assertSame($attrs, $this->session->all());
 
         $this->session->clear();
 
-        $this->assertSame(array(), $this->session->getAttributes());
+        $this->assertSame(array(), $this->session->all());
     }
 
     public function testMigrateAndInvalidate()
@@ -122,7 +122,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
         $this->session = $this->getSession();
         $this->session->invalidate();
 
-        $this->assertSame(array(), $this->session->getAttributes());
+        $this->assertSame(array(), $this->session->all());
         $this->assertSame(array(), $this->session->getFlashes());
     }
 
@@ -198,7 +198,7 @@ class SessionTest extends \PHPUnit_Framework_TestCase
         $this->assertSame('en', \Locale::getDefault());
 
         $this->assertSame(array(), $this->session->getFlashes());
-        $this->assertSame(array(), $this->session->getAttributes());
+        $this->assertSame(array(), $this->session->all());
     }
 
     public function testStorageRegenerate()