Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d3c74b

Browse files
Merge branch '3.4'
* 3.4: [Finder] Deprecate FilterIterator forward compatibility with Symfony 4
2 parents 1a7dde4 + 08aa6a8 commit 4d3c74b

File tree

6 files changed

+29
-2
lines changed

6 files changed

+29
-2
lines changed

UPGRADE-3.4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
UPGRADE FROM 3.3 to 3.4
22
=======================
33

4+
Finder
5+
------
6+
7+
* The `Symfony\Component\Finder\Iterator\FilterIterator` class has been
8+
deprecated and will be removed in 4.0 as it used to fix a bug which existed
9+
before version 5.5.23/5.6.7
10+
411
Validator
512
---------
613

UPGRADE-4.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ Finder
145145
------
146146

147147
* The `ExceptionInterface` has been removed.
148+
* The `Symfony\Component\Finder\Iterator\FilterIterator` class has been
149+
removed as it used to fix a bug which existed before version 5.5.23/5.6.7
148150

149151
Form
150152
----

src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\SecurityBundle\DataCollector;
1313

1414
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
15+
use Symfony\Component\Security\Core\Role\Role;
1516
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
1617
use Symfony\Component\HttpFoundation\Request;
1718
use Symfony\Component\HttpFoundation\Response;
@@ -110,15 +111,23 @@ public function collect(Request $request, Response $response, \Exception $except
110111
// fail silently when the logout URL cannot be generated
111112
}
112113

114+
$extractRoles = function ($role) {
115+
if (!$role instanceof RoleInterface && !$role instanceof Role) {
116+
throw new \InvalidArgumentException(sprintf('Roles must be instances of %s or %s (%s given).', RoleInterface::class, Role::class, is_object($role) ? get_class($role) : gettype($role)));
117+
}
118+
119+
return $role->getRole();
120+
};
121+
113122
$this->data = array(
114123
'enabled' => true,
115124
'authenticated' => $token->isAuthenticated(),
116125
'token' => $token,
117126
'token_class' => $this->hasVarDumper ? new ClassStub(get_class($token)) : get_class($token),
118127
'logout_url' => $logoutUrl,
119128
'user' => $token->getUsername(),
120-
'roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $assignedRoles),
121-
'inherited_roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $inheritedRoles),
129+
'roles' => array_map($extractRoles, $assignedRoles),
130+
'inherited_roles' => array_map($extractRoles, $inheritedRoles),
122131
'supports_role_hierarchy' => null !== $this->roleHierarchy,
123132
);
124133
}

src/Symfony/Component/Finder/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ CHANGELOG
66

77
* removed `ExceptionInterface`
88

9+
3.4.0
10+
-----
11+
12+
* deprecated `Symfony\Component\Finder\Iterator\FilterIterator`
13+
914
3.3.0
1015
-----
1116

src/Symfony/Component/Finder/Iterator/FilterIterator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* @see https://bugs.php.net/68557
1919
*
2020
* @author Alex Bogomazov
21+
*
22+
* @deprecated since 3.4, to be removed in 4.0.
2123
*/
2224
abstract class FilterIterator extends \FilterIterator
2325
{

src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* @author Alex Bogomazov
16+
*
17+
* @group legacy
1618
*/
1719
class FilterIteratorTest extends RealIteratorTestCase
1820
{

0 commit comments

Comments
 (0)