Skip to content

is_granted cannot be passed an array as a second argument (subject) #35026

Closed
@emodric

Description

@emodric

Symfony version(s) affected: 5.0.1

Description

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 %}

Is this something that was intended, because it doesn't seem so? Upgrade docs mention that the attribute cannot be an array anymore in AuthorizationCheckerInterface::isGranted, but it does not mention that the subject is now required to be a PHP object.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions