8000 bug #35028 [TwigBridge] Fix invalid typehint for subject in is_grante… · symfony/symfony@edac0ce · GitHub
[go: up one dir, main page]

Skip to content

Commit edac0ce

Browse files
bug #35028 [TwigBridge] Fix invalid typehint for subject in is_granted Twig function (emodric)
This PR was merged into the 5.0 branch. Discussion ---------- [TwigBridge] Fix invalid typehint for subject in is_granted Twig function | Q | A | ------------- | --- | Branch? | 5.0 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35026 | License | MIT | Doc PR | N/A Twig function `is_granted` does not accept `mixed` any more for its second argument, instead requiring `object` or `null` with a PHP typehint. `AuthorizationCheckerInterface::isGranted`, where this argument is passed, has no typehint in code and is typehinted as `mixed` in PHPDoc. This makes it impossible to have a check in Twig template with code similar to this: `{% if is_granted('ROLE_MY_APP', {foo: 'bar', bar: 'baz'}) %}...{% endif %}` Commits ------- d3d86ce Fix invalid typehint for subject in is_granted Twig function
2 parents c048ea5 + d3d86ce commit edac0ce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Symfony/Bridge/Twig/Extension/SecurityExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public function __construct(AuthorizationCheckerInterface $securityChecker = nul
3131
$this->securityChecker = $securityChecker;
3232
}
3333

34-
public function isGranted($role, object $object = null, string $field = null): bool
34+
/**
35+
* @param mixed $object
36+
*/
37+
public function isGranted($role, $object = null, string $field = null): bool
3538
{
3639
if (null === $this->securityChecker) {
3740
return false;

0 commit comments

Comments
 (0)
0