From 0cf9fcb30459a887368e66e9db26c5220914dc24 Mon Sep 17 00:00:00 2001 From: Drak Date: Thu, 20 Dec 2012 17:42:47 +0000 Subject: [PATCH] [HttpFoundation] Deprecated count() and \Countable --- src/Symfony/Component/HttpFoundation/CHANGELOG.md | 1 + .../Component/HttpFoundation/Session/Flash/FlashBag.php | 2 ++ .../HttpFoundation/Tests/Session/Flash/FlashBagTest.php | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/CHANGELOG.md b/src/Symfony/Component/HttpFoundation/CHANGELOG.md index 13ed8dd7c96c..c83695f7478d 100644 --- a/src/Symfony/Component/HttpFoundation/CHANGELOG.md +++ b/src/Symfony/Component/HttpFoundation/CHANGELOG.md @@ -8,6 +8,7 @@ CHANGELOG * added Request::getRealMethod() to get the "real" HTTP method (getMethod() returns the "intended" HTTP method) * disabled _method request parameter support by default (call Request::enableHttpMethodParameterOverride() to enable it) * Request::splitHttpAcceptHeader() method is deprecated and will be removed in 2.3 + * Deprecated Flashbag::count() and \Countable interface, will be removed in 2.3 2.1.0 ----- diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php index ce9308e15456..97966539855b 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -181,6 +181,8 @@ public function getIterator() */ public function count() { + trigger_error(sprintf('%s() is deprecated since 2.2 and will be removed in 2.3', __METHOD__), E_USER_DEPRECATED); + return count($this->flashes); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php index d7d12e59b76b..208a5e705b12 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php @@ -135,6 +135,7 @@ public function testPeekAll() /** * @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::count + * @expectedException \PHPUnit_Framework_Error_Deprecated */ public function testCount() { @@ -163,6 +164,6 @@ public function testGetIterator() } $this->assertEquals(count($flashes), $i); - $this->assertEquals(0, count($this->bag)); + $this->assertEquals(0, count($this->bag->all())); } }