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

Skip to content

[TwigBridge] Fix invalid typehint for subject in is_granted Twig function #35028

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

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

emodric
Copy link
Contributor

@emodric emodric commented Dec 18, 2019

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

@nicolas-grekas
Copy link
Member

Thank you @emodric.

nicolas-grekas added a commit that referenced this pull request Dec 18, 2019
…d 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
@nicolas-grekas nicolas-grekas merged commit d3d86ce into symfony:5.0 Dec 18, 2019
emodric added a commit to netgen-layouts/layouts-core that referenced this pull request Dec 19, 2019
@fabpot fabpot mentioned this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants