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

Does not understand 'Higher Order Messages' #359

Open
Dylan-DutchAndBold opened this issue Dec 24, 2018 · 2 comments
Open

Does not understand 'Higher Order Messages' #359

Dylan-DutchAndBold opened this issue Dec 24, 2018 · 2 comments

Comments

@Dylan-DutchAndBold
Copy link

I have this line of code in Twig:
user.roles.first.is(role) to truth check if I should set an option to selected. This should translate to $user->roles->first->is($role). But it seems to do something more in the ballpark of this $user->roles->first()->is($role)

This is what getAttribute resolves into:
screenshot 2018-12-24 at 11 49 50

This is what it should resolve into:
screenshot 2018-12-24 at 11 49 27

@Dylan-DutchAndBold
Copy link
Author

Dylan-DutchAndBold commented Dec 24, 2018

I believe it goes bad on line 582 of Twig\Template. It does an isset check of the property. But since the HigherOrderCollectionProxy is created in the magic __get method of a Collection. It returns false and tries it as a function.

Dylan-DutchAndBold added a commit to Dylan-DutchAndBold/TwigBridge that referenced this issue Dec 24, 2018
Allows `Collection` `Higher Order Message` feature to work. The issue is explained in
rcrowe#359 However this might create unwanted behavior. I'll explain further within the issue
@Dylan-DutchAndBold
Copy link
Author

I have created a possible solution to this issue, it actually does the same as what it does for a Model class objects. However this does mean that if you'd use to use something like this before: user.roles.first.name, it will now no longer work. You'd now have to write user.roles.first().name. So this might be unwanted.

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

No branches or pull requests

1 participant