Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[HttpFoundation] removed deprecated session methods

  • Loading branch information...
commit 4a70ddff4d68f7c29af177c0ba8dc6543848ca33 1 parent 4e7943f
@fabpot fabpot authored
View
19 src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php
@@ -16,7 +16,7 @@
*
* @author Drak <drak@zikula.org>
*/
-class FlashBag implements FlashBagInterface, \IteratorAggregate, \Countable
+class FlashBag implements FlashBagInterface, \IteratorAggregate
{
private $name = 'flashes';
@@ -173,21 +173,4 @@ public function getIterator()
{
return new \ArrayIterator($this->all());
}
-
- /**
- * Returns the number of flashes.
- *
- * This method does not work.
- *
- * @deprecated in 2.2, removed in 2.3
- * @see https://github.com/symfony/symfony/issues/6408
- *
- * @return int The number of flashes
- */
- 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);
- }
}
View
109 src/Symfony/Component/HttpFoundation/Session/Session.php
@@ -249,113 +249,4 @@ public function getFlashBag()
{
return $this->getBag($this->flashName);
}
-
- // the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3)
-
- /**
- * @return array
- *
- * @deprecated since 2.1, will be removed from 2.3
- */
- public function getFlashes()
- {
- trigger_error('getFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
-
- $all = $this->getBag($this->flashName)->all();
-
- $return = array();
- if ($all) {
- foreach ($all as $name => $array) {
- if (is_numeric(key($array))) {
- $return[$name] = reset($array);
- } else {
- $return[$name] = $array;
- }
- }
- }
-
- return $return;
- }
-
- /**
- * @param array $values
- *
- * @deprecated since 2.1, will be removed from 2.3
- */
- public function setFlashes($values)
- {
- trigger_error('setFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
-
- foreach ($values as $name => $value) {
- $this->getBag($this->flashName)->set($name, $value);
- }
- }
-
- /**
- * @param string $name
- * @param string $default
- *
- * @return string
- *
- * @deprecated since 2.1, will be removed from 2.3
- */
- public function getFlash($name, $default = null)
- {
- trigger_error('getFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
-
- $return = $this->getBag($this->flashName)->get($name);
-
- return empty($return) ? $default : reset($return);
- }
-
- /**
- * @param string $name
- * @param string $value
- *
- * @deprecated since 2.1, will be removed from 2.3
- */
- public function setFlash($name, $value)
- {
- trigger_error('setFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
-
- $this->getBag($this->flashName)->set($name, $value);
- }
-
- /**
- * @param string $name
- *
- * @return Boolean
- *
- * @deprecated since 2.1, will be removed from 2.3
- */
- public function hasFlash($name)
- {
- trigger_error('hasFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
-
- return $this->getBag($this->flashName)->has($name);
- }
-
- /**
- * @param string $name
- *
- * @deprecated since 2.1, will be removed from 2.3
- */
- public function removeFlash($name)
- {
- trigger_error('removeFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
-
- $this->getBag($this->flashName)->get($name);
- }
-
- /**
- * @return array
- *
- * @deprecated since 2.1, will be removed from 2.3
- */
- public function clearFlashes()
- {
- trigger_error('clearFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
-
- return $this->getBag($this->flashName)->clear();
- }
}
View
14 src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php
@@ -134,20 +134,6 @@ public function testPeekAll()
}
/**
- * @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::count
- * @expectedException \PHPUnit_Framework_Error_Deprecated
- */
- public function testCount()
- {
- $flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope');
- foreach ($flashes as $key => $val) {
- $this->bag->set($key, $val);
- }
-
- $this->assertEquals(count($flashes), count($this->bag));
- }
-
- /**
* @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::getIterator
*/
public function testGetIterator()
View
106 src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
@@ -47,15 +47,6 @@ protected function tearDown()
$this->session = null;
}
- public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context)
- {
- if ($errorNumber & E_USER_DEPRECATED) {
- return true;
- }
-
- return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line);
- }
-
public function testStart()
{
$this->assertEquals('', $this->session->getId());
@@ -199,103 +190,6 @@ public function testGetFlashBag()
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag());
}
- // deprecated since 2.1, will be removed from 2.3
-
- public function testGetSetFlashes()
- {
- set_error_handler(array($this, "deprecationErrorHandler"));
-
- $array = array('notice' => 'hello', 'error' => 'none');
- $this->assertEquals(array(), $this->session->getFlashes());
- $this->session->setFlashes($array);
- $this->assertEquals($array, $this->session->getFlashes());
- $this->assertEquals(array(), $this->session->getFlashes());
- $this->session->getFlashBag()->add('notice', 'foo');
-
- // test that BC works by only retrieving the first added.
- $this->session->getFlashBag()->add('notice', 'foo2');
- $this->assertEquals(array('notice' => 'foo'), $this->session->getFlashes());
-
- restore_error_handler();
- }
-
- public function testGetFlashesWithArray()
- {
- set_error_handler(array($this, "deprecationErrorHandler"));
-
- $array = array('notice' => 'hello', 'error' => 'none');
- $this->assertEquals(array(), $this->session->getFlashes());
- $this->session->setFlash('foo', $array);
- $this->assertEquals(array('foo' => $array), $this->session->getFlashes());
- $this->assertEquals(array(), $this->session->getFlashes());
-
- $array = array('hello', 'foo');
- $this->assertEquals(array(), $this->session->getFlashes());
- $this->session->setFlash('foo', $array);
- $this->assertEquals(array('foo' => 'hello'), $this->session->getFlashes());
- $this->assertEquals(array(), $this->session->getFlashes());
-
- restore_error_handler();
- }
-
- public function testGetSetFlash()
- {
- set_error_handler(array($this, "deprecationErrorHandler"));
-
- $this->assertNull($this->session->getFlash('notice'));
- $this->assertEquals('default', $this->session->getFlash('notice', 'default'));
- $this->session->getFlashBag()->add('notice', 'foo');
- $this->session->getFlashBag()->add('notice', 'foo2');
-
- // test that BC works by only retrieving the first added.
- $this->assertEquals('foo', $this->session->getFlash('notice'));
- $this->assertNull($this->session->getFlash('notice'));
-
- restore_error_handler();
- }
-
- public function testHasFlash()
- {
- set_error_handler(array($this, "deprecationErrorHandler"));
-
- $this->assertFalse($this->session->hasFlash('notice'));
- $this->session->setFlash('notice', 'foo');
- $this->assertTrue($this->session->hasFlash('notice'));
-
- restore_error_handler();
- }
-
- public function testRemoveFlash()
- {
- set_error_handler(array($this, "deprecationErrorHandler"));
-
- $this->session->setFlash('notice', 'foo');
- $this->session->setFlash('error', 'bar');
- $this->assertTrue($this->session->hasFlash('notice'));
- $this->session->removeFlash('error');
- $this->assertTrue($this->session->hasFlash('notice'));
- $this->assertFalse($this->session->hasFlash('error'));
-
- restore_error_handler();
- }
-
- public function testClearFlashes()
- {
- set_error_handler(array($this, "deprecationErrorHandler"));
-
- $this->assertFalse($this->session->hasFlash('notice'));
- $this->assertFalse($this->session->hasFlash('error'));
- $this->session->setFlash('notice', 'foo');
- $this->session->setFlash('error', 'bar');
- $this->assertTrue($this->session->hasFlash('notice'));
- $this->assertTrue($this->session->hasFlash('error'));
- $this->session->clearFlashes();
- $this->assertFalse($this->session->hasFlash('notice'));
- $this->assertFalse($this->session->hasFlash('error'));
-
- restore_error_handler();
- }
-
/**
* @covers Symfony\Component\HttpFoundation\Session\Session::getIterator
*/
Please sign in to comment.
Something went wrong with that request. Please try again.