Skip to content

Commit 4a70ddf

Browse files
committed
[HttpFoundation] removed deprecated session methods
1 parent 4e7943f commit 4a70ddf

File tree

4 files changed

+1
-247
lines changed

4 files changed

+1
-247
lines changed

src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Drak <drak@zikula.org>
1818
*/
19-
class FlashBag implements FlashBagInterface, \IteratorAggregate, \Countable
19+
class FlashBag implements FlashBagInterface, \IteratorAggregate
2020
{
2121
private $name = 'flashes';
2222

@@ -173,21 +173,4 @@ public function getIterator()
173173
{
174174
return new \ArrayIterator($this->all());
175175
}
176-
177-
/**
178-
* Returns the number of flashes.
179-
*
180-
* This method does not work.
181-
*
182-
* @deprecated in 2.2, removed in 2.3
183-
* @see https://github.com/symfony/symfony/issues/6408
184-
*
185-
* @return int The number of flashes
186-
*/
187-
public function count()
188-
{
189-
trigger_error(sprintf('%s() is deprecated since 2.2 and will be removed in 2.3', __METHOD__), E_USER_DEPRECATED);
190-
191-
return count($this->flashes);
192-
}
193176
}

src/Symfony/Component/HttpFoundation/Session/Session.php

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -249,113 +249,4 @@ public function getFlashBag()
249249
{
250250
return $this->getBag($this->flashName);
251251
}
252-
253-
// the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3)
254-
255-
/**
256-
* @return array
257-
*
258-
* @deprecated since 2.1, will be removed from 2.3
259-
*/
260-
public function getFlashes()
261-
{
262-
trigger_error('getFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
263-
264-
$all = $this->getBag($this->flashName)->all();
265-
266-
$return = array();
267-
if ($all) {
268-
foreach ($all as $name => $array) {
269-
if (is_numeric(key($array))) {
270-
$return[$name] = reset($array);
271-
} else {
272-
$return[$name] = $array;
273-
}
274-
}
275-
}
276-
277-
return $return;
278-
}
279-
280-
/**
281-
* @param array $values
282-
*
283-
* @deprecated since 2.1, will be removed from 2.3
284-
*/
285-
public function setFlashes($values)
286-
{
287-
trigger_error('setFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
288-
289-
foreach ($values as $name => $value) {
290-
$this->getBag($this->flashName)->set($name, $value);
291-
}
292-
}
293-
294-
/**
295-
* @param string $name
296-
* @param string $default
297-
*
298-
* @return string
299-
*
300-
* @deprecated since 2.1, will be removed from 2.3
301-
*/
302-
public function getFlash($name, $default = null)
303-
{
304-
trigger_error('getFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
305-
306-
$return = $this->getBag($this->flashName)->get($name);
307-
308-
return empty($return) ? $default : reset($return);
309-
}
310-
311-
/**
312-
* @param string $name
313-
* @param string $value
314-
*
315-
* @deprecated since 2.1, will be removed from 2.3
316-
*/
317-
public function setFlash($name, $value)
318-
{
319-
trigger_error('setFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
320-
321-
$this->getBag($this->flashName)->set($name, $value);
322-
}
323-
324-
/**
325-
* @param string $name
326-
*
327-
* @return Boolean
328-
*
329-
* @deprecated since 2.1, will be removed from 2.3
330-
*/
331-
public function hasFlash($name)
332-
{
333-
trigger_error('hasFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
334-
335-
return $this->getBag($this->flashName)->has($name);
336-
}
337-
338-
/**
339-
* @param string $name
340-
*
341-
* @deprecated since 2.1, will be removed from 2.3
342-
*/
343-
public function removeFlash($name)
344-
{
345-
trigger_error('removeFlash() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
346-
347-
$this->getBag($this->flashName)->get($name);
348-
}
349-
350-
/**
351-
* @return array
352-
*
353-
* @deprecated since 2.1, will be removed from 2.3
354-
*/
355-
public function clearFlashes()
356-
{
357-
trigger_error('clearFlashes() is deprecated since version 2.1 and will be removed in 2.3. Use the FlashBag instead.', E_USER_DEPRECATED);
358-
359-
return $this->getBag($this->flashName)->clear();
360-
}
361252
}

src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,6 @@ public function testPeekAll()
133133
);
134134
}
135135

136-
/**
137-
* @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::count
138-
* @expectedException \PHPUnit_Framework_Error_Deprecated
139-
*/
140-
public function testCount()
141-
{
142-
$flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope');
143-
foreach ($flashes as $key => $val) {
144-
$this->bag->set($key, $val);
145-
}
146-
147-
$this->assertEquals(count($flashes), count($this->bag));
148-
}
149-
150136
/**
151137
* @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::getIterator
152138
*/

src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ protected function tearDown()
4747
$this->session = null;
4848
}
4949

50-
public function deprecationErrorHandler($errorNumber, $message, $file, $line, $context)
51-
{
52-
if ($errorNumber & E_USER_DEPRECATED) {
53-
return true;
54-
}
55-
56-
return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line);
57-
}
58-
5950
public function testStart()
6051
{
6152
$this->assertEquals('', $this->session->getId());
@@ -199,103 +190,6 @@ public function testGetFlashBag()
199190
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface', $this->session->getFlashBag());
200191
}
201192

202-
// deprecated since 2.1, will be removed from 2.3
203-
204-
public function testGetSetFlashes()
205-
{
206-
set_error_handler(array($this, "deprecationErrorHandler"));
207-
208-
$array = array('notice' => 'hello', 'error' => 'none');
209-
$this->assertEquals(array(), $this->session->getFlashes());
210-
$this->session->setFlashes($array);
211-
$this->assertEquals($array, $this->session->getFlashes());
212-
$this->assertEquals(array(), $this->session->getFlashes());
213-
$this->session->getFlashBag()->add('notice', 'foo');
214-
215-
// test that BC works by only retrieving the first added.
216-
$this->session->getFlashBag()->add('notice', 'foo2');
217-
$this->assertEquals(array('notice' => 'foo'), $this->session->getFlashes());
218-
219-
restore_error_handler();
220-
}
221-
222-
public function testGetFlashesWithArray()
223-
{
224-
set_error_handler(array($this, "deprecationErrorHandler"));
225-
226-
$array = array('notice' => 'hello', 'error' => 'none');
227-
$this->assertEquals(array(), $this->session->getFlashes());
228-
$this->session->setFlash('foo', $array);
229-
$this->assertEquals(array('foo' => $array), $this->session->getFlashes());
230-
$this->assertEquals(array(), $this->session->getFlashes());
231-
232-
$array = array('hello', 'foo');
233-
$this->assertEquals(array(), $this->session->getFlashes());
234-
$this->session->setFlash('foo', $array);
235-
$this->assertEquals(array('foo' => 'hello'), $this->session->getFlashes());
236-
$this->assertEquals(array(), $this->session->getFlashes());
237-
238-
restore_error_handler();
239-
}
240-
241-
public function testGetSetFlash()
242-
{
243-
set_error_handler(array($this, "deprecationErrorHandler"));
244-
245-
$this->assertNull($this->session->getFlash('notice'));
246-
$this->assertEquals('default', $this->session->getFlash('notice', 'default'));
247-
$this->session->getFlashBag()->add('notice', 'foo');
248-
$this->session->getFlashBag()->add('notice', 'foo2');
249-
250-
// test that BC works by only retrieving the first added.
251-
$this->assertEquals('foo', $this->session->getFlash('notice'));
252-
$this->assertNull($this->session->getFlash('notice'));
253-
254-
restore_error_handler();
255-
}
256-
257-
public function testHasFlash()
258-
{
259-
set_error_handler(array($this, "deprecationErrorHandler"));
260-
261-
$this->assertFalse($this->session->hasFlash('notice'));
262-
$this->session->setFlash('notice', 'foo');
263-
$this->assertTrue($this->session->hasFlash('notice'));
264-
265-
restore_error_handler();
266-
}
267-
268-
public function testRemoveFlash()
269-
{
270-
set_error_handler(array($this, "deprecationErrorHandler"));
271-
272-
$this->session->setFlash('notice', 'foo');
273-
$this->session->setFlash('error', 'bar');
274-
$this->assertTrue($this->session->hasFlash('notice'));
275-
$this->session->removeFlash('error');
276-
$this->assertTrue($this->session->hasFlash('notice'));
277-
$this->assertFalse($this->session->hasFlash('error'));
278-
279-
restore_error_handler();
280-
}
281-
282-
public function testClearFlashes()
283-
{
284-
set_error_handler(array($this, "deprecationErrorHandler"));
285-
286-
$this->assertFalse($this->session->hasFlash('notice'));
287-
$this->assertFalse($this->session->hasFlash('error'));
288-
$this->session->setFlash('notice', 'foo');
289-
$this->session->setFlash('error', 'bar');
290-
$this->assertTrue($this->session->hasFlash('notice'));
291-
$this->assertTrue($this->session->hasFlash('error'));
292-
$this->session->clearFlashes();
293-
$this->assertFalse($this->session->hasFlash('notice'));
294-
$this->assertFalse($this->session->hasFlash('error'));
295-
296-
restore_error_handler();
297-
}
298-
299193
/**
300194
* @covers Symfony\Component\HttpFoundation\Session\Session::getIterator
301195
*/

0 commit comments

Comments
 (0)