Skip to content
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

fix #58 - Call to a member function getCallable() on bool. #59

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

oallain
Copy link
Member

@oallain oallain commented Sep 17, 2023

Q A
Bug fix? yes
New feature? no
BC breaks? no
Fixed issue #58

@oallain oallain changed the title fix issue #58 fix #58 - Call to a member function getCallable() on bool. Sep 17, 2023
@@ -21,7 +21,7 @@ public function hasPermission(Environment $env, string $permission): bool
{
$function = $env->getFunction('sylius_plus_rbac_has_permission');

if ($function !== null && is_callable($function->getCallable())) {
if (is_object($function) && is_callable($function->getCallable())) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion it's pretty weird to check if a variable called "function" is an object or not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method signature has changed between Twig v2 and Twig v3.

Twig v2

    /**
     * @return TwigFunction|false
     */
    public function getFunction($name)

In Twig v3

    public function getFunction(string $name): ?TwigFunction

So check only with null is not enough.

@Jibbarth Jibbarth merged commit dc3f1b7 into master Sep 22, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants