Skip to content

[HttpFoundation] remove deprecated : FlashBag don't implement anymore IteratorAggregate #13258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,3 +1031,7 @@ UPGRADE FROM 2.x to 3.0
### Swiftmailer Bridge

* `Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector` was removed. Use the `Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector` class instead.

### HttpFoundation

* `Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface` no longer implements the `IteratorAggregate` interface. Use the `all()` method instead of iterating over the flash bag.
18 changes: 1 addition & 17 deletions src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
/**
* FlashBag flash message container.
*
* \IteratorAggregate implementation is deprecated and will be removed in 3.0.
*
* @author Drak <drak@zikula.org>
*/
class FlashBag implements FlashBagInterface, \IteratorAggregate
class FlashBag implements FlashBagInterface
{
private $name = 'flashes';

Expand Down Expand Up @@ -165,18 +163,4 @@ public function clear()
{
return $this->all();
}

/**
* Returns an iterator for flashes.
*
* @deprecated since version 2.4, to be removed in 3.0.
*
* @return \ArrayIterator An \ArrayIterator instance
*/
public function getIterator()
{
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);

return new \ArrayIterator($this->all());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,4 @@ public function testPeekAll()
), $this->bag->peekAll()
);
}

/**
* @covers Symfony\Component\HttpFoundation\Session\Flash\FlashBag::getIterator
*/
public function testLegacyGetIterator()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$flashes = array('hello' => 'world', 'beep' => 'boop', 'notice' => 'nope');
foreach ($flashes as $key => $val) {
$this->bag->set($key, $val);
}

$i = 0;
foreach ($this->bag as $key => $val) {
$this->assertEquals(array($flashes[$key]), $val);
$i++;
}

$this->assertEquals(count($flashes), $i);
$this->assertCount(0, $this->bag->all());
}
}